Wed, 31 Dec 2014 06:09:35 +0100
Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.
1 /* Any copyright is dedicated to the Public Domain.
2 * http://creativecommons.org/publicdomain/zero/1.0/
3 */
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 */
12 var gManagerWindow;
14 const URI_ABOUT_DEFAULT = "chrome://mozapps/content/extensions/about.xul";
15 const URI_ABOUT_CUSTOM = CHROMEROOT + "addon_about.xul";
17 function test() {
18 requestLongerTimeout(2);
20 waitForExplicitFinish();
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 }]);
35 open_manager("addons://list/extension", function(aManager) {
36 gManagerWindow = aManager;
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 }
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 }
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);
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");
65 let win = aSubject.QueryInterface(Ci.nsIDOMEventTarget);
66 waitForFocus(function() {
67 info("Saw about dialog");
69 is(win.location,
70 aExpectedAboutUri,
71 "The correct add-on about window should have opened");
73 is(win.arguments && win.arguments[0] && win.arguments[0].name,
74 aAddonItemName,
75 "window.arguments[0] should refer to the add-on object");
77 win.close();
78 }, win);
79 }
80 });
82 gManagerWindow.gViewController.doCommand("cmd_showItemAbout",
83 addonItem.mAddon);
84 }