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
michael@0 | 1 | /* Any copyright is dedicated to the Public Domain. |
michael@0 | 2 | http://creativecommons.org/publicdomain/zero/1.0/ */ |
michael@0 | 3 | |
michael@0 | 4 | // Test for bug 673467. In a new tab, load a page which inserts a new iframe |
michael@0 | 5 | // before the load and then sets its location during the load. This should |
michael@0 | 6 | // create just one SHEntry. |
michael@0 | 7 | |
michael@0 | 8 | var doc = "data:text/html,<html><body onload='load()'>" + |
michael@0 | 9 | "<script>" + |
michael@0 | 10 | " var iframe = document.createElement('iframe');" + |
michael@0 | 11 | " iframe.id = 'iframe';" + |
michael@0 | 12 | " document.documentElement.appendChild(iframe);" + |
michael@0 | 13 | " function load() {" + |
michael@0 | 14 | " iframe.src = 'data:text/html,Hello!';" + |
michael@0 | 15 | " }" + |
michael@0 | 16 | "</script>" + |
michael@0 | 17 | "</body></html>" |
michael@0 | 18 | |
michael@0 | 19 | function test() { |
michael@0 | 20 | waitForExplicitFinish(); |
michael@0 | 21 | |
michael@0 | 22 | let tab = gBrowser.addTab(doc); |
michael@0 | 23 | let tabBrowser = tab.linkedBrowser; |
michael@0 | 24 | |
michael@0 | 25 | tabBrowser.addEventListener('load', function(aEvent) { |
michael@0 | 26 | tabBrowser.removeEventListener('load', arguments.callee, true); |
michael@0 | 27 | |
michael@0 | 28 | // The main page has loaded. Now wait for the iframe to load. |
michael@0 | 29 | let iframe = tabBrowser.contentWindow.document.getElementById('iframe'); |
michael@0 | 30 | iframe.addEventListener('load', function(aEvent) { |
michael@0 | 31 | |
michael@0 | 32 | // Wait for the iframe to load the new document, not about:blank. |
michael@0 | 33 | if (!iframe.src) |
michael@0 | 34 | return; |
michael@0 | 35 | |
michael@0 | 36 | iframe.removeEventListener('load', arguments.callee, true); |
michael@0 | 37 | let shistory = tabBrowser.contentWindow |
michael@0 | 38 | .QueryInterface(Ci.nsIInterfaceRequestor) |
michael@0 | 39 | .getInterface(Ci.nsIWebNavigation) |
michael@0 | 40 | .sessionHistory; |
michael@0 | 41 | |
michael@0 | 42 | is(shistory.count, 1, 'shistory count should be 1.'); |
michael@0 | 43 | |
michael@0 | 44 | gBrowser.removeTab(tab); |
michael@0 | 45 | finish(); |
michael@0 | 46 | |
michael@0 | 47 | }, true); |
michael@0 | 48 | }, true); |
michael@0 | 49 | } |