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: michael@0: function installAddon(aCallback) { michael@0: AddonManager.getInstallForURL(TESTROOT + "addons/browser_inlinesettings1_custom.xpi", michael@0: function(aInstall) { michael@0: aInstall.addListener({ michael@0: onInstallEnded: function() { michael@0: executeSoon(aCallback); michael@0: } michael@0: }); michael@0: aInstall.install(); michael@0: }, "application/x-xpinstall"); michael@0: } michael@0: michael@0: function test() { michael@0: waitForExplicitFinish(); michael@0: michael@0: installAddon(function () { 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: michael@0: function end_test() { michael@0: close_manager(gManagerWindow, function() { michael@0: AddonManager.getAddonByID("inlinesettings1@tests.mozilla.org", function(aAddon) { michael@0: aAddon.uninstall(); michael@0: finish(); michael@0: }); michael@0: }); michael@0: } michael@0: michael@0: // Addon with options.xul, with custom binding michael@0: add_test(function() { michael@0: var addon = get_addon_element(gManagerWindow, "inlinesettings1@tests.mozilla.org"); michael@0: is(addon.mAddon.optionsType, AddonManager.OPTIONS_TYPE_INLINE, "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: run_next_test(); michael@0: }); michael@0: michael@0: // Addon with options.xul, also a test for the setting.xml bindings michael@0: add_test(function() { michael@0: var addon = get_addon_element(gManagerWindow, "inlinesettings1@tests.mozilla.org"); michael@0: addon.parentNode.ensureElementIsVisible(addon); michael@0: michael@0: var button = gManagerWindow.document.getAnonymousElementByAttribute(addon, "anonid", "preferences-btn"); michael@0: EventUtils.synthesizeMouseAtCenter(button, { clickCount: 1 }, gManagerWindow); michael@0: michael@0: wait_for_view_load(gManagerWindow, function() { michael@0: is(gManagerWindow.gViewController.currentViewId, michael@0: "addons://detail/inlinesettings1%40tests.mozilla.org/preferences", michael@0: "Current view should scroll to preferences"); michael@0: michael@0: var grid = gManagerWindow.document.getElementById("detail-grid"); michael@0: var settings = grid.querySelectorAll("rows > setting"); michael@0: is(settings.length, 1, "Grid should have settings children"); michael@0: michael@0: ok(settings[0].hasAttribute("first-row"), "First visible row should have first-row attribute"); michael@0: michael@0: var style = window.getComputedStyle(settings[0], null); michael@0: is(style.getPropertyValue("background-color"), "rgb(0, 0, 255)", "Background color should be set"); michael@0: is(style.getPropertyValue("display"), "-moz-grid-line", "Display should be set"); michael@0: is(style.getPropertyValue("-moz-binding"), 'url("chrome://inlinesettings/content/binding.xml#custom")', "Binding should be set"); michael@0: michael@0: var label = gManagerWindow.document.getAnonymousElementByAttribute(settings[0], "anonid", "label"); michael@0: is(label.textContent, "Custom", "Localized string should be shown"); michael@0: michael@0: var input = gManagerWindow.document.getAnonymousElementByAttribute(settings[0], "anonid", "input"); michael@0: isnot(input, null, "Binding should be applied"); michael@0: is(input.value, "Woah!", "Binding should be applied"); michael@0: michael@0: button = gManagerWindow.document.getElementById("detail-prefs-btn"); michael@0: is_element_hidden(button, "Preferences button should not be visible"); michael@0: michael@0: gCategoryUtilities.openType("extension", run_next_test); michael@0: }); michael@0: });