Bug 610661: Pass Addon object to custom about dialogs. r+a=dtownsend

--HG--
rename : toolkit/mozapps/extensions/test/browser/addon_prefs.xul => toolkit/mozapps/extensions/test/browser/addon_about.xul
This commit is contained in:
Paolo Amadini 2011-01-11 09:47:53 -08:00
parent ff24f46b45
commit 1066e91218
4 changed files with 90 additions and 1 deletions

View File

@ -887,7 +887,7 @@ var gViewController = {
doCommand: function(aAddon) {
var aboutURL = aAddon.aboutURL;
if (aboutURL)
openDialog(aboutURL, "", "chrome,centerscreen,modal");
openDialog(aboutURL, "", "chrome,centerscreen,modal", aAddon);
else
openDialog("chrome://mozapps/content/extensions/about.xul",
"", "chrome,centerscreen,modal", aAddon);

View File

@ -47,6 +47,7 @@ include $(DEPTH)/config/autoconf.mk
_MAIN_TEST_FILES = \
head.js \
browser_about.js \
browser_bug557943.js \
browser_bug562797.js \
browser_bug562890.js \
@ -89,6 +90,7 @@ _TEST_FILES = \
$(NULL)
_TEST_RESOURCES = \
addon_about.xul \
addon_prefs.xul \
browser_bug557956.rdf \
browser_bug557956_8_2.xpi \

View File

@ -0,0 +1,6 @@
<?xml version="1.0"?>
<?xml-stylesheet href="chrome://global/skin/" type="text/css"?>
<window xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
id="addon-test-about-window">
<label value="Oh hai!"/>
</window>

View File

@ -0,0 +1,81 @@
/* Any copyright is dedicated to the Public Domain.
* http://creativecommons.org/publicdomain/zero/1.0/
*/
/**
* Tests the default and custom "about" dialogs of add-ons.
*
* Test for bug 610661 <https://bugzilla.mozilla.org/show_bug.cgi?id=610661>:
* Addon object not passed to custom about dialogs.
*/
var gManagerWindow;
const URI_ABOUT_DEFAULT = "chrome://mozapps/content/extensions/about.xul";
const URI_ABOUT_CUSTOM = CHROMEROOT + "addon_about.xul";
function test() {
requestLongerTimeout(2);
waitForExplicitFinish();
var gProvider = new MockProvider();
gProvider.createAddons([{
id: "test1@tests.mozilla.org",
name: "Test add-on 1",
description: "foo"
},
{
id: "test2@tests.mozilla.org",
name: "Test add-on 2",
description: "bar",
aboutURL: URI_ABOUT_CUSTOM
}]);
open_manager("addons://list/extension", function(aManager) {
gManagerWindow = aManager;
test_about_window("Test add-on 1", URI_ABOUT_DEFAULT, function() {
test_about_window("Test add-on 2", URI_ABOUT_CUSTOM, function() {
close_manager(gManagerWindow, finish);
});
});
});
}
function test_about_window(aAddonItemName, aExpectedAboutUri, aCallback) {
var addonList = gManagerWindow.document.getElementById("addon-list");
for (var i = 0; i < addonList.childNodes.length; i++) {
var addonItem = addonList.childNodes[i];
if (addonItem.hasAttribute("name") &&
addonItem.getAttribute("name") === aAddonItemName)
break;
}
Services.ww.registerNotification(function TEST_ww_observer(aSubject, aTopic,
aData) {
if (aTopic == "domwindowclosed") {
Services.ww.unregisterNotification(TEST_ww_observer);
// Give the window a chance to finish closing before continuing.
executeSoon(aCallback);
} else if (aTopic == "domwindowopened") {
let win = aSubject.QueryInterface(Ci.nsIDOMEventTarget);
win.addEventListener("load", function TEST_ww_onLoad() {
is(win.location,
aExpectedAboutUri,
"The correct add-on about window should have opened");
is(win.arguments && win.arguments[0] && win.arguments[0].name,
aAddonItemName,
"window.arguments[0] should refer to the add-on object");
win.removeEventListener("load", TEST_ww_onLoad, false);
win.close();
}, false);
}
});
gManagerWindow.gViewController.doCommand("cmd_showItemAbout",
addonItem.mAddon);
}