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.

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

mercurial