browser_bug673467.js (1840B)
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 = 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>"; 19 20 function test() { 21 waitForExplicitFinish(); 22 23 let taskFinished; 24 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() { 36 // Wait for the iframe to load the new document, not about:blank. 37 if (!iframe.src) { 38 return; 39 } 40 41 iframe.removeEventListener("load", listener, true); 42 let shistory = content.docShell.QueryInterface( 43 Ci.nsIWebNavigation 44 ).sessionHistory; 45 46 Assert.equal(shistory.count, 1, "shistory count should be 1."); 47 resolve(); 48 }, 49 true 50 ); 51 }, 52 true 53 ); 54 }); 55 }); 56 }); 57 58 taskFinished.then(() => { 59 gBrowser.removeTab(tab); 60 finish(); 61 }); 62 }