Source code
Revision control
Copy as Markdown
Other Tools
Test Info: Warnings
- This test gets skipped with pattern: os == 'win' && socketprocess_networking && fission
- Manifest: toolkit/components/extensions/test/xpcshell/xpcshell-remote.toml includes toolkit/components/extensions/test/xpcshell/xpcshell-common.toml
- Manifest: toolkit/components/extensions/test/xpcshell/xpcshell.toml includes toolkit/components/extensions/test/xpcshell/xpcshell-common.toml
- Manifest: toolkit/components/extensions/test/xpcshell/xpcshell-serviceworker.toml
"use strict";
async function testExtensionWithBackground({
background,
expected_manifest_warnings,
}) {
let extension = ExtensionTestUtils.loadExtension({
manifest: { background },
});
ExtensionTestUtils.failOnSchemaWarnings(false);
await extension.startup();
ExtensionTestUtils.failOnSchemaWarnings(true);
await extension.unload();
Assert.deepEqual(
extension.extension.warnings,
expected_manifest_warnings,
"Expected manifest warnings"
);
}
add_task(async function test_empty_background_scripts() {
// extensions with an empty background.scripts property should load fine
await testExtensionWithBackground({
background: {
scripts: [],
},
expected_manifest_warnings: [
"Reading manifest: Warning processing background: background.scripts is empty.",
],
});
});
add_task(async function test_empty_background_object() {
// extensions with an empty background property should load fine
const requireAtLeastOneOfWarning =
WebExtensionPolicy.backgroundServiceWorkerEnabled
? 'Reading manifest: Warning processing background: Error processing background: background requires at least one of "service_worker", "scripts" or "page".'
: 'Reading manifest: Warning processing background: Error processing background: background requires at least one of "scripts" or "page".';
await testExtensionWithBackground({
background: {},
expected_manifest_warnings: [requireAtLeastOneOfWarning],
});
await testExtensionWithBackground({
background: {
unknown: true,
},
expected_manifest_warnings: [
"Reading manifest: Warning processing background.unknown: An unexpected property was found in the WebExtension manifest.",
requireAtLeastOneOfWarning,
],
});
await testExtensionWithBackground({
background: null,
expected_manifest_warnings: [],
});
});