diff options
author | wolfbeast <mcwerewolf@wolfbeast.com> | 2019-04-05 20:01:10 +0200 |
---|---|---|
committer | wolfbeast <mcwerewolf@wolfbeast.com> | 2019-04-05 20:01:10 +0200 |
commit | c3b63b831cd2c64700e875b28540212c7c881ac6 (patch) | |
tree | edd98fcbd2004d3b562904f822bf6c3322fc7f52 /toolkit/components/webextensions/test/xpcshell/test_ext_schemas_api_injection.js | |
parent | d432e068a21c815d5d5e7bcbc1cc8c6e77a7d1e0 (diff) | |
parent | cc07da9cb4d6e7a53f8d953427ffc2bca2e0c2df (diff) | |
download | UXP-c3b63b831cd2c64700e875b28540212c7c881ac6.tar UXP-c3b63b831cd2c64700e875b28540212c7c881ac6.tar.gz UXP-c3b63b831cd2c64700e875b28540212c7c881ac6.tar.lz UXP-c3b63b831cd2c64700e875b28540212c7c881ac6.tar.xz UXP-c3b63b831cd2c64700e875b28540212c7c881ac6.zip |
Merge branch 'master' into 816
Diffstat (limited to 'toolkit/components/webextensions/test/xpcshell/test_ext_schemas_api_injection.js')
-rw-r--r-- | toolkit/components/webextensions/test/xpcshell/test_ext_schemas_api_injection.js | 102 |
1 files changed, 0 insertions, 102 deletions
diff --git a/toolkit/components/webextensions/test/xpcshell/test_ext_schemas_api_injection.js b/toolkit/components/webextensions/test/xpcshell/test_ext_schemas_api_injection.js deleted file mode 100644 index 36d88d722..000000000 --- a/toolkit/components/webextensions/test/xpcshell/test_ext_schemas_api_injection.js +++ /dev/null @@ -1,102 +0,0 @@ -"use strict"; - -Components.utils.import("resource://gre/modules/ExtensionCommon.jsm"); -Components.utils.import("resource://gre/modules/Schemas.jsm"); - -let { - BaseContext, - SchemaAPIManager, -} = ExtensionCommon; - -let nestedNamespaceJson = [ - { - "namespace": "backgroundAPI.testnamespace", - "functions": [ - { - "name": "create", - "type": "function", - "parameters": [ - { - "name": "title", - "type": "string", - }, - ], - "returns": { - "type": "string", - }, - }, - ], - }, - { - "namespace": "noBackgroundAPI.testnamespace", - "functions": [ - { - "name": "create", - "type": "function", - "parameters": [ - { - "name": "title", - "type": "string", - }, - ], - }, - ], - }, -]; - -let global = this; -class StubContext extends BaseContext { - constructor() { - let fakeExtension = {id: "test@web.extension"}; - super("addon_child", fakeExtension); - this.sandbox = Cu.Sandbox(global); - this.viewType = "background"; - } - - get cloneScope() { - return this.sandbox; - } -} - -add_task(function* testSchemaAPIInjection() { - let url = "data:," + JSON.stringify(nestedNamespaceJson); - - // Load the schema of the fake APIs. - yield Schemas.load(url); - - let apiManager = new SchemaAPIManager("addon"); - - // Register an API that will skip the background page. - apiManager.registerSchemaAPI("noBackgroundAPI.testnamespace", "addon_child", context => { - // This API should not be available in this context, return null so that - // the schema wrapper is removed as well. - return null; - }); - - // Register an API that will skip any but the background page. - apiManager.registerSchemaAPI("backgroundAPI.testnamespace", "addon_child", context => { - if (context.viewType === "background") { - return { - backgroundAPI: { - testnamespace: { - create(title) { - return title; - }, - }, - }, - }; - } - - // This API should not be available in this context, return null so that - // the schema wrapper is removed as well. - return null; - }); - - let context = new StubContext(); - let browserObj = {}; - apiManager.generateAPIs(context, browserObj); - - do_check_eq(browserObj.noBackgroundAPI, undefined); - const res = browserObj.backgroundAPI.testnamespace.create("param-value"); - do_check_eq(res, "param-value"); -}); |