michael@0: /* Any copyright is dedicated to the Public Domain. michael@0: * http://creativecommons.org/publicdomain/zero/1.0/ michael@0: */ michael@0: michael@0: // Tests various aspects of the details view michael@0: michael@0: var gManagerWindow; michael@0: var gCategoryUtilities; michael@0: var gProvider; michael@0: michael@0: function test() { michael@0: waitForExplicitFinish(); michael@0: michael@0: gProvider = new MockProvider(); michael@0: michael@0: gProvider.createAddons([{ michael@0: id: "tabsettings@tests.mozilla.org", michael@0: name: "Tab Settings", michael@0: version: "1", michael@0: optionsURL: CHROMEROOT + "addon_prefs.xul", michael@0: optionsType: AddonManager.OPTIONS_TYPE_TAB michael@0: }]); michael@0: michael@0: open_manager("addons://list/extension", function(aWindow) { michael@0: gManagerWindow = aWindow; michael@0: gCategoryUtilities = new CategoryUtilities(gManagerWindow); michael@0: michael@0: run_next_test(); michael@0: }); michael@0: } michael@0: michael@0: function end_test() { michael@0: close_manager(gManagerWindow, function() { michael@0: finish(); michael@0: }); michael@0: } michael@0: michael@0: add_test(function() { michael@0: var addon = get_addon_element(gManagerWindow, "tabsettings@tests.mozilla.org"); michael@0: is(addon.mAddon.optionsType, AddonManager.OPTIONS_TYPE_TAB, "Options should be inline type"); michael@0: addon.parentNode.ensureElementIsVisible(addon); michael@0: michael@0: var button = gManagerWindow.document.getAnonymousElementByAttribute(addon, "anonid", "preferences-btn"); michael@0: is_element_visible(button, "Preferences button should be visible"); michael@0: michael@0: if (gUseInContentUI) { michael@0: EventUtils.synthesizeMouseAtCenter(button, { clickCount: 1 }, gManagerWindow); michael@0: michael@0: var browser = gBrowser.selectedTab.linkedBrowser; michael@0: browser.addEventListener("DOMContentLoaded", function() { michael@0: browser.removeEventListener("DOMContentLoaded", arguments.callee, false); michael@0: is(browser.currentURI.spec, addon.mAddon.optionsURL, "New tab should have loaded the options URL"); michael@0: browser.contentWindow.close(); michael@0: run_next_test(); michael@0: }, false); michael@0: return; michael@0: } michael@0: michael@0: let instantApply = Services.prefs.getBoolPref("browser.preferences.instantApply"); michael@0: michael@0: function observer(aSubject, aTopic, aData) { michael@0: switch (aTopic) { michael@0: case "domwindowclosed": michael@0: // Give the preference window a chance to finish closing before michael@0: // closing the add-ons manager. michael@0: waitForFocus(function () { michael@0: Services.ww.unregisterNotification(observer); michael@0: run_next_test(); michael@0: }); michael@0: break; michael@0: case "domwindowopened": michael@0: let win = aSubject.QueryInterface(Ci.nsIDOMEventTarget); michael@0: waitForFocus(function () { michael@0: // If the openDialog privileges are wrong a new browser window michael@0: // will open, let the test proceed (and fail) rather than timeout. michael@0: if (win.location != addon.mAddon.optionsURL && michael@0: win.location != "chrome://browser/content/browser.xul") michael@0: return; michael@0: michael@0: is(win.location, addon.mAddon.optionsURL, michael@0: "The correct addon pref window should have opened"); michael@0: michael@0: let chromeFlags = win.QueryInterface(Ci.nsIInterfaceRequestor). michael@0: getInterface(Ci.nsIWebNavigation). michael@0: QueryInterface(Ci.nsIDocShellTreeItem).treeOwner. michael@0: QueryInterface(Ci.nsIInterfaceRequestor). michael@0: getInterface(Ci.nsIXULWindow).chromeFlags; michael@0: ok(chromeFlags & Ci.nsIWebBrowserChrome.CHROME_OPENAS_CHROME && michael@0: (instantApply || chromeFlags & Ci.nsIWebBrowserChrome.CHROME_OPENAS_DIALOG), michael@0: "Window was open as a chrome dialog."); michael@0: michael@0: win.close(); michael@0: }, win); michael@0: break; michael@0: } michael@0: } michael@0: michael@0: Services.ww.registerNotification(observer); michael@0: EventUtils.synthesizeMouseAtCenter(button, { clickCount: 1 }, gManagerWindow); michael@0: });