Skip to content

Commit 8a42bef

Browse files
mr-cheffyRob--W
authored andcommitted
Bug 1943057 - Remove pref extensions.webextensions.userScripts.enabled r=extension-reviewers,robwu
Differential Revision: https://phabricator.services.mozilla.com/D258823
1 parent b23ccae commit 8a42bef

File tree

4 files changed

+0
-105
lines changed

4 files changed

+0
-105
lines changed

modules/libpref/init/all.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3137,7 +3137,6 @@ pref("extensions.originControls.grantByDefault", true);
31373137
pref("extensions.webextensions.protocol.remote", true);
31383138

31393139
// Enable userScripts API by default.
3140-
pref("extensions.webextensions.userScripts.enabled", true);
31413140
pref("extensions.userScripts.mv3.enabled", true);
31423141

31433142
// Whether or not the installed extensions should be migrated to the storage.local IndexedDB backend.

toolkit/components/extensions/child/ext-userScripts-content.js

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -6,22 +6,10 @@
66

77
"use strict";
88

9-
var USERSCRIPT_PREFNAME = "extensions.webextensions.userScripts.enabled";
10-
var USERSCRIPT_DISABLED_ERRORMSG = `userScripts APIs are currently experimental and must be enabled with the ${USERSCRIPT_PREFNAME} preference.`;
11-
129
ChromeUtils.defineESModuleGetters(this, {
1310
Schemas: "resource://gre/modules/Schemas.sys.mjs",
1411
});
1512

16-
XPCOMUtils.defineLazyPreferenceGetter(
17-
this,
18-
"userScriptsEnabled",
19-
USERSCRIPT_PREFNAME,
20-
false
21-
);
22-
23-
var { ExtensionError } = ExtensionUtils;
24-
2513
const TYPEOF_PRIMITIVES = ["bigint", "boolean", "number", "string", "symbol"];
2614

2715
/**
@@ -371,10 +359,6 @@ this.userScriptsContent = class extends ExtensionAPI {
371359
context,
372360
name: "userScripts.onBeforeScript",
373361
register: fire => {
374-
if (!userScriptsEnabled) {
375-
throw new ExtensionError(USERSCRIPT_DISABLED_ERRORMSG);
376-
}
377-
378362
let handler = (event, metadata, scriptSandbox) => {
379363
const us = new UserScript({
380364
context,

toolkit/components/extensions/child/ext-userScripts.js

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -6,16 +6,6 @@
66

77
"use strict";
88

9-
var USERSCRIPT_PREFNAME = "extensions.webextensions.userScripts.enabled";
10-
var USERSCRIPT_DISABLED_ERRORMSG = `userScripts APIs are currently experimental and must be enabled with the ${USERSCRIPT_PREFNAME} preference.`;
11-
12-
XPCOMUtils.defineLazyPreferenceGetter(
13-
this,
14-
"userScriptsEnabled",
15-
USERSCRIPT_PREFNAME,
16-
false
17-
);
18-
199
// eslint-disable-next-line mozilla/reject-importGlobalProperties
2010
Cu.importGlobalProperties(["crypto", "TextEncoder"]);
2111

@@ -170,10 +160,6 @@ this.userScripts = class extends ExtensionAPI {
170160
return {
171161
userScripts: {
172162
register(options) {
173-
if (!userScriptsEnabled) {
174-
throw new ExtensionError(USERSCRIPT_DISABLED_ERRORMSG);
175-
}
176-
177163
let scriptId = getUniqueId();
178164
return context.cloneScope.Promise.resolve().then(async () => {
179165
options.scriptId = scriptId;

toolkit/components/extensions/test/xpcshell/test_ext_userScripts.js

Lines changed: 0 additions & 74 deletions
Original file line numberDiff line numberDiff line change
@@ -417,80 +417,6 @@ add_task(async function test_cached_userScript_on_document_start() {
417417
await extension.unload();
418418
});
419419

420-
add_task(async function test_userScripts_pref_disabled() {
421-
async function run_userScript_on_pref_disabled_test() {
422-
async function background() {
423-
let promise = (async () => {
424-
await browser.userScripts.register({
425-
js: [
426-
{
427-
code: "throw new Error('This userScripts should not be registered')",
428-
},
429-
],
430-
runAt: "document_start",
431-
matches: ["<all_urls>"],
432-
});
433-
})();
434-
435-
await browser.test.assertRejects(
436-
promise,
437-
/userScripts APIs are currently experimental/,
438-
"Got the expected error from userScripts.register when the userScripts API is disabled"
439-
);
440-
441-
browser.test.sendMessage("background-page:done");
442-
}
443-
444-
async function contentScript() {
445-
let promise = (async () => {
446-
browser.userScripts.onBeforeScript.addListener(() => {});
447-
})();
448-
await browser.test.assertRejects(
449-
promise,
450-
/userScripts APIs are currently experimental/,
451-
"Got the expected error from userScripts.onBeforeScript when the userScripts API is disabled"
452-
);
453-
454-
browser.test.sendMessage("content-script:done");
455-
}
456-
457-
let extension = ExtensionTestUtils.loadExtension({
458-
background,
459-
manifest: {
460-
permissions: ["http://*/*/file_sample.html"],
461-
user_scripts: { api_script: "" },
462-
content_scripts: [
463-
{
464-
matches: ["http://*/*/file_sample.html"],
465-
js: ["content_script.js"],
466-
run_at: "document_start",
467-
},
468-
],
469-
},
470-
files: {
471-
"content_script.js": contentScript,
472-
},
473-
});
474-
475-
await extension.startup();
476-
477-
await extension.awaitMessage("background-page:done");
478-
479-
let url = `${BASE_URL}/file_sample.html`;
480-
let contentPage = await ExtensionTestUtils.loadContentPage(url);
481-
482-
await extension.awaitMessage("content-script:done");
483-
484-
await extension.unload();
485-
await contentPage.close();
486-
}
487-
488-
await runWithPrefs(
489-
[["extensions.webextensions.userScripts.enabled", false]],
490-
run_userScript_on_pref_disabled_test
491-
);
492-
});
493-
494420
// This test verify that userScripts.onBeforeScript API Event is not available without
495421
// a "user_scripts.api_script" property in the manifest.
496422
add_task(async function test_user_script_api_script_required() {

0 commit comments

Comments
 (0)