diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-28 14:29:10 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-28 14:29:10 +0000 |
commit | 2aa4a82499d4becd2284cdb482213d541b8804dd (patch) | |
tree | b80bf8bf13c3766139fbacc530efd0dd9d54394c /browser/components/extensions/test/xpcshell/test_ext_manifest.js | |
parent | Initial commit. (diff) | |
download | firefox-upstream.tar.xz firefox-upstream.zip |
Adding upstream version 86.0.1.upstream/86.0.1upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'browser/components/extensions/test/xpcshell/test_ext_manifest.js')
-rw-r--r-- | browser/components/extensions/test/xpcshell/test_ext_manifest.js | 61 |
1 files changed, 61 insertions, 0 deletions
diff --git a/browser/components/extensions/test/xpcshell/test_ext_manifest.js b/browser/components/extensions/test/xpcshell/test_ext_manifest.js new file mode 100644 index 0000000000..376d3901c0 --- /dev/null +++ b/browser/components/extensions/test/xpcshell/test_ext_manifest.js @@ -0,0 +1,61 @@ +/* -*- Mode: indent-tabs-mode: nil; js-indent-level: 2 -*- */ +/* vim: set sts=2 sw=2 et tw=80: */ +"use strict"; + +async function testIconPaths(icon, manifest, expectedError) { + let normalized = await ExtensionTestUtils.normalizeManifest(manifest); + + if (expectedError) { + ok( + expectedError.test(normalized.error), + `Should have an error for ${JSON.stringify(manifest)}` + ); + } else { + ok( + !normalized.error, + `Should not have an error ${JSON.stringify(manifest)}, ${ + normalized.error + }` + ); + } +} + +add_task(async function test_manifest() { + let badpaths = ["", " ", "\t", "http://foo.com/icon.png"]; + for (let path of badpaths) { + for (let action of ["browser_action", "page_action", "sidebar_action"]) { + let manifest = {}; + manifest[action] = { default_icon: path }; + let error = new RegExp(`Error processing ${action}.default_icon`); + await testIconPaths(path, manifest, error); + + manifest[action] = { default_icon: { "16": path } }; + await testIconPaths(path, manifest, error); + } + } + + let paths = [ + "icon.png", + "/icon.png", + "./icon.png", + "path to an icon.png", + " icon.png", + ]; + for (let path of paths) { + for (let action of ["browser_action", "page_action", "sidebar_action"]) { + let manifest = {}; + manifest[action] = { default_icon: path }; + if (action == "sidebar_action") { + // Sidebar requires panel. + manifest[action].default_panel = "foo.html"; + } + await testIconPaths(path, manifest); + + manifest[action] = { default_icon: { "16": path } }; + if (action == "sidebar_action") { + manifest[action].default_panel = "foo.html"; + } + await testIconPaths(path, manifest); + } + } +}); |