46 let
pb =
Cc[
"@mozilla.org/privatebrowsing;1"].
48 let profilePath =
Cc[
"@mozilla.org/file/directory_service;1"].
50 get(
"ProfD",
Ci.nsIFile);
53 let ss =
Cc[
"@mozilla.org/browser/sessionstore;1"].
56 let sessionStoreJS = profilePath.clone();
57 sessionStoreJS.append(
"sessionstore.js");
58 if (sessionStoreJS.exists())
59 sessionStoreJS.remove(
false);
60 ok(sessionStoreJS.exists() ==
false,
"sessionstore.js was removed");
63 gPrefService.setIntPref(
"browser.sessionstore.interval", 0);
65 sessionStoreJS = profilePath.clone();
66 sessionStoreJS.append(
"sessionstore.js");
70 let blankState =
JSON.stringify({
72 tabs: [{ entries: [{
url:
"about:blank" }] }],
77 ss.setBrowserState(blankState);
79 let closedWindowCount = ss.getClosedWindowCount();
81 let testURL_A =
"about:config";
82 let testURL_B =
"about:mozilla";
84 let uniqueKey_A =
"bug 394759 Non-PB";
85 let uniqueValue_A =
"unik" + Date.now();
86 let uniqueKey_B =
"bug 394759 PB";
87 let uniqueValue_B =
"uniq" + Date.now();
91 let newWin = openDialog(location,
"_blank",
"chrome,all,dialog=no", testURL_A);
92 newWin.addEventListener(
"load",
function(aEvent) {
93 newWin.gBrowser.addEventListener(
"load",
function(aEvent) {
94 newWin.gBrowser.removeEventListener(
"load",
arguments.callee,
true);
96 executeSoon(
function() {
97 newWin.gBrowser.addTab();
100 ss.setWindowValue(newWin, uniqueKey_A, uniqueValue_A);
105 is(ss.getClosedWindowCount(), closedWindowCount + 1,
106 "The closed window was added to the list");
109 let
data =
JSON.parse(ss.getClosedWindowData())[0];
110 ok(data.toSource().indexOf(uniqueValue_A) > -1,
111 "The closed window data was stored correctly");
114 pb.privateBrowsingEnabled =
true;
115 ok(pb.privateBrowsingEnabled,
"private browsing enabled");
118 is(ss.getClosedWindowCount(), 0,
119 "Recently Closed Windows are removed when entering Private Browsing");
120 is(ss.getClosedWindowData(),
"[]",
121 "Recently Closed Windows data is cleared when entering Private Browsing");
124 let pbWin = openDialog(location,
"_blank",
"chrome,all,dialog=no", testURL_B);
125 pbWin.addEventListener(
"load",
function(aEvent) {
126 pbWin.gBrowser.addEventListener(
"load",
function(aEvent) {
127 pbWin.gBrowser.removeEventListener(
"load",
arguments.callee,
true);
129 executeSoon(
function() {
131 pbWin.gBrowser.addTab();
134 ss.setWindowValue(pbWin, uniqueKey_B, uniqueValue_B);
139 let data =
JSON.parse(ss.getClosedWindowData())[0];
140 ok(data.toSource().indexOf(uniqueValue_B) > -1,
141 "The closed window data was stored correctly in PB mode");
144 pb.privateBrowsingEnabled =
false;
145 ok(!pb.privateBrowsingEnabled,
"private browsing disabled");
148 is(ss.getClosedWindowCount(), closedWindowCount + 1,
149 "The correct number of recently closed windows were restored " +
150 "when exiting PB mode");
152 let data =
JSON.parse(ss.getClosedWindowData())[0];
153 ok(data.toSource().indexOf(uniqueValue_A) > -1,
154 "The data associated with the recently closed window was " +
155 "restored when exiting PB mode");
158 if (
gPrefService.prefHasUserValue(
"browser.sessionstore.interval"))
159 gPrefService.clearUserPref(
"browser.sessionstore.interval");
getService(Ci.sbIFaceplateManager)
return!aWindow arguments!aWindow arguments[0]