41 let ss =
Cc[
"@mozilla.org/browser/sessionstore;1"].getService(
Ci.nsISessionStore);
42 let
ioService =
Cc[
"@mozilla.org/network/io-service;1"].getService(
Ci.nsIIOService);
46 const REFERRER1 =
"http://www.example.net/?" + Date.now();
47 const REFERRER2 =
"http://www.example.net/?" + Math.random();
49 let
tab = gBrowser.addTab();
50 gBrowser.selectedTab =
tab;
52 let
browser = tab.linkedBrowser;
53 browser.addEventListener(
"load",
function() {
54 browser.removeEventListener(
"load",
arguments.callee,
true);
56 let tabState =
JSON.parse(ss.getTabState(tab));
57 is(tabState.entries[0].referrer, REFERRER1,
58 "Referrer retrieved via getTabState matches referrer set via loadURI.");
60 tabState.entries[0].referrer = REFERRER2;
61 ss.setTabState(tab,
JSON.stringify(tabState));
63 tab.addEventListener(
"SSTabRestored",
function() {
64 tab.removeEventListener(
"SSTabRestored",
arguments.callee,
false);
65 is(
window.content.document.referrer, REFERRER2,
"document.referrer matches referrer set via setTabState.");
67 gBrowser.removeTab(tab);
68 let newTab = ss.undoCloseTab(
window, 0);
69 newTab.addEventListener(
"SSTabRestored",
function() {
70 newTab.removeEventListener(
"SSTabRestored",
arguments.callee,
false);
72 is(
window.content.document.referrer, REFERRER2,
"document.referrer is still correct after closing and reopening the tab.");
73 gBrowser.removeTab(newTab);
80 let referrerURI = ioService.newURI(REFERRER1,
null,
null);
81 browser.loadURI(
"http://www.example.net", referrerURI,
null);
return!aWindow arguments!aWindow arguments[0]