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