1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/browser/base/content/test/general/browser_bug735471.js Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,55 @@ 1.4 +/* 1.5 + * This Source Code Form is subject to the terms of the Mozilla Public License, 1.6 + * v. 2.0. If a copy of the MPL was not distributed with this file, You can 1.7 + * obtain one at http://mozilla.org/MPL/2.0/. 1.8 + */ 1.9 + 1.10 + 1.11 +function test() { 1.12 + waitForExplicitFinish(); 1.13 + registerCleanupFunction(function() { 1.14 + // Reset pref to its default 1.15 + Services.prefs.clearUserPref("browser.preferences.inContent"); 1.16 + }); 1.17 + 1.18 + // Verify that about:preferences tab is displayed when 1.19 + // browser.preferences.inContent is set to true 1.20 + Services.prefs.setBoolPref("browser.preferences.inContent", true); 1.21 + 1.22 + // Open a new tab. 1.23 + whenNewTabLoaded(window, testPreferences); 1.24 +} 1.25 + 1.26 +function testPreferences() { 1.27 + whenTabLoaded(gBrowser.selectedTab, function () { 1.28 + is(Services.prefs.getBoolPref("browser.preferences.inContent"), true, "In-content prefs are enabled"); 1.29 + is(content.location.href, "about:preferences", "Checking if the preferences tab was opened"); 1.30 + 1.31 + gBrowser.removeCurrentTab(); 1.32 + Services.prefs.setBoolPref("browser.preferences.inContent", false); 1.33 + openPreferences(); 1.34 + }); 1.35 + 1.36 + let observer = { 1.37 + observe: function(aSubject, aTopic, aData) { 1.38 + if (aTopic == "domwindowopened") { 1.39 + windowWatcher.unregisterNotification(observer); 1.40 + 1.41 + let win = aSubject.QueryInterface(Components.interfaces.nsIDOMWindow); 1.42 + win.addEventListener("load", function() { 1.43 + win.removeEventListener("load", arguments.callee, false); 1.44 + is(Services.prefs.getBoolPref("browser.preferences.inContent"), false, "In-content prefs are disabled"); 1.45 + is(win.location.href, "chrome://browser/content/preferences/preferences.xul", "Checking if the preferences window was opened"); 1.46 + win.close(); 1.47 + finish(); 1.48 + }, false); 1.49 + } 1.50 + } 1.51 + } 1.52 + 1.53 + var windowWatcher = Components.classes["@mozilla.org/embedcomp/window-watcher;1"] 1.54 + .getService(Components.interfaces.nsIWindowWatcher); 1.55 + windowWatcher.registerNotification(observer); 1.56 + 1.57 + openPreferences(); 1.58 +}