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