Bug 888778 - Custom binding not applied to inline settings; r=Unfocused

This commit is contained in:
Geoff Lankow 2013-07-03 00:20:51 +12:00
parent 7cfec0c252
commit 20b7dce3f8
9 changed files with 155 additions and 1 deletions

View File

@ -2973,7 +2973,8 @@ var gDetailView = {
var settings = xml.querySelectorAll(":root > setting");
var firstSetting = null;
for (let setting of settings) {
for (var xmlSetting of settings) {
var setting = document.importNode(xmlSetting, true);
var desc = stripTextNodes(setting).trim();
if (!setting.hasAttribute("desc"))
@ -2983,6 +2984,12 @@ var gDetailView = {
if (type == "file" || type == "directory")
setting.setAttribute("fullpath", "true");
var style = setting.getAttribute("style");
if (style) {
setting.removeAttribute("style");
setting.setAttribute("style", style);
}
rows.appendChild(setting);
var visible = window.getComputedStyle(setting, null).getPropertyValue("display") != "none";
if (!firstSetting && visible) {

View File

@ -59,6 +59,7 @@ MOCHITEST_BROWSER_MAIN = \
browser_openDialog.js \
browser_types.js \
browser_inlinesettings.js \
browser_inlinesettings_custom.js \
browser_inlinesettings_info.js \
browser_tabsettings.js \
browser_pluginprefs.js \

View File

@ -0,0 +1,19 @@
<?xml version="1.0"?>
<bindings xmlns="http://www.mozilla.org/xbl"
xmlns:xbl="http://www.mozilla.org/xbl"
xmlns:xul="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
<binding id="custom"
extends="chrome://mozapps/content/extensions/setting.xml#setting-base">
<content>
<xul:vbox>
<xul:hbox class="preferences-alignment">
<xul:label anonid="label" class="preferences-title" flex="1" xbl:inherits="xbl:text=title"/>
</xul:hbox>
<xul:description class="preferences-description" flex="1" xbl:inherits="xbl:text=desc"/>
</xul:vbox>
<xul:hbox class="preferences-alignment">
<xul:label anonid="input" value="Woah!"/>
</xul:hbox>
</content>
</binding>
</bindings>

View File

@ -0,0 +1,8 @@
function install (params, aReason) {
}
function uninstall (params, aReason) {
}
function startup (params, aReason) {
}
function shutdown (params, aReason) {
}

View File

@ -0,0 +1,2 @@
content inlinesettings ./
locale inlinesettings en-US ./

View File

@ -0,0 +1,19 @@
<?xml version="1.0" ?>
<RDF xmlns="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:em="http://www.mozilla.org/2004/em-rdf#">
<Description about="urn:mozilla:install-manifest">
<em:id>inlinesettings1@tests.mozilla.org</em:id>
<em:name>Inline Settings (Bootstrap)</em:name>
<em:version>1</em:version>
<em:bootstrap>true</em:bootstrap>
<em:targetApplication>
<Description>
<em:id>toolkit@mozilla.org</em:id>
<em:minVersion>0</em:minVersion>
<em:maxVersion>*</em:maxVersion>
</Description>
</em:targetApplication>
</Description>
</RDF>

View File

@ -0,0 +1,5 @@
<?xml version="1.0" ?>
<!DOCTYPE vbox SYSTEM "chrome://inlinesettings/locale/string.dtd">
<vbox xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
<setting type="custom" title="&custom.title;" style="background-color: blue; display: -moz-grid-line; -moz-binding: url('chrome://inlinesettings/content/binding.xml#custom');"/>
</vbox>

View File

@ -0,0 +1 @@
<!ENTITY custom.title "Custom">

View File

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