|
1 /* |
|
2 * This Source Code Form is subject to the terms of the Mozilla Public License, |
|
3 * v. 2.0. If a copy of the MPL was not distributed with this file, You can |
|
4 * obtain one at http://mozilla.org/MPL/2.0/. |
|
5 */ |
|
6 |
|
7 |
|
8 function test() { |
|
9 waitForExplicitFinish(); |
|
10 registerCleanupFunction(function() { |
|
11 // Reset pref to its default |
|
12 Services.prefs.clearUserPref("browser.preferences.inContent"); |
|
13 }); |
|
14 |
|
15 // Verify that about:preferences tab is displayed when |
|
16 // browser.preferences.inContent is set to true |
|
17 Services.prefs.setBoolPref("browser.preferences.inContent", true); |
|
18 |
|
19 // Open a new tab. |
|
20 whenNewTabLoaded(window, testPreferences); |
|
21 } |
|
22 |
|
23 function testPreferences() { |
|
24 whenTabLoaded(gBrowser.selectedTab, function () { |
|
25 is(Services.prefs.getBoolPref("browser.preferences.inContent"), true, "In-content prefs are enabled"); |
|
26 is(content.location.href, "about:preferences", "Checking if the preferences tab was opened"); |
|
27 |
|
28 gBrowser.removeCurrentTab(); |
|
29 Services.prefs.setBoolPref("browser.preferences.inContent", false); |
|
30 openPreferences(); |
|
31 }); |
|
32 |
|
33 let observer = { |
|
34 observe: function(aSubject, aTopic, aData) { |
|
35 if (aTopic == "domwindowopened") { |
|
36 windowWatcher.unregisterNotification(observer); |
|
37 |
|
38 let win = aSubject.QueryInterface(Components.interfaces.nsIDOMWindow); |
|
39 win.addEventListener("load", function() { |
|
40 win.removeEventListener("load", arguments.callee, false); |
|
41 is(Services.prefs.getBoolPref("browser.preferences.inContent"), false, "In-content prefs are disabled"); |
|
42 is(win.location.href, "chrome://browser/content/preferences/preferences.xul", "Checking if the preferences window was opened"); |
|
43 win.close(); |
|
44 finish(); |
|
45 }, false); |
|
46 } |
|
47 } |
|
48 } |
|
49 |
|
50 var windowWatcher = Components.classes["@mozilla.org/embedcomp/window-watcher;1"] |
|
51 .getService(Components.interfaces.nsIWindowWatcher); |
|
52 windowWatcher.registerNotification(observer); |
|
53 |
|
54 openPreferences(); |
|
55 } |