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