docshell/test/browser/browser_bug673467.js

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/docshell/test/browser/browser_bug673467.js	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,49 @@
     1.4 +/* Any copyright is dedicated to the Public Domain.
     1.5 +   http://creativecommons.org/publicdomain/zero/1.0/ */
     1.6 +
     1.7 +// Test for bug 673467.  In a new tab, load a page which inserts a new iframe
     1.8 +// before the load and then sets its location during the load.  This should
     1.9 +// create just one SHEntry.
    1.10 +
    1.11 +var doc = "data:text/html,<html><body onload='load()'>" +
    1.12 + "<script>" +
    1.13 + "  var iframe = document.createElement('iframe');" +
    1.14 + "  iframe.id = 'iframe';" +
    1.15 + "  document.documentElement.appendChild(iframe);" +
    1.16 + "  function load() {" +
    1.17 + "    iframe.src = 'data:text/html,Hello!';" +
    1.18 + "  }" +
    1.19 + "</script>" +
    1.20 + "</body></html>"
    1.21 +
    1.22 +function test() {
    1.23 +  waitForExplicitFinish();
    1.24 +
    1.25 +  let tab = gBrowser.addTab(doc);
    1.26 +  let tabBrowser = tab.linkedBrowser;
    1.27 +
    1.28 +  tabBrowser.addEventListener('load', function(aEvent) {
    1.29 +    tabBrowser.removeEventListener('load', arguments.callee, true);
    1.30 +
    1.31 +    // The main page has loaded.  Now wait for the iframe to load.
    1.32 +    let iframe = tabBrowser.contentWindow.document.getElementById('iframe');
    1.33 +    iframe.addEventListener('load', function(aEvent) {
    1.34 +
    1.35 +      // Wait for the iframe to load the new document, not about:blank.
    1.36 +      if (!iframe.src)
    1.37 +        return;
    1.38 +
    1.39 +      iframe.removeEventListener('load', arguments.callee, true);
    1.40 +      let shistory = tabBrowser.contentWindow
    1.41 +                      .QueryInterface(Ci.nsIInterfaceRequestor)
    1.42 +                      .getInterface(Ci.nsIWebNavigation)
    1.43 +                      .sessionHistory;
    1.44 +
    1.45 +      is(shistory.count, 1, 'shistory count should be 1.');
    1.46 +
    1.47 +      gBrowser.removeTab(tab);
    1.48 +      finish();
    1.49 +
    1.50 +    }, true);
    1.51 +  }, true);
    1.52 +}

mercurial