1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/toolkit/mozapps/extensions/test/browser/browser_inlinesettings_custom.js Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,92 @@ 1.4 +/* Any copyright is dedicated to the Public Domain. 1.5 + * http://creativecommons.org/publicdomain/zero/1.0/ 1.6 + */ 1.7 + 1.8 +// Tests various aspects of the details view 1.9 + 1.10 +var gManagerWindow; 1.11 +var gCategoryUtilities; 1.12 + 1.13 +function installAddon(aCallback) { 1.14 + AddonManager.getInstallForURL(TESTROOT + "addons/browser_inlinesettings1_custom.xpi", 1.15 + function(aInstall) { 1.16 + aInstall.addListener({ 1.17 + onInstallEnded: function() { 1.18 + executeSoon(aCallback); 1.19 + } 1.20 + }); 1.21 + aInstall.install(); 1.22 + }, "application/x-xpinstall"); 1.23 +} 1.24 + 1.25 +function test() { 1.26 + waitForExplicitFinish(); 1.27 + 1.28 + installAddon(function () { 1.29 + open_manager("addons://list/extension", function(aWindow) { 1.30 + gManagerWindow = aWindow; 1.31 + gCategoryUtilities = new CategoryUtilities(gManagerWindow); 1.32 + 1.33 + run_next_test(); 1.34 + }); 1.35 + }); 1.36 +} 1.37 + 1.38 +function end_test() { 1.39 + close_manager(gManagerWindow, function() { 1.40 + AddonManager.getAddonByID("inlinesettings1@tests.mozilla.org", function(aAddon) { 1.41 + aAddon.uninstall(); 1.42 + finish(); 1.43 + }); 1.44 + }); 1.45 +} 1.46 + 1.47 +// Addon with options.xul, with custom <setting> binding 1.48 +add_test(function() { 1.49 + var addon = get_addon_element(gManagerWindow, "inlinesettings1@tests.mozilla.org"); 1.50 + is(addon.mAddon.optionsType, AddonManager.OPTIONS_TYPE_INLINE, "Options should be inline type"); 1.51 + addon.parentNode.ensureElementIsVisible(addon); 1.52 + 1.53 + var button = gManagerWindow.document.getAnonymousElementByAttribute(addon, "anonid", "preferences-btn"); 1.54 + is_element_visible(button, "Preferences button should be visible"); 1.55 + 1.56 + run_next_test(); 1.57 +}); 1.58 + 1.59 +// Addon with options.xul, also a test for the setting.xml bindings 1.60 +add_test(function() { 1.61 + var addon = get_addon_element(gManagerWindow, "inlinesettings1@tests.mozilla.org"); 1.62 + addon.parentNode.ensureElementIsVisible(addon); 1.63 + 1.64 + var button = gManagerWindow.document.getAnonymousElementByAttribute(addon, "anonid", "preferences-btn"); 1.65 + EventUtils.synthesizeMouseAtCenter(button, { clickCount: 1 }, gManagerWindow); 1.66 + 1.67 + wait_for_view_load(gManagerWindow, function() { 1.68 + is(gManagerWindow.gViewController.currentViewId, 1.69 + "addons://detail/inlinesettings1%40tests.mozilla.org/preferences", 1.70 + "Current view should scroll to preferences"); 1.71 + 1.72 + var grid = gManagerWindow.document.getElementById("detail-grid"); 1.73 + var settings = grid.querySelectorAll("rows > setting"); 1.74 + is(settings.length, 1, "Grid should have settings children"); 1.75 + 1.76 + ok(settings[0].hasAttribute("first-row"), "First visible row should have first-row attribute"); 1.77 + 1.78 + var style = window.getComputedStyle(settings[0], null); 1.79 + is(style.getPropertyValue("background-color"), "rgb(0, 0, 255)", "Background color should be set"); 1.80 + is(style.getPropertyValue("display"), "-moz-grid-line", "Display should be set"); 1.81 + is(style.getPropertyValue("-moz-binding"), 'url("chrome://inlinesettings/content/binding.xml#custom")', "Binding should be set"); 1.82 + 1.83 + var label = gManagerWindow.document.getAnonymousElementByAttribute(settings[0], "anonid", "label"); 1.84 + is(label.textContent, "Custom", "Localized string should be shown"); 1.85 + 1.86 + var input = gManagerWindow.document.getAnonymousElementByAttribute(settings[0], "anonid", "input"); 1.87 + isnot(input, null, "Binding should be applied"); 1.88 + is(input.value, "Woah!", "Binding should be applied"); 1.89 + 1.90 + button = gManagerWindow.document.getElementById("detail-prefs-btn"); 1.91 + is_element_hidden(button, "Preferences button should not be visible"); 1.92 + 1.93 + gCategoryUtilities.openType("extension", run_next_test); 1.94 + }); 1.95 +});