diff options
author | Matt A. Tobin <email@mattatobin.com> | 2018-02-10 02:49:12 -0500 |
---|---|---|
committer | Matt A. Tobin <email@mattatobin.com> | 2018-02-10 02:49:12 -0500 |
commit | 4fb11cd5966461bccc3ed1599b808237be6b0de9 (patch) | |
tree | d7f0ccd49cebb3544d52635ff1bd6ed4d763823f /toolkit/mozapps/webextensions/test/browser/browser_about.js | |
parent | f164d9124708b50789dbb6959e1de96cc5697c48 (diff) | |
download | UXP-4fb11cd5966461bccc3ed1599b808237be6b0de9.tar UXP-4fb11cd5966461bccc3ed1599b808237be6b0de9.tar.gz UXP-4fb11cd5966461bccc3ed1599b808237be6b0de9.tar.lz UXP-4fb11cd5966461bccc3ed1599b808237be6b0de9.tar.xz UXP-4fb11cd5966461bccc3ed1599b808237be6b0de9.zip |
Move WebExtensions enabled Add-ons Manager
Diffstat (limited to 'toolkit/mozapps/webextensions/test/browser/browser_about.js')
-rw-r--r-- | toolkit/mozapps/webextensions/test/browser/browser_about.js | 84 |
1 files changed, 84 insertions, 0 deletions
diff --git a/toolkit/mozapps/webextensions/test/browser/browser_about.js b/toolkit/mozapps/webextensions/test/browser/browser_about.js new file mode 100644 index 000000000..f781cf146 --- /dev/null +++ b/toolkit/mozapps/webextensions/test/browser/browser_about.js @@ -0,0 +1,84 @@ +/* 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 addonItem of addonList.childNodes) { + if (addonItem.hasAttribute("name") && + addonItem.getAttribute("name") === aAddonItemName) + break; + } + + info("Waiting for about dialog"); + Services.ww.registerNotification(function TEST_ww_observer(aSubject, aTopic, + aData) { + if (aTopic == "domwindowclosed") { + Services.ww.unregisterNotification(TEST_ww_observer); + + info("About dialog closed, waiting for focus on browser window"); + waitForFocus(() => executeSoon(aCallback)); + } else if (aTopic == "domwindowopened") { + info("About dialog opened, waiting for focus"); + + let win = aSubject.QueryInterface(Ci.nsIDOMEventTarget); + waitForFocus(function() { + info("Saw about dialog"); + + 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"); + + executeSoon(() => win.close()); + }, win); + } + }); + + gManagerWindow.gViewController.doCommand("cmd_showItemAbout", + addonItem.mAddon); +} |