diff options
author | Matt A. Tobin <email@mattatobin.com> | 2018-02-11 07:03:16 -0500 |
---|---|---|
committer | Matt A. Tobin <email@mattatobin.com> | 2018-02-11 07:03:16 -0500 |
commit | 203eb0f61a09372310a2a8fb57e169cb3f47800b (patch) | |
tree | 8490329d3dae4de3c7ffd127bce1f65fdc009abd /toolkit/mozapps/extensions/test/browser/browser_bug562890.js | |
parent | e45706ca3acbb6530419433212becc61d5953a2d (diff) | |
parent | 8f6d3dab81c7f8f97ef197e26ab9439b09735b8f (diff) | |
download | UXP-203eb0f61a09372310a2a8fb57e169cb3f47800b.tar UXP-203eb0f61a09372310a2a8fb57e169cb3f47800b.tar.gz UXP-203eb0f61a09372310a2a8fb57e169cb3f47800b.tar.lz UXP-203eb0f61a09372310a2a8fb57e169cb3f47800b.tar.xz UXP-203eb0f61a09372310a2a8fb57e169cb3f47800b.zip |
Merge branch 'ext-work'FF_Checkpoint_1
Diffstat (limited to 'toolkit/mozapps/extensions/test/browser/browser_bug562890.js')
-rw-r--r-- | toolkit/mozapps/extensions/test/browser/browser_bug562890.js | 78 |
1 files changed, 78 insertions, 0 deletions
diff --git a/toolkit/mozapps/extensions/test/browser/browser_bug562890.js b/toolkit/mozapps/extensions/test/browser/browser_bug562890.js new file mode 100644 index 000000000..375cb9ef0 --- /dev/null +++ b/toolkit/mozapps/extensions/test/browser/browser_bug562890.js @@ -0,0 +1,78 @@ +/* Any copyright is dedicated to the Public Domain. + * http://creativecommons.org/publicdomain/zero/1.0/ + */ + +/** + * Tests the Preferences button for addons in list view + */ + +function test() { + requestLongerTimeout(2); + + waitForExplicitFinish(); + + var addonPrefsURI = CHROMEROOT + "addon_prefs.xul"; + + 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", + optionsURL: addonPrefsURI + }]); + + open_manager("addons://list/extension", function(aManager) { + var addonList = aManager.document.getElementById("addon-list"); + for (var addonItem of addonList.childNodes) { + if (addonItem.hasAttribute("name") && + addonItem.getAttribute("name") == "Test add-on 1") + break; + } + var prefsBtn = aManager.document.getAnonymousElementByAttribute(addonItem, + "anonid", + "preferences-btn"); + is(prefsBtn.hidden, true, "Prefs button should be hidden for addon with no optionsURL set") + + for (addonItem of addonList.childNodes) { + if (addonItem.hasAttribute("name") && + addonItem.getAttribute("name") == "Test add-on 2") + break; + } + prefsBtn = aManager.document.getAnonymousElementByAttribute(addonItem, + "anonid", + "preferences-btn"); + is(prefsBtn.hidden, false, "Prefs button should be shown for addon with a optionsURL set") + + Services.ww.registerNotification(function TEST_ww_observer(aSubject, aTopic, aData) { + if (aTopic == "domwindowclosed") { + Services.ww.unregisterNotification(TEST_ww_observer); + // Give the preference window a chance to finish closing before closing + // the add-ons manager. + executeSoon(function() { + close_manager(aManager, finish); + }); + } else if (aTopic == "domwindowopened") { + let win = aSubject.QueryInterface(Ci.nsIDOMEventTarget); + win = aSubject.QueryInterface(Ci.nsIDOMEventTarget); + win.addEventListener("load", function TEST_ww_onLoad() { + if (win.location != addonPrefsURI) + return; + + win.removeEventListener("load", TEST_ww_onLoad, false); + is(win.location, addonPrefsURI, + "The correct addon pref window should have opened"); + win.close(); + }, false); + } + }); + + addonList.ensureElementIsVisible(addonItem); + EventUtils.synthesizeMouseAtCenter(prefsBtn, { }, aManager); + }); + +} |