toolkit/mozapps/extensions/test/browser/browser_inlinesettings_custom.js

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

     1 /* Any copyright is dedicated to the Public Domain.
     2  * http://creativecommons.org/publicdomain/zero/1.0/
     3  */
     5 // Tests various aspects of the details view
     7 var gManagerWindow;
     8 var gCategoryUtilities;
    10 function installAddon(aCallback) {
    11   AddonManager.getInstallForURL(TESTROOT + "addons/browser_inlinesettings1_custom.xpi",
    12                                 function(aInstall) {
    13     aInstall.addListener({
    14       onInstallEnded: function() {
    15         executeSoon(aCallback);
    16       }
    17     });
    18     aInstall.install();
    19   }, "application/x-xpinstall");
    20 }
    22 function test() {
    23   waitForExplicitFinish();
    25   installAddon(function () {
    26     open_manager("addons://list/extension", function(aWindow) {
    27       gManagerWindow = aWindow;
    28       gCategoryUtilities = new CategoryUtilities(gManagerWindow);
    30       run_next_test();
    31     });
    32   });
    33 }
    35 function end_test() {
    36   close_manager(gManagerWindow, function() {
    37     AddonManager.getAddonByID("inlinesettings1@tests.mozilla.org", function(aAddon) {
    38       aAddon.uninstall();
    39       finish();
    40     });
    41   });
    42 }
    44 // Addon with options.xul, with custom <setting> binding
    45 add_test(function() {
    46   var addon = get_addon_element(gManagerWindow, "inlinesettings1@tests.mozilla.org");
    47   is(addon.mAddon.optionsType, AddonManager.OPTIONS_TYPE_INLINE, "Options should be inline type");
    48   addon.parentNode.ensureElementIsVisible(addon);
    50   var button = gManagerWindow.document.getAnonymousElementByAttribute(addon, "anonid", "preferences-btn");
    51   is_element_visible(button, "Preferences button should be visible");
    53   run_next_test();
    54 });
    56 // Addon with options.xul, also a test for the setting.xml bindings
    57 add_test(function() {
    58   var addon = get_addon_element(gManagerWindow, "inlinesettings1@tests.mozilla.org");
    59   addon.parentNode.ensureElementIsVisible(addon);
    61   var button = gManagerWindow.document.getAnonymousElementByAttribute(addon, "anonid", "preferences-btn");
    62   EventUtils.synthesizeMouseAtCenter(button, { clickCount: 1 }, gManagerWindow);
    64   wait_for_view_load(gManagerWindow, function() {
    65     is(gManagerWindow.gViewController.currentViewId,
    66        "addons://detail/inlinesettings1%40tests.mozilla.org/preferences",
    67        "Current view should scroll to preferences");
    69     var grid = gManagerWindow.document.getElementById("detail-grid");
    70     var settings = grid.querySelectorAll("rows > setting");
    71     is(settings.length, 1, "Grid should have settings children");
    73     ok(settings[0].hasAttribute("first-row"), "First visible row should have first-row attribute");
    75     var style = window.getComputedStyle(settings[0], null);
    76     is(style.getPropertyValue("background-color"), "rgb(0, 0, 255)", "Background color should be set");
    77     is(style.getPropertyValue("display"), "-moz-grid-line", "Display should be set");
    78     is(style.getPropertyValue("-moz-binding"), 'url("chrome://inlinesettings/content/binding.xml#custom")', "Binding should be set");
    80     var label = gManagerWindow.document.getAnonymousElementByAttribute(settings[0], "anonid", "label");
    81     is(label.textContent, "Custom", "Localized string should be shown");
    83     var input = gManagerWindow.document.getAnonymousElementByAttribute(settings[0], "anonid", "input");
    84     isnot(input, null, "Binding should be applied");
    85     is(input.value, "Woah!", "Binding should be applied");
    87     button = gManagerWindow.document.getElementById("detail-prefs-btn");
    88     is_element_hidden(button, "Preferences button should not be visible");
    90     gCategoryUtilities.openType("extension", run_next_test);
    91   });
    92 });

mercurial