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 | /* This Source Code Form is subject to the terms of the Mozilla Public |
michael@0 | 2 | * License, v. 2.0. If a copy of the MPL was not distributed with this |
michael@0 | 3 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
michael@0 | 4 | |
michael@0 | 5 | function test() { |
michael@0 | 6 | /** Test for Bug 491168 **/ |
michael@0 | 7 | |
michael@0 | 8 | waitForExplicitFinish(); |
michael@0 | 9 | |
michael@0 | 10 | const REFERRER1 = "http://example.org/?" + Date.now(); |
michael@0 | 11 | const REFERRER2 = "http://example.org/?" + Math.random(); |
michael@0 | 12 | |
michael@0 | 13 | let tab = gBrowser.addTab(); |
michael@0 | 14 | gBrowser.selectedTab = tab; |
michael@0 | 15 | |
michael@0 | 16 | let browser = tab.linkedBrowser; |
michael@0 | 17 | whenBrowserLoaded(browser, function() { |
michael@0 | 18 | let tabState = JSON.parse(ss.getTabState(tab)); |
michael@0 | 19 | is(tabState.entries[0].referrer, REFERRER1, |
michael@0 | 20 | "Referrer retrieved via getTabState matches referrer set via loadURI."); |
michael@0 | 21 | |
michael@0 | 22 | tabState.entries[0].referrer = REFERRER2; |
michael@0 | 23 | ss.setTabState(tab, JSON.stringify(tabState)); |
michael@0 | 24 | |
michael@0 | 25 | whenTabRestored(tab, function(e) { |
michael@0 | 26 | is(window.content.document.referrer, REFERRER2, "document.referrer matches referrer set via setTabState."); |
michael@0 | 27 | |
michael@0 | 28 | gBrowser.removeTab(tab); |
michael@0 | 29 | |
michael@0 | 30 | let newTab = ss.undoCloseTab(window, 0); |
michael@0 | 31 | whenTabRestored(newTab, function() { |
michael@0 | 32 | is(window.content.document.referrer, REFERRER2, "document.referrer is still correct after closing and reopening the tab."); |
michael@0 | 33 | gBrowser.removeTab(newTab); |
michael@0 | 34 | |
michael@0 | 35 | finish(); |
michael@0 | 36 | }); |
michael@0 | 37 | }); |
michael@0 | 38 | }); |
michael@0 | 39 | |
michael@0 | 40 | let referrerURI = Services.io.newURI(REFERRER1, null, null); |
michael@0 | 41 | browser.loadURI("http://example.org", referrerURI, null); |
michael@0 | 42 | } |