зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1766615 - Enable scripting APIs in MV2. r=rpl
Differential Revision: https://phabricator.services.mozilla.com/D145629
This commit is contained in:
Родитель
1b235627d5
Коммит
4968829f54
|
@ -5,7 +5,9 @@
|
|||
Services.prefs.setBoolPref("extensions.manifestV3.enabled", true);
|
||||
|
||||
async function testManifest(manifest, expectedError) {
|
||||
ExtensionTestUtils.failOnSchemaWarnings(false);
|
||||
let normalized = await ExtensionTestUtils.normalizeManifest(manifest);
|
||||
ExtensionTestUtils.failOnSchemaWarnings(true);
|
||||
|
||||
if (expectedError) {
|
||||
ok(
|
||||
|
@ -75,10 +77,6 @@ add_task(async function test_manifest() {
|
|||
});
|
||||
|
||||
add_task(async function test_action_version() {
|
||||
// The above test validates these work with the correct version,
|
||||
// here we verify they fail with the incorrect version for MV3.
|
||||
ExtensionTestUtils.failOnSchemaWarnings(false);
|
||||
|
||||
let warnings = await testManifest({
|
||||
manifest_version: 3,
|
||||
browser_action: {
|
||||
|
@ -104,33 +102,22 @@ add_task(async function test_action_version() {
|
|||
[`Property "action" is unsupported in Manifest Version 2`],
|
||||
`Manifest v2 with "action" key first warning is clear.`
|
||||
);
|
||||
|
||||
ExtensionTestUtils.failOnSchemaWarnings(true);
|
||||
});
|
||||
|
||||
add_task(async function test_scripting_permission() {
|
||||
ExtensionTestUtils.failOnSchemaWarnings(false);
|
||||
add_task(async function test_mv2_scripting_permission_always_enabled() {
|
||||
let warnings = await testManifest({
|
||||
manifest_version: 2,
|
||||
permissions: ["scripting"],
|
||||
});
|
||||
|
||||
// The "scripting" permission is only available in MV3.
|
||||
Assert.deepEqual(warnings, [], "Got no warnings");
|
||||
});
|
||||
|
||||
add_task(async function test_mv3_scripting_permission_always_enabled() {
|
||||
let warnings = await testManifest({
|
||||
manifest_version: 3,
|
||||
permissions: ["scripting"],
|
||||
});
|
||||
|
||||
Assert.deepEqual(warnings, [], "Got no warnings");
|
||||
|
||||
warnings = await testManifest({
|
||||
manifest_version: 2,
|
||||
permissions: ["scripting"],
|
||||
});
|
||||
|
||||
equal(warnings.length, 1, "Got exactly one warning");
|
||||
ok(
|
||||
warnings[0]?.startsWith(
|
||||
`Warning processing permissions: Error processing permissions.0: Value "scripting" must either:`
|
||||
),
|
||||
`Got the expected warning message: ${warnings[0]}`
|
||||
);
|
||||
|
||||
ExtensionTestUtils.failOnSchemaWarnings(true);
|
||||
});
|
||||
|
|
|
@ -10,8 +10,7 @@
|
|||
"$extend": "OptionalPermissionNoPrompt",
|
||||
"choices": [{
|
||||
"type": "string",
|
||||
"enum": ["scripting"],
|
||||
"min_manifest_version": 3
|
||||
"enum": ["scripting"]
|
||||
}]
|
||||
}
|
||||
]
|
||||
|
@ -20,7 +19,6 @@
|
|||
"namespace": "scripting",
|
||||
"description": "Use the scripting API to execute script in different contexts.",
|
||||
"permissions": ["scripting"],
|
||||
"min_manifest_version": 3,
|
||||
"types": [
|
||||
{
|
||||
"id": "ScriptInjection",
|
||||
|
|
|
@ -0,0 +1,23 @@
|
|||
"use strict";
|
||||
|
||||
add_task(async function test_scripting_enabled_in_mv2() {
|
||||
const extension = ExtensionTestUtils.loadExtension({
|
||||
manifest: {
|
||||
manifest_version: 2,
|
||||
permissions: ["scripting"],
|
||||
},
|
||||
background() {
|
||||
browser.test.assertEq(
|
||||
"object",
|
||||
typeof browser.scripting,
|
||||
"expected scripting namespace to be defined"
|
||||
);
|
||||
|
||||
browser.test.sendMessage("background-done");
|
||||
},
|
||||
});
|
||||
|
||||
await extension.startup();
|
||||
await extension.awaitMessage("background-done");
|
||||
await extension.unload();
|
||||
});
|
|
@ -214,6 +214,7 @@ skip-if =
|
|||
os == "linux" && debug && fission # Bug 1762638
|
||||
os == "mac" && debug && fission # Bug 1762638
|
||||
[test_ext_scripting_contentScripts_file.js]
|
||||
[test_ext_scripting_mv2.js]
|
||||
[test_ext_scripting_updateContentScripts.js]
|
||||
[test_ext_shared_workers.js]
|
||||
[test_ext_shutdown_cleanup.js]
|
||||
|
|
Загрузка…
Ссылка в новой задаче