4 function test(aLambda) {
6 return aLambda() ||
true;
17 let ssComponent =
test(
function()
Cc[
"@mozilla.org/browser/sessionstore;1"]);
18 ok(ssComponent,
"reference the sessionstore component");
21 let ss =
test(
function() ssComponent.getService(
Ci.nsISessionStore));
22 ok(ss,
"reference the sessionstore service");
27 let
key =
"Unique name: " + Date.now();
28 let
value =
"Unique value: " + Math.random();
31 ok(
test(
function() ss.setWindowValue(
window, key, value)),
"set a window value");
34 is(ss.getWindowValue(
window, key),
value,
"stored window value matches original");
37 ok(
test(
function() ss.deleteWindowValue(
window, key)),
"delete the window value");
40 is(ss.getWindowValue(
window, key),
"",
"window value was deleted");
45 key =
"Unique name: " + Math.random();
46 value =
"Unique value: " + Date.now();
47 let
tab = tabbrowser.addTab();
50 ok(
test(
function() ss.setTabValue(tab, key, value)),
"store a tab value");
53 is(ss.getTabValue(tab, key),
value,
"stored tab value match original");
56 ok(
test(
function() ss.deleteTabValue(tab, key)),
"delete the tab value");
58 is(ss.getTabValue(tab, key),
"",
"tab value was deleted");
61 tabbrowser.removeTab(tab);
69 let max_tabs_undo =
gPrefService.getIntPref(
"browser.sessionstore.max_tabs_undo");
70 ok(0 <= count && count <= max_tabs_undo,
71 "getClosedTabCount returns zero or at most max_tabs_undo");
75 tab = tabbrowser.addTab(testURL);
76 tab.linkedBrowser.addEventListener(
"load",
function(aEvent) {
78 gPrefService.setIntPref(
"browser.sessionstore.max_tabs_undo", max_tabs_undo + 1);
81 tabbrowser.removeTab(tab);
84 var newcount = ss.getClosedTabCount(
window);
85 ok(newcount > count,
"after closing a tab, getClosedTabCount has been incremented");
88 tab =
test(
function() ss.undoCloseTab(
window, 0));
89 ok(tab,
"undoCloseTab doesn't throw")
91 tab.linkedBrowser.addEventListener(
"load",
function(aEvent) {
92 is(this.currentURI.spec, testURL,
"correct tab was reopened");
95 if (
gPrefService.prefHasUserValue(
"browser.sessionstore.max_tabs_undo"))
96 gPrefService.clearUserPref(
"browser.sessionstore.max_tabs_undo");
97 tabbrowser.removeTab(tab);
function getBrowser() gBrowser