no bug - Bumping Firefox l10n changesets r=release a=l10n-bump DONTBUILD CLOSED TREE
[gecko.git] / docshell / test / browser / browser_bug673467.js
blob507410254c4ce372da20dc8489f9814f617b119a
1 /* Any copyright is dedicated to the Public Domain.
2    http://creativecommons.org/publicdomain/zero/1.0/ */
4 // Test for bug 673467.  In a new tab, load a page which inserts a new iframe
5 // before the load and then sets its location during the load.  This should
6 // create just one SHEntry.
8 var doc =
9   "data:text/html,<html><body onload='load()'>" +
10   "<script>" +
11   "  var iframe = document.createElement('iframe');" +
12   "  iframe.id = 'iframe';" +
13   "  document.documentElement.appendChild(iframe);" +
14   "  function load() {" +
15   "    iframe.src = 'data:text/html,Hello!';" +
16   "  }" +
17   "</script>" +
18   "</body></html>";
20 function test() {
21   waitForExplicitFinish();
23   let taskFinished;
25   let tab = BrowserTestUtils.addTab(gBrowser, doc, {}, tab => {
26     taskFinished = ContentTask.spawn(tab.linkedBrowser, null, () => {
27       return new Promise(resolve => {
28         addEventListener(
29           "load",
30           function () {
31             // The main page has loaded.  Now wait for the iframe to load.
32             let iframe = content.document.getElementById("iframe");
33             iframe.addEventListener(
34               "load",
35               function listener(aEvent) {
36                 // Wait for the iframe to load the new document, not about:blank.
37                 if (!iframe.src) {
38                   return;
39                 }
41                 iframe.removeEventListener("load", listener, true);
42                 let shistory = content.docShell.QueryInterface(
43                   Ci.nsIWebNavigation
44                 ).sessionHistory;
46                 Assert.equal(shistory.count, 1, "shistory count should be 1.");
47                 resolve();
48               },
49               true
50             );
51           },
52           true
53         );
54       });
55     });
56   });
58   taskFinished.then(() => {
59     gBrowser.removeTab(tab);
60     finish();
61   });