43 let
pb =
Cc[
"@mozilla.org/privatebrowsing;1"].
45 let ds =
Cc[
"@mozilla.org/file/directory_service;1"].
47 let dir1 = ds.get(
"ProfD",
Ci.nsIFile);
48 let dir2 = ds.get(
"TmpD",
Ci.nsIFile);
49 let
file = dir2.clone();
50 file.append(
"pbtest.file");
51 file.createUnique(
Ci.nsIFile.NORMAL_FILE_TYPE, 0600);
53 const kPrefName =
"browser.open.lastDir";
55 function setupCleanSlate() {
56 gLastOpenDirectory.reset();
66 ok(!gLastOpenDirectory.path,
67 "Last open directory path should be initially empty");
68 gLastOpenDirectory.path = dir2;
69 is(gLastOpenDirectory.path.path, dir2.path,
70 "The path should be successfully set");
71 gLastOpenDirectory.path =
null;
72 is(gLastOpenDirectory.path.path, dir2.path,
73 "The path should be not change when assigning it to null");
74 gLastOpenDirectory.path = dir1;
75 is(gLastOpenDirectory.path.path, dir1.path,
76 "The path should be successfully outside of the private browsing mode");
79 pb.privateBrowsingEnabled =
true;
81 is(gLastOpenDirectory.path.path, dir1.path,
82 "The path should not change when entering the private browsing mode");
83 gLastOpenDirectory.path = dir2;
84 is(gLastOpenDirectory.path.path, dir2.path,
85 "The path should successfully change inside the private browsing mode");
88 pb.privateBrowsingEnabled =
false;
90 is(gLastOpenDirectory.path.path, dir1.path,
91 "The path should be reset to the same path as before entering the private browsing mode");
97 pb.privateBrowsingEnabled =
true;
98 ok(!gLastOpenDirectory.path,
99 "No original path should exist inside the private browsing mode");
100 gLastOpenDirectory.path = dir1;
101 is(gLastOpenDirectory.path.path, dir1.path,
102 "The path should be successfully set inside the private browsing mode");
103 pb.privateBrowsingEnabled =
false;
104 ok(!gLastOpenDirectory.path,
105 "The path set inside the private browsing mode should not leak when leaving that mode");
113 is(gLastOpenDirectory.path.path, dir1.path,
114 "The pref set from last session should take effect outside the private browsing mode");
122 pb.privateBrowsingEnabled =
true;
123 is(gLastOpenDirectory.path.path, dir1.path,
124 "The pref set from last session should take effect inside the private browsing mode");
125 pb.privateBrowsingEnabled =
false;
126 is(gLastOpenDirectory.path.path, dir1.path,
127 "The pref set from last session should remain in effect after leaving the private browsing mode");
133 gLastOpenDirectory.path =
file;
134 ok(!gLastOpenDirectory.path,
135 "Setting the path to a file shouldn't work when it's originally null");
136 gLastOpenDirectory.path = dir1;
137 gLastOpenDirectory.path =
file;
138 is(gLastOpenDirectory.path.path, dir1.path,
139 "Setting the path to a file shouldn't work when it's not originally null");
getService(Ci.sbIFaceplateManager)