Thu, 22 Jan 2015 13:21:57 +0100
Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6
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 = "data:text/html,<html><body onload='load()'>" +
9 "<script>" +
10 " var iframe = document.createElement('iframe');" +
11 " iframe.id = 'iframe';" +
12 " document.documentElement.appendChild(iframe);" +
13 " function load() {" +
14 " iframe.src = 'data:text/html,Hello!';" +
15 " }" +
16 "</script>" +
17 "</body></html>"
19 function test() {
20 waitForExplicitFinish();
22 let tab = gBrowser.addTab(doc);
23 let tabBrowser = tab.linkedBrowser;
25 tabBrowser.addEventListener('load', function(aEvent) {
26 tabBrowser.removeEventListener('load', arguments.callee, true);
28 // The main page has loaded. Now wait for the iframe to load.
29 let iframe = tabBrowser.contentWindow.document.getElementById('iframe');
30 iframe.addEventListener('load', function(aEvent) {
32 // Wait for the iframe to load the new document, not about:blank.
33 if (!iframe.src)
34 return;
36 iframe.removeEventListener('load', arguments.callee, true);
37 let shistory = tabBrowser.contentWindow
38 .QueryInterface(Ci.nsIInterfaceRequestor)
39 .getInterface(Ci.nsIWebNavigation)
40 .sessionHistory;
42 is(shistory.count, 1, 'shistory count should be 1.');
44 gBrowser.removeTab(tab);
45 finish();
47 }, true);
48 }, true);
49 }