diff options
author | Matt A. Tobin <email@mattatobin.com> | 2018-02-10 02:51:36 -0500 |
---|---|---|
committer | Matt A. Tobin <email@mattatobin.com> | 2018-02-10 02:51:36 -0500 |
commit | 37d5300335d81cecbecc99812747a657588c63eb (patch) | |
tree | 765efa3b6a56bb715d9813a8697473e120436278 /toolkit/mozapps/extensions/test/browser/browser_webapi.js | |
parent | b2bdac20c02b12f2057b9ef70b0a946113a00e00 (diff) | |
parent | 4fb11cd5966461bccc3ed1599b808237be6b0de9 (diff) | |
download | UXP-37d5300335d81cecbecc99812747a657588c63eb.tar UXP-37d5300335d81cecbecc99812747a657588c63eb.tar.gz UXP-37d5300335d81cecbecc99812747a657588c63eb.tar.lz UXP-37d5300335d81cecbecc99812747a657588c63eb.tar.xz UXP-37d5300335d81cecbecc99812747a657588c63eb.zip |
Merge branch 'ext-work'
Diffstat (limited to 'toolkit/mozapps/extensions/test/browser/browser_webapi.js')
-rw-r--r-- | toolkit/mozapps/extensions/test/browser/browser_webapi.js | 106 |
1 files changed, 0 insertions, 106 deletions
diff --git a/toolkit/mozapps/extensions/test/browser/browser_webapi.js b/toolkit/mozapps/extensions/test/browser/browser_webapi.js deleted file mode 100644 index ca8e41aad..000000000 --- a/toolkit/mozapps/extensions/test/browser/browser_webapi.js +++ /dev/null @@ -1,106 +0,0 @@ -/* Any copyright is dedicated to the Public Domain. - * http://creativecommons.org/publicdomain/zero/1.0/ - */ - -const TESTPAGE = `${SECURE_TESTROOT}webapi_checkavailable.html`; - -Services.prefs.setBoolPref("extensions.webapi.testing", true); -registerCleanupFunction(() => { - Services.prefs.clearUserPref("extensions.webapi.testing"); -}); - -function testWithAPI(task) { - return function*() { - yield BrowserTestUtils.withNewTab(TESTPAGE, task); - } -} - -let gProvider = new MockProvider(); - -let addons = gProvider.createAddons([{ - id: "addon1@tests.mozilla.org", - name: "Test add-on 1", - version: "2.1", - description: "Short description", - type: "extension", - userDisabled: false, - isActive: true, -}, { - id: "addon2@tests.mozilla.org", - name: "Test add-on 2", - version: "5.3.7ab", - description: null, - type: "theme", - userDisabled: false, - isActive: false, -}, { - id: "addon3@tests.mozilla.org", - name: "Test add-on 3", - version: "1", - description: "Longer description", - type: "extension", - userDisabled: true, - isActive: false, -}, { - id: "addon4@tests.mozilla.org", - name: "Test add-on 4", - version: "1", - description: "Longer description", - type: "extension", - userDisabled: false, - isActive: true, -}]); - -addons[3].permissions &= ~AddonManager.PERM_CAN_UNINSTALL; - -function API_getAddonByID(browser, id) { - return ContentTask.spawn(browser, id, function*(id) { - let addon = yield content.navigator.mozAddonManager.getAddonByID(id); - - // We can't send native objects back so clone its properties. - let result = {}; - for (let prop in addon) { - result[prop] = addon[prop]; - } - - return result; - }); -} - -add_task(testWithAPI(function*(browser) { - function compareObjects(web, real) { - for (let prop of Object.keys(web)) { - let webVal = web[prop]; - let realVal = real[prop]; - - switch (prop) { - case "isEnabled": - realVal = !real.userDisabled; - break; - - case "canUninstall": - realVal = Boolean(real.permissions & AddonManager.PERM_CAN_UNINSTALL); - break; - } - - // null and undefined don't compare well so stringify them first - if (realVal === null || realVal === undefined) { - realVal = `${realVal}`; - webVal = `${webVal}`; - } - - is(webVal, realVal, `Property ${prop} should have the right value in add-on ${real.id}`); - } - } - - let [a1, a2, a3] = yield promiseAddonsByIDs(["addon1@tests.mozilla.org", - "addon2@tests.mozilla.org", - "addon3@tests.mozilla.org"]); - let w1 = yield API_getAddonByID(browser, "addon1@tests.mozilla.org"); - let w2 = yield API_getAddonByID(browser, "addon2@tests.mozilla.org"); - let w3 = yield API_getAddonByID(browser, "addon3@tests.mozilla.org"); - - compareObjects(w1, a1); - compareObjects(w2, a2); - compareObjects(w3, a3); -})); |