docshell/test/browser/browser_bug673467.js

changeset 0
6474c204b198
equal deleted inserted replaced
-1:000000000000 0:0b6be5c28efb
1 /* Any copyright is dedicated to the Public Domain.
2 http://creativecommons.org/publicdomain/zero/1.0/ */
3
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.
7
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>"
18
19 function test() {
20 waitForExplicitFinish();
21
22 let tab = gBrowser.addTab(doc);
23 let tabBrowser = tab.linkedBrowser;
24
25 tabBrowser.addEventListener('load', function(aEvent) {
26 tabBrowser.removeEventListener('load', arguments.callee, true);
27
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) {
31
32 // Wait for the iframe to load the new document, not about:blank.
33 if (!iframe.src)
34 return;
35
36 iframe.removeEventListener('load', arguments.callee, true);
37 let shistory = tabBrowser.contentWindow
38 .QueryInterface(Ci.nsIInterfaceRequestor)
39 .getInterface(Ci.nsIWebNavigation)
40 .sessionHistory;
41
42 is(shistory.count, 1, 'shistory count should be 1.');
43
44 gBrowser.removeTab(tab);
45 finish();
46
47 }, true);
48 }, true);
49 }

mercurial