41 let ss =
Cc[
"@mozilla.org/browser/sessionstore;1"].getService(
Ci.nsISessionStore);
44 const REMEMBER = Date.now(), FORGET = Math.random();
45 let test_state = {
windows: [{
"tabs": [{
"entries": [] }], _closedTabs: [
46 { state: { entries: [{
url:
"http://www.example.net/" }] }, title: FORGET },
47 { state: { entries: [{
url:
"http://www.example.org/" }] }, title: REMEMBER },
48 { state: { entries: [{
url:
"http://www.example.net/" },
49 {
url:
"http://www.example.org/" }] }, title: FORGET },
50 { state: { entries: [{
url:
"http://example.net/" }] }, title: FORGET },
51 { state: { entries: [{
url:
"http://sub.example.net/" }] }, title: FORGET },
52 { state: { entries: [{
url:
"http://www.example.net:8080/" }] }, title: FORGET },
53 { state: { entries: [{
url:
"about:license" }] }, title: REMEMBER },
54 { state: { entries: [{
url:
"http://www.example.org/frameset",
56 {
url:
"http://www.example.org/frame" },
57 {
url:
"http://www.example.org:8080/frame2" }
58 ] }] }, title: REMEMBER },
59 { state: { entries: [{
url:
"http://www.example.org/frameset",
61 {
url:
"http://www.example.org/frame" },
62 {
url:
"http://www.example.net/frame" }
63 ] }] }, title: FORGET },
64 { state: { entries: [{
url:
"http://www.example.org/form",
65 formdata: {
"#url":
"http://www.example.net/" }
66 }] }, title: REMEMBER },
67 { state: { entries: [{
url:
"http://www.example.org/form" }],
68 extData: {
"setTabValue":
"http://example.net:80" } }, title: REMEMBER }
70 let remember_count = 5;
72 function countByTitle(aClosedTabList, aTitle)
73 aClosedTabList.filter(
function(
aData)
aData.title == aTitle).length;
76 let newWin = openDialog(location,
"_blank",
"chrome,all,dialog=no");
77 newWin.addEventListener(
"load",
function(aEvent) {
78 gPrefService.setIntPref(
"browser.sessionstore.max_tabs_undo",
79 test_state.windows[0]._closedTabs.length);
80 ss.setWindowState(newWin,
JSON.stringify(test_state),
true);
82 let closedTabs = eval(
"(" + ss.getClosedTabData(newWin) +
")");
83 is(closedTabs.length, test_state.windows[0]._closedTabs.length,
84 "Closed tab list has the expected length");
85 is(countByTitle(closedTabs, FORGET),
86 test_state.windows[0]._closedTabs.length - remember_count,
87 "The correct amout of tabs are to be forgotten");
88 is(countByTitle(closedTabs, REMEMBER), remember_count,
89 "Everything is set up.");
91 let
pb =
Cc[
"@mozilla.org/privatebrowsing;1"].
93 pb.removeDataFromDomain(
"example.net");
95 closedTabs = eval(
"(" + ss.getClosedTabData(newWin) +
")");
96 is(closedTabs.length, remember_count,
97 "The correct amout of tabs was removed");
98 is(countByTitle(closedTabs, FORGET), 0,
99 "All tabs to be forgotten were indeed removed");
100 is(countByTitle(closedTabs, REMEMBER), remember_count,
101 "... and tabs to be remembered weren't.");
105 if (
gPrefService.prefHasUserValue(
"browser.sessionstore.max_tabs_undo"))
106 gPrefService.clearUserPref(
"browser.sessionstore.max_tabs_undo");
getService(Ci.sbIFaceplateManager)
_updateTextAndScrollDataForFrame aData