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

changeset 0
6474c204b198
equal deleted inserted replaced
-1:000000000000 0:ecd313727eff
1 /* Any copyright is dedicated to the Public Domain.
2 * http://creativecommons.org/publicdomain/zero/1.0/
3 */
4
5 // Tests various aspects of the details view
6
7 var gManagerWindow;
8 var gCategoryUtilities;
9
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 }
21
22 function test() {
23 waitForExplicitFinish();
24
25 installAddon(function () {
26 open_manager("addons://list/extension", function(aWindow) {
27 gManagerWindow = aWindow;
28 gCategoryUtilities = new CategoryUtilities(gManagerWindow);
29
30 run_next_test();
31 });
32 });
33 }
34
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 }
43
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);
49
50 var button = gManagerWindow.document.getAnonymousElementByAttribute(addon, "anonid", "preferences-btn");
51 is_element_visible(button, "Preferences button should be visible");
52
53 run_next_test();
54 });
55
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);
60
61 var button = gManagerWindow.document.getAnonymousElementByAttribute(addon, "anonid", "preferences-btn");
62 EventUtils.synthesizeMouseAtCenter(button, { clickCount: 1 }, gManagerWindow);
63
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");
68
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");
72
73 ok(settings[0].hasAttribute("first-row"), "First visible row should have first-row attribute");
74
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");
79
80 var label = gManagerWindow.document.getAnonymousElementByAttribute(settings[0], "anonid", "label");
81 is(label.textContent, "Custom", "Localized string should be shown");
82
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");
86
87 button = gManagerWindow.document.getElementById("detail-prefs-btn");
88 is_element_hidden(button, "Preferences button should not be visible");
89
90 gCategoryUtilities.openType("extension", run_next_test);
91 });
92 });

mercurial