unable to run api.js in extension when declaring script: api.js experiment_apis in manifest.json
Categories
(WebExtensions :: Untriaged, defect)
Tracking
(Not tracked)
People
(Reporter: john, Unassigned)
Details
User Agent: Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:134.0) Gecko/20100101 Firefox/134.0
Steps to reproduce:
manifest.json
{
"manifest_version": 2,
"name": "MyTestExtension",
"version": "1.0",
"description": "Minimal experiment demo",
"browser_specific_settings": {
"gecko": {
"id": "mytestextension@example.com",
"strict_min_version": "136.0a1"
}
},
"background": {
"scripts": ["background.js"]
},
"experiment_apis": {
"helloWorld": {
"schema": "schema.json",
"parent": {
"scopes": ["addon_parent"],
"paths": [["helloWorld"]],
"script": "api.js"
}
}
}
}
schema.json:
{
"schema": 2,
"types": [],
"functions": [
{
"name": "sayHello",
"type": "function",
"async": true,
"parameters": []
}
]
}
api.js
"use strict";
console.log("api.js loaded for the experiment.");
// Import ExtensionAPI from ExtensionCommon
var { ExtensionAPI } = ChromeUtils.import("resource://gre/modules/ExtensionCommon.jsm");
this.helloWorld = class extends ExtensionAPI {
getAPI(context) {
return {
helloWorld: {
async sayHello() {
console.log("Hello from the custom experiment!");
return "Hello from the custom experiment!";
}
}
};
}
};
running Firefox Nightly 136.0a1
- extensions.experiments.enabled : true
- xpinstall.signatures.required: false
Actual results:
background.js is not able to call browser.helloWorld, and browser.helloWorld does not appear when running the debug console, because it is null
Expected results:
console.log("api.js loaded for the experiment."); should have run
browser.helloWorld should not be null
Updated•1 month ago
|
My schema.json was formatted wrong. it is supposed to be a json list:
[
{
"namespace": "helloWorld",
"schema_version": 1,
"types": [],
"functions": [
{
"name": "sayHello",
"type": "function",
"async": true,
"parameters": []
}
]
}
]
Description
•