diff options
author | Matt A. Tobin <email@mattatobin.com> | 2018-02-09 11:10:00 -0500 |
---|---|---|
committer | Matt A. Tobin <email@mattatobin.com> | 2018-02-09 11:10:00 -0500 |
commit | f164d9124708b50789dbb6959e1de96cc5697c48 (patch) | |
tree | 6dffd12e08c5383130df0252fb69cd6d6330794f /toolkit/components/extensions/test/xpcshell/test_getAPILevelForWindow.js | |
parent | 30de4018913f0cdaea19d1dd12ecd8209e2ed08e (diff) | |
download | UXP-f164d9124708b50789dbb6959e1de96cc5697c48.tar UXP-f164d9124708b50789dbb6959e1de96cc5697c48.tar.gz UXP-f164d9124708b50789dbb6959e1de96cc5697c48.tar.lz UXP-f164d9124708b50789dbb6959e1de96cc5697c48.tar.xz UXP-f164d9124708b50789dbb6959e1de96cc5697c48.zip |
Rename Toolkit's webextensions component directory to better reflect what it is.
Diffstat (limited to 'toolkit/components/extensions/test/xpcshell/test_getAPILevelForWindow.js')
-rw-r--r-- | toolkit/components/extensions/test/xpcshell/test_getAPILevelForWindow.js | 55 |
1 files changed, 0 insertions, 55 deletions
diff --git a/toolkit/components/extensions/test/xpcshell/test_getAPILevelForWindow.js b/toolkit/components/extensions/test/xpcshell/test_getAPILevelForWindow.js deleted file mode 100644 index 68741a6cc..000000000 --- a/toolkit/components/extensions/test/xpcshell/test_getAPILevelForWindow.js +++ /dev/null @@ -1,55 +0,0 @@ -"use strict"; - -Cu.import("resource://gre/modules/ExtensionManagement.jsm"); -Cu.import("resource://gre/modules/Services.jsm"); - -function createWindowWithAddonId(addonId) { - let baseURI = Services.io.newURI("about:blank", null, null); - let originAttributes = {addonId}; - let principal = Services.scriptSecurityManager - .createCodebasePrincipal(baseURI, originAttributes); - let chromeNav = Services.appShell.createWindowlessBrowser(true); - let interfaceRequestor = chromeNav.QueryInterface(Ci.nsIInterfaceRequestor); - let docShell = interfaceRequestor.getInterface(Ci.nsIDocShell); - docShell.createAboutBlankContentViewer(principal); - - return {chromeNav, window: docShell.contentViewer.DOMDocument.defaultView}; -} - -add_task(function* test_eventpages() { - const {getAPILevelForWindow, getAddonIdForWindow} = ExtensionManagement; - const {NO_PRIVILEGES, FULL_PRIVILEGES} = ExtensionManagement.API_LEVELS; - const FAKE_ADDON_ID = "fakeAddonId"; - const OTHER_ADDON_ID = "otherFakeAddonId"; - const EMPTY_ADDON_ID = ""; - - let fakeAddonId = createWindowWithAddonId(FAKE_ADDON_ID); - equal(getAddonIdForWindow(fakeAddonId.window), FAKE_ADDON_ID, - "the window has the expected addonId"); - - let apiLevel = getAPILevelForWindow(fakeAddonId.window, FAKE_ADDON_ID); - equal(apiLevel, FULL_PRIVILEGES, - "apiLevel for the window with the right addonId should be FULL_PRIVILEGES"); - - apiLevel = getAPILevelForWindow(fakeAddonId.window, OTHER_ADDON_ID); - equal(apiLevel, NO_PRIVILEGES, - "apiLevel for the window with a different addonId should be NO_PRIVILEGES"); - - fakeAddonId.chromeNav.close(); - - // NOTE: check that window with an empty addon Id (which are window that are - // not Extensions pages) always get no WebExtensions APIs. - let emptyAddonId = createWindowWithAddonId(EMPTY_ADDON_ID); - equal(getAddonIdForWindow(emptyAddonId.window), EMPTY_ADDON_ID, - "the window has the expected addonId"); - - apiLevel = getAPILevelForWindow(emptyAddonId.window, EMPTY_ADDON_ID); - equal(apiLevel, NO_PRIVILEGES, - "apiLevel for empty addonId should be NO_PRIVILEGES"); - - apiLevel = getAPILevelForWindow(emptyAddonId.window, OTHER_ADDON_ID); - equal(apiLevel, NO_PRIVILEGES, - "apiLevel for an 'empty addonId' window should be always NO_PRIVILEGES"); - - emptyAddonId.chromeNav.close(); -}); |