michael@0: /* michael@0: * This Source Code Form is subject to the terms of the Mozilla Public License, michael@0: * v. 2.0. If a copy of the MPL was not distributed with this file, You can michael@0: * obtain one at http://mozilla.org/MPL/2.0/. michael@0: */ michael@0: michael@0: michael@0: function test() { michael@0: waitForExplicitFinish(); michael@0: registerCleanupFunction(function() { michael@0: // Reset pref to its default michael@0: Services.prefs.clearUserPref("browser.preferences.inContent"); michael@0: }); michael@0: michael@0: // Verify that about:preferences tab is displayed when michael@0: // browser.preferences.inContent is set to true michael@0: Services.prefs.setBoolPref("browser.preferences.inContent", true); michael@0: michael@0: // Open a new tab. michael@0: whenNewTabLoaded(window, testPreferences); michael@0: } michael@0: michael@0: function testPreferences() { michael@0: whenTabLoaded(gBrowser.selectedTab, function () { michael@0: is(Services.prefs.getBoolPref("browser.preferences.inContent"), true, "In-content prefs are enabled"); michael@0: is(content.location.href, "about:preferences", "Checking if the preferences tab was opened"); michael@0: michael@0: gBrowser.removeCurrentTab(); michael@0: Services.prefs.setBoolPref("browser.preferences.inContent", false); michael@0: openPreferences(); michael@0: }); michael@0: michael@0: let observer = { michael@0: observe: function(aSubject, aTopic, aData) { michael@0: if (aTopic == "domwindowopened") { michael@0: windowWatcher.unregisterNotification(observer); michael@0: michael@0: let win = aSubject.QueryInterface(Components.interfaces.nsIDOMWindow); michael@0: win.addEventListener("load", function() { michael@0: win.removeEventListener("load", arguments.callee, false); michael@0: is(Services.prefs.getBoolPref("browser.preferences.inContent"), false, "In-content prefs are disabled"); michael@0: is(win.location.href, "chrome://browser/content/preferences/preferences.xul", "Checking if the preferences window was opened"); michael@0: win.close(); michael@0: finish(); michael@0: }, false); michael@0: } michael@0: } michael@0: } michael@0: michael@0: var windowWatcher = Components.classes["@mozilla.org/embedcomp/window-watcher;1"] michael@0: .getService(Components.interfaces.nsIWindowWatcher); michael@0: windowWatcher.registerNotification(observer); michael@0: michael@0: openPreferences(); michael@0: }