39 let
ww =
Cc[
"@mozilla.org/embedcomp/window-watcher;1"].
43 if (aTopic ==
"domwindowopened") {
44 ww.unregisterNotification(
this);
46 let
win = aSubject.QueryInterface(
Ci.nsIDOMEventTarget);
47 win.addEventListener(
"load",
function() {
48 win.removeEventListener(
"load",
arguments.callee,
false);
49 testFunc(
dialog.document.defaultView);
51 ww.registerNotification(observer);
54 }
else if (aTopic ==
"domwindowclosed") {
55 ww.unregisterNotification(
this);
60 ww.registerNotification(observer);
62 let
dialog = openDialog(
"chrome://browser/content/preferences/preferences.xul",
"Preferences",
63 "chrome,titlebar,toolbar,centerscreen,dialog=no",
"panePrivacy");
67 let
event =
doc.createEvent(
"Events");
68 event.initEvent(
"command",
true,
true);
73 let texts = [
"none",
"bookmarkhistory",
"history",
"bookmark"];
75 let locbarlist =
win.document.getElementById(
"locationBarSuggestion");
76 ok(locbarlist,
"location bar suggestion menulist should exist");
78 for (let level = -1; level <= 2; ++level) {
79 locbarlist.value = level;
81 is(gURLBar.emptyText, gURLBar.getAttribute(texts[level + 1] +
"emptytext"),
82 "location bar empty text for for level " + level +
" is correctly set");
88 "remember":
"historyRememberPane",
89 "dontremember":
"historyDontRememberPane",
90 "custom":
"historyCustomPane"
93 let historymode =
win.document.getElementById(
"historyMode");
94 ok(historymode,
"history mode menulist should exist");
95 let historypane =
win.document.getElementById(
"historyPane");
96 ok(historypane,
"history mode pane should exist");
98 for (let mode in modes) {
99 historymode.value = mode;
101 is(historypane.selectedPanel,
win.document.getElementById(modes[mode]),
102 "The correct pane should be selected for the " + mode +
" mode");
107 let historymode =
win.document.getElementById(
"historyMode");
108 ok(historymode,
"history mode menulist should exist");
109 let pbautostart =
win.document.getElementById(
"privateBrowsingAutoStart");
110 ok(pbautostart,
"the private browsing auto-start checkbox should exist");
112 win.document.getElementById(
"rememberHistoryDays"),
113 win.document.getElementById(
"historyDays"),
114 win.document.getElementById(
"rememberAfter"),
115 win.document.getElementById(
"rememberDownloads"),
116 win.document.getElementById(
"rememberForms"),
117 win.document.getElementById(
"keepUntil"),
118 win.document.getElementById(
"keepCookiesUntil"),
119 win.document.getElementById(
"alwaysClear"),
121 controls.forEach(
function(control) {
122 ok(control,
"the dependent controls should exist");
125 win.document.getElementById(
"acceptCookies"),
126 win.document.getElementById(
"acceptThirdParty"),
128 independents.forEach(
function(control) {
129 ok(control,
"the independent controls should exist");
131 let cookieexceptions =
win.document.getElementById(
"cookieExceptions");
132 ok(cookieexceptions,
"the cookie exceptions button should exist");
133 let keepuntil =
win.document.getElementById(
"keepCookiesUntil");
134 ok(keepuntil,
"the keep cookies until menulist should exist");
135 let alwaysclear =
win.document.getElementById(
"alwaysClear");
136 ok(alwaysclear,
"the clear data on close checkbox should exist");
137 let rememberhistory =
win.document.getElementById(
"rememberHistoryDays");
138 ok(rememberhistory,
"the remember history checkbox should exist");
139 let rememberdownloads =
win.document.getElementById(
"rememberDownloads");
140 ok(rememberdownloads,
"the remember downloads checkbox should exist");
141 let rememberforms =
win.document.getElementById(
"rememberForms");
142 ok(rememberforms,
"the remember forms checkbox should exist");
143 let alwaysclearsettings =
win.document.getElementById(
"clearDataSettings");
144 ok(alwaysclearsettings,
"the clear data settings button should exist");
146 function expect_disabled(disabled) {
147 controls.forEach(
function(control) {
148 is(control.disabled, disabled,
149 control.getAttribute(
"id") +
" should " + (disabled ?
"" :
"not ") +
"be disabled");
151 is(keepuntil.value, disabled ? 2 : 0,
152 "the keep cookies until menulist value should be as expected");
154 ok(!alwaysclear.checked,
155 "the clear data on close checkbox value should be as expected");
156 ok(!rememberhistory.checked,
157 "the remember history checkbox value should be as expected");
158 ok(!rememberdownloads.checked,
159 "the remember downloads checkbox value should be as expected");
160 ok(!rememberforms.checked,
161 "the remember forms checkbox value should be as expected");
164 function check_independents(
expected) {
165 independents.forEach(
function(control) {
167 control.getAttribute(
"id") +
" should " + (
expected ?
"" :
"not ") +
"be disabled");
169 ok(!cookieexceptions.disabled,
170 "the cookie exceptions button should never be disabled");
171 ok(alwaysclearsettings.disabled,
172 "the clear data settings button should always be disabled");
176 historymode.value =
"remember";
178 expect_disabled(
false);
179 check_independents(
false);
182 historymode.value =
"custom";
184 expect_disabled(
false);
185 check_independents(
false);
188 historymode.value =
"dontremember";
190 expect_disabled(
false);
191 check_independents(
false);
194 historymode.value =
"custom";
196 expect_disabled(
true);
197 check_independents(
false);
200 pbautostart.checked =
false;
202 expect_disabled(
false);
203 check_independents(
false);
206 pbautostart.checked =
true;
208 expect_disabled(
true);
209 check_independents(
false);
213 let historymode =
win.document.getElementById(
"historyMode");
214 ok(historymode,
"history mode menulist should exist");
215 let pbautostart =
win.document.getElementById(
"privateBrowsingAutoStart");
216 ok(pbautostart,
"the private browsing auto-start checkbox should exist");
218 win.document.getElementById(
"acceptThirdParty"),
219 win.document.getElementById(
"keepUntil"),
220 win.document.getElementById(
"keepCookiesUntil"),
222 controls.forEach(
function(control) {
223 ok(control,
"the dependent cookie controls should exist");
225 let acceptcookies =
win.document.getElementById(
"acceptCookies");
226 ok(acceptcookies,
"the accept cookies checkbox should exist");
228 function expect_disabled(disabled) {
229 controls.forEach(
function(control) {
230 is(control.disabled, disabled,
231 control.getAttribute(
"id") +
" should " + (disabled ?
"" :
"not ") +
"be disabled");
235 historymode.value =
"custom";
237 pbautostart.checked =
false;
239 expect_disabled(
false);
241 acceptcookies.checked =
false;
243 expect_disabled(
true);
246 pbautostart.checked =
true;
248 expect_disabled(
true);
250 pbautostart.checked =
false;
252 expect_disabled(
true);
254 acceptcookies.checked =
true;
256 expect_disabled(
false);
258 let accessthirdparty = controls.shift();
259 pbautostart.checked =
true;
261 expect_disabled(
true);
262 ok(!accessthirdparty.disabled,
"access third party button should be enabled");
264 acceptcookies.checked =
false;
266 expect_disabled(
true);
267 ok(accessthirdparty.disabled,
"access third party button should be disabled");
269 pbautostart.checked =
false;
271 expect_disabled(
true);
272 ok(accessthirdparty.disabled,
"access third party button should be disabled");
274 acceptcookies.checked =
true;
276 expect_disabled(
false);
277 ok(!accessthirdparty.disabled,
"access third party button should be enabled");
281 let historymode =
win.document.getElementById(
"historyMode");
282 ok(historymode,
"history mode menulist should exist");
283 let pbautostart =
win.document.getElementById(
"privateBrowsingAutoStart");
284 ok(pbautostart,
"the private browsing auto-start checkbox should exist");
285 let alwaysclear =
win.document.getElementById(
"alwaysClear");
286 ok(alwaysclear,
"the clear data on close checkbox should exist");
287 let alwaysclearsettings =
win.document.getElementById(
"clearDataSettings");
288 ok(alwaysclearsettings,
"the clear data settings button should exist");
290 function expect_disabled(disabled) {
291 is(alwaysclearsettings.disabled, disabled,
292 "the clear data settings should " + (disabled ?
"" :
"not ") +
"be disabled");
295 historymode.value =
"custom";
297 pbautostart.checked =
false;
299 alwaysclear.checked =
false;
301 expect_disabled(
true);
303 alwaysclear.checked =
true;
305 expect_disabled(
false);
307 pbautostart.checked =
true;
309 expect_disabled(
true);
311 pbautostart.checked =
false;
313 expect_disabled(
false);
315 alwaysclear.checked =
false;
317 expect_disabled(
true);
321 let historymode =
win.document.getElementById(
"historyMode");
322 ok(historymode,
"history mode menulist should exist");
324 win.document.getElementById(
"rememberHistoryDays"),
325 win.document.getElementById(
"rememberDownloads"),
326 win.document.getElementById(
"rememberForms"),
327 win.document.getElementById(
"acceptCookies"),
328 win.document.getElementById(
"acceptThirdParty"),
330 controls.forEach(
function(control) {
331 ok(control,
"the micro-management controls should exist");
334 function expect_checked(checked) {
335 controls.forEach(
function(control) {
336 is(control.checked, checked,
337 control.getAttribute(
"id") +
" should " + (checked ?
"not " :
"") +
"be checked");
342 historymode.value =
"remember";
344 expect_checked(
true);
347 historymode.value =
"custom";
349 controls.forEach(
function(control) {
350 control.checked =
false;
353 expect_checked(
false);
354 historymode.value =
"remember";
356 expect_checked(
true);
360 return function(
win) {
361 let historymode =
win.document.getElementById(
"historyMode");
362 ok(historymode,
"history mode menulist should exist");
364 if (expect !== undefined) {
365 is(historymode.value, expect,
366 "history mode is expected to remain " + expect);
369 historymode.value = mode;
375 return function(
win) {
376 let historymode =
win.document.getElementById(
"historyMode");
377 ok(historymode,
"history mode menulist should exist");
379 if (expect !== undefined) {
380 is(historymode.value, expect,
381 "history mode is expected to remain " + expect);
384 historymode.value =
"custom";
387 controlToChange =
win.document.getElementById(controlToChange);
388 ok(controlToChange,
"the control to change should exist");
389 switch (controlToChange.localName) {
391 controlToChange.checked = !controlToChange.checked;
394 controlToChange.value = parseInt(controlToChange.value) + valueIncrement;
397 controlToChange.value = valueIncrement;
405 return function(
win) {
406 let locbarsuggest =
win.document.getElementById(
"locationBarSuggestion");
407 ok(locbarsuggest,
"location bar suggestion menulist should exist");
409 if (expect !== undefined) {
410 is(locbarsuggest.value, expect,
411 "location bar suggestion is expected to remain " + expect);
414 locbarsuggest.value = mode;
420 let historymode =
win.document.getElementById(
"historyMode");
421 ok(historymode,
"history mode menulist should exist");
422 let pbautostart =
win.document.getElementById(
"privateBrowsingAutoStart");
423 ok(pbautostart,
"the private browsing auto-start checkbox should exist");
425 let pbService =
Cc[
"@mozilla.org/privatebrowsing;1"].
429 historymode.value =
"remember";
433 historymode.value =
"dontremember";
435 ok(pbService.privateBrowsingEnabled,
"private browsing should be activated");
438 historymode.value =
"remember";
440 ok(!pbService.privateBrowsingEnabled,
"private browsing should be deactivated");
443 historymode.value =
"custom";
445 ok(!pbService.privateBrowsingEnabled,
"private browsing should remain deactivated");
448 pbautostart.checked =
true;
450 ok(pbService.privateBrowsingEnabled,
"private browsing should be activated");
453 pbautostart.checked =
false;
455 ok(!pbService.privateBrowsingEnabled,
"private browsing should be deactivated");
459 let historymode =
win.document.getElementById(
"historyMode");
460 ok(historymode,
"history mode menulist should exist");
461 let pbautostart =
win.document.getElementById(
"privateBrowsingAutoStart");
462 ok(pbautostart,
"the private browsing auto-start checkbox should exist");
464 let pbmenuitem = document.getElementById(
"privateBrowsingItem");
465 ok(pbmenuitem,
"the private browsing menu item should exist");
466 let pbcommand = document.getElementById(
"Tools:PrivateBrowsing");
467 ok(pbcommand,
"the private browsing command should exist");
470 historymode.value =
"remember";
472 ok(!pbmenuitem.hasAttribute(
"disabled"),
473 "private browsing menu item should not be initially disabled");
474 ok(!pbcommand.hasAttribute(
"disabled"),
475 "private browsing command should not be initially disabled");
478 historymode.value =
"dontremember";
480 ok(pbmenuitem.hasAttribute(
"disabled"),
481 "private browsing menu item should be disabled");
482 ok(pbcommand.hasAttribute(
"disabled"),
483 "private browsing command should be disabled");
486 historymode.value =
"remember";
488 ok(!pbmenuitem.hasAttribute(
"disabled"),
489 "private browsing menu item should be enabled");
490 ok(!pbcommand.hasAttribute(
"disabled"),
491 "private browsing command should be enabled");
494 historymode.value =
"custom";
496 ok(!pbmenuitem.hasAttribute(
"disabled"),
497 "private browsing menu item should remain enabled");
498 ok(!pbcommand.hasAttribute(
"disabled"),
499 "private browsing command should remain enabled");
502 pbautostart.checked =
true;
504 ok(pbmenuitem.hasAttribute(
"disabled"),
505 "private browsing menu item should be disabled");
506 ok(pbcommand.hasAttribute(
"disabled"),
507 "private browsing command should be disabled");
510 pbautostart.checked =
false;
512 ok(!pbmenuitem.hasAttribute(
"disabled"),
513 "private browsing menu item should be enabled");
514 ok(!pbcommand.hasAttribute(
"disabled"),
515 "private browsing command should be enabled");
519 let pbService =
Cc[
"@mozilla.org/privatebrowsing;1"].
521 win.document.getElementById(
"browser.privatebrowsing.keep_current_session")
523 pbService.privateBrowsingEnabled =
true;
527 let
prefs =
win.document.getElementsByTagName(
"preference");
528 for (let
i = 0;
i < prefs.length; ++
i)
529 if (prefs[
i].hasUserValue)
535 let psvc =
Cc[
"@mozilla.org/preferences-service;1"].
537 let instantApplyOrig = psvc.getBoolPref(
"browser.preferences.instantApply");
538 psvc.setBoolPref(
"browser.preferences.instantApply",
true);
545 runNext:
function() {
546 if (this.counter == this.
tests.length) {
548 psvc.setBoolPref(
"browser.preferences.instantApply", instantApplyOrig);
function test_dependent_cookie_elements(win)
function controlChanged(doc, element)
function test_privatebrowsing_ui(win)
function doc() browser.contentDocument
function test_locbar_emptyText(win)
function test_dependent_clearonclose_elements(win)
function test_locbar_suggestion_retention(mode, expect)
function test_pane_visibility(win)
function test_custom_retention(controlToChange, expect, valueIncrement)
getService(Ci.sbIFaceplateManager)
function enter_private_browsing(win)
function runTestOnPrivacyPrefPane(testFunc)
function test_dependent_elements(win)
aWindow setTimeout(function(){_this.restoreHistory(aWindow, aTabs, aTabData, aIdMap);}, 0)
function test_dependent_prefs(win)
function test_historymode_retention(mode, expect)
function test_privatebrowsing_toggle(win)
return!aWindow arguments!aWindow arguments[0]
function reset_preferences(win)
function run_test_subset(subset)
_getSelectedPageStyle s i
_updateTextAndScrollDataForFrame aData
sbDeviceFirmwareAutoCheckForUpdate prototype observe