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

changeset 0
6474c204b198
equal deleted inserted replaced
-1:000000000000 0:e3ff0d5ee61d
1 /* Any copyright is dedicated to the Public Domain.
2 * http://creativecommons.org/publicdomain/zero/1.0/
3 */
4
5 /**
6 * Tests the default and custom "about" dialogs of add-ons.
7 *
8 * Test for bug 610661 <https://bugzilla.mozilla.org/show_bug.cgi?id=610661>:
9 * Addon object not passed to custom about dialogs.
10 */
11
12 var gManagerWindow;
13
14 const URI_ABOUT_DEFAULT = "chrome://mozapps/content/extensions/about.xul";
15 const URI_ABOUT_CUSTOM = CHROMEROOT + "addon_about.xul";
16
17 function test() {
18 requestLongerTimeout(2);
19
20 waitForExplicitFinish();
21
22 var gProvider = new MockProvider();
23 gProvider.createAddons([{
24 id: "test1@tests.mozilla.org",
25 name: "Test add-on 1",
26 description: "foo"
27 },
28 {
29 id: "test2@tests.mozilla.org",
30 name: "Test add-on 2",
31 description: "bar",
32 aboutURL: URI_ABOUT_CUSTOM
33 }]);
34
35 open_manager("addons://list/extension", function(aManager) {
36 gManagerWindow = aManager;
37
38 test_about_window("Test add-on 1", URI_ABOUT_DEFAULT, function() {
39 test_about_window("Test add-on 2", URI_ABOUT_CUSTOM, function() {
40 close_manager(gManagerWindow, finish);
41 });
42 });
43 });
44 }
45
46 function test_about_window(aAddonItemName, aExpectedAboutUri, aCallback) {
47 var addonList = gManagerWindow.document.getElementById("addon-list");
48 for (var addonItem of addonList.childNodes) {
49 if (addonItem.hasAttribute("name") &&
50 addonItem.getAttribute("name") === aAddonItemName)
51 break;
52 }
53
54 info("Waiting for about dialog");
55 Services.ww.registerNotification(function TEST_ww_observer(aSubject, aTopic,
56 aData) {
57 if (aTopic == "domwindowclosed") {
58 Services.ww.unregisterNotification(TEST_ww_observer);
59
60 info("About dialog closed, waiting for focus on browser window");
61 waitForFocus(aCallback);
62 } else if (aTopic == "domwindowopened") {
63 info("About dialog opened, waiting for focus");
64
65 let win = aSubject.QueryInterface(Ci.nsIDOMEventTarget);
66 waitForFocus(function() {
67 info("Saw about dialog");
68
69 is(win.location,
70 aExpectedAboutUri,
71 "The correct add-on about window should have opened");
72
73 is(win.arguments && win.arguments[0] && win.arguments[0].name,
74 aAddonItemName,
75 "window.arguments[0] should refer to the add-on object");
76
77 win.close();
78 }, win);
79 }
80 });
81
82 gManagerWindow.gViewController.doCommand("cmd_showItemAbout",
83 addonItem.mAddon);
84 }

mercurial