2012-05-21 04:12:37 -07:00
|
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
2009-02-19 05:09:54 -08:00
|
|
|
|
|
|
|
function test() {
|
|
|
|
/** Test for Bug 447951 **/
|
2012-05-25 14:39:22 -07:00
|
|
|
|
2009-02-19 05:09:54 -08:00
|
|
|
waitForExplicitFinish();
|
2010-03-12 13:53:36 -08:00
|
|
|
const baseURL = "http://mochi.test:8888/browser/" +
|
2011-12-16 01:11:21 -08:00
|
|
|
"browser/components/sessionstore/test/browser_447951_sample.html#";
|
2012-05-25 14:39:22 -07:00
|
|
|
|
2014-02-06 17:15:59 -08:00
|
|
|
// Make sure the functionality added in bug 943339 doesn't affect the results
|
|
|
|
gPrefService.setIntPref("browser.sessionstore.max_serialize_back", -1);
|
|
|
|
gPrefService.setIntPref("browser.sessionstore.max_serialize_forward", -1);
|
|
|
|
registerCleanupFunction(function () {
|
|
|
|
gPrefService.clearUserPref("browser.sessionstore.max_serialize_back");
|
|
|
|
gPrefService.clearUserPref("browser.sessionstore.max_serialize_forward");
|
|
|
|
});
|
|
|
|
|
2009-02-19 05:09:54 -08:00
|
|
|
let tab = gBrowser.addTab();
|
2013-11-23 12:13:15 -08:00
|
|
|
whenBrowserLoaded(tab.linkedBrowser, function() {
|
2009-02-19 05:09:54 -08:00
|
|
|
let tabState = { entries: [] };
|
|
|
|
let max_entries = gPrefService.getIntPref("browser.sessionhistory.max_entries");
|
|
|
|
for (let i = 0; i < max_entries; i++)
|
|
|
|
tabState.entries.push({ url: baseURL + i });
|
2012-05-25 14:39:22 -07:00
|
|
|
|
2009-02-19 05:09:54 -08:00
|
|
|
ss.setTabState(tab, JSON.stringify(tabState));
|
2013-11-23 12:13:15 -08:00
|
|
|
whenTabRestored(tab, function() {
|
2014-01-20 08:36:59 -08:00
|
|
|
SyncHandlers.get(tab.linkedBrowser).flush();
|
2010-06-09 13:55:45 -07:00
|
|
|
tabState = JSON.parse(ss.getTabState(tab));
|
2009-02-19 05:09:54 -08:00
|
|
|
is(tabState.entries.length, max_entries, "session history filled to the limit");
|
|
|
|
is(tabState.entries[0].url, baseURL + 0, "... but not more");
|
2012-05-25 14:39:22 -07:00
|
|
|
|
2009-02-19 05:09:54 -08:00
|
|
|
// visit yet another anchor (appending it to session history)
|
2014-01-20 08:36:59 -08:00
|
|
|
tab.linkedBrowser.contentDocument.querySelector("a").click();
|
2012-05-25 14:39:22 -07:00
|
|
|
|
2013-11-23 12:13:15 -08:00
|
|
|
function check() {
|
2014-01-20 08:36:59 -08:00
|
|
|
SyncHandlers.get(tab.linkedBrowser).flush();
|
2010-06-09 13:55:45 -07:00
|
|
|
tabState = JSON.parse(ss.getTabState(tab));
|
2013-11-23 12:13:15 -08:00
|
|
|
if (tabState.entries[tabState.entries.length - 1].url != baseURL + "end") {
|
|
|
|
// It may take a few passes through the event loop before we
|
|
|
|
// get the right URL.
|
|
|
|
executeSoon(check);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2009-02-19 05:09:54 -08:00
|
|
|
is(tab.linkedBrowser.currentURI.spec, baseURL + "end",
|
|
|
|
"the new anchor was loaded");
|
|
|
|
is(tabState.entries[tabState.entries.length - 1].url, baseURL + "end",
|
|
|
|
"... and ignored");
|
|
|
|
is(tabState.entries[0].url, baseURL + 1,
|
|
|
|
"... and the first item was removed");
|
2012-05-25 14:39:22 -07:00
|
|
|
|
2009-02-19 05:09:54 -08:00
|
|
|
// clean up
|
|
|
|
gBrowser.removeTab(tab);
|
|
|
|
finish();
|
2013-11-23 12:13:15 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
check();
|
|
|
|
});
|
|
|
|
});
|
2009-02-19 05:09:54 -08:00
|
|
|
}
|