Wed, 31 Dec 2014 06:09:35 +0100
Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.
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 447951 **/ |
michael@0 | 7 | |
michael@0 | 8 | waitForExplicitFinish(); |
michael@0 | 9 | const baseURL = "http://mochi.test:8888/browser/" + |
michael@0 | 10 | "browser/components/sessionstore/test/browser_447951_sample.html#"; |
michael@0 | 11 | |
michael@0 | 12 | // Make sure the functionality added in bug 943339 doesn't affect the results |
michael@0 | 13 | gPrefService.setIntPref("browser.sessionstore.max_serialize_back", -1); |
michael@0 | 14 | gPrefService.setIntPref("browser.sessionstore.max_serialize_forward", -1); |
michael@0 | 15 | registerCleanupFunction(function () { |
michael@0 | 16 | gPrefService.clearUserPref("browser.sessionstore.max_serialize_back"); |
michael@0 | 17 | gPrefService.clearUserPref("browser.sessionstore.max_serialize_forward"); |
michael@0 | 18 | }); |
michael@0 | 19 | |
michael@0 | 20 | let tab = gBrowser.addTab(); |
michael@0 | 21 | whenBrowserLoaded(tab.linkedBrowser, function() { |
michael@0 | 22 | let tabState = { entries: [] }; |
michael@0 | 23 | let max_entries = gPrefService.getIntPref("browser.sessionhistory.max_entries"); |
michael@0 | 24 | for (let i = 0; i < max_entries; i++) |
michael@0 | 25 | tabState.entries.push({ url: baseURL + i }); |
michael@0 | 26 | |
michael@0 | 27 | ss.setTabState(tab, JSON.stringify(tabState)); |
michael@0 | 28 | whenTabRestored(tab, function() { |
michael@0 | 29 | SyncHandlers.get(tab.linkedBrowser).flush(); |
michael@0 | 30 | tabState = JSON.parse(ss.getTabState(tab)); |
michael@0 | 31 | is(tabState.entries.length, max_entries, "session history filled to the limit"); |
michael@0 | 32 | is(tabState.entries[0].url, baseURL + 0, "... but not more"); |
michael@0 | 33 | |
michael@0 | 34 | // visit yet another anchor (appending it to session history) |
michael@0 | 35 | tab.linkedBrowser.contentDocument.querySelector("a").click(); |
michael@0 | 36 | |
michael@0 | 37 | function check() { |
michael@0 | 38 | SyncHandlers.get(tab.linkedBrowser).flush(); |
michael@0 | 39 | tabState = JSON.parse(ss.getTabState(tab)); |
michael@0 | 40 | if (tabState.entries[tabState.entries.length - 1].url != baseURL + "end") { |
michael@0 | 41 | // It may take a few passes through the event loop before we |
michael@0 | 42 | // get the right URL. |
michael@0 | 43 | executeSoon(check); |
michael@0 | 44 | return; |
michael@0 | 45 | } |
michael@0 | 46 | |
michael@0 | 47 | is(tab.linkedBrowser.currentURI.spec, baseURL + "end", |
michael@0 | 48 | "the new anchor was loaded"); |
michael@0 | 49 | is(tabState.entries[tabState.entries.length - 1].url, baseURL + "end", |
michael@0 | 50 | "... and ignored"); |
michael@0 | 51 | is(tabState.entries[0].url, baseURL + 1, |
michael@0 | 52 | "... and the first item was removed"); |
michael@0 | 53 | |
michael@0 | 54 | // clean up |
michael@0 | 55 | gBrowser.removeTab(tab); |
michael@0 | 56 | finish(); |
michael@0 | 57 | } |
michael@0 | 58 | |
michael@0 | 59 | check(); |
michael@0 | 60 | }); |
michael@0 | 61 | }); |
michael@0 | 62 | } |