diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 19:33:14 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 19:33:14 +0000 |
commit | 36d22d82aa202bb199967e9512281e9a53db42c9 (patch) | |
tree | 105e8c98ddea1c1e4784a60a5a6410fa416be2de /devtools/client/application/test/node/fixtures | |
parent | Initial commit. (diff) | |
download | firefox-esr-36d22d82aa202bb199967e9512281e9a53db42c9.tar.xz firefox-esr-36d22d82aa202bb199967e9512281e9a53db42c9.zip |
Adding upstream version 115.7.0esr.upstream/115.7.0esr
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'devtools/client/application/test/node/fixtures')
-rw-r--r-- | devtools/client/application/test/node/fixtures/data/constants.js | 312 |
1 files changed, 312 insertions, 0 deletions
diff --git a/devtools/client/application/test/node/fixtures/data/constants.js b/devtools/client/application/test/node/fixtures/data/constants.js new file mode 100644 index 0000000000..795324525c --- /dev/null +++ b/devtools/client/application/test/node/fixtures/data/constants.js @@ -0,0 +1,312 @@ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +"use strict"; + +// NOTE: worker state values are defined in an enum in nsIServiceWorkerManager +// https://searchfox.org/mozilla-central/source/dom/interfaces/base/nsIServiceWorkerManager.idl + +const EMPTY_WORKER_LIST = []; + +const WORKER_RUNNING = { + id: "id-worker-1-example", + workerDescriptorFront: true, + url: "http://example.com/worker.js", + state: 4, + stateText: "activated", +}; + +const WORKER_STOPPED = { + id: "id-worker-1-example", + workerDescriptorFront: false, + url: "http://example.com/worker.js", + state: 4, + stateText: "activated", +}; + +const WORKER_WAITING = { + id: "id-worker-1-example", + workerDescriptorFront: false, + url: "http://example.com/worker.js", + state: 2, + stateText: "installed", +}; + +const REGISTRATION_SINGLE_WORKER = { + id: "id-reg-1-example", + scope: "SCOPE 123", + registrationFront: "", + workers: [ + { + id: "id-worker-1-example", + workerDescriptorFront: "", + url: "http://example.com/worker.js", + state: 4, + stateText: "activated", + }, + ], +}; + +const REGISTRATION_MULTIPLE_WORKERS = { + id: "id-reg-1-example", + scope: "SCOPE 123", + registrationFront: "", + workers: [ + { + id: "id-worker-1-example", + workerDescriptorFront: "", + url: "http://example.com/worker.js", + state: 4, + stateText: "activated", + }, + { + id: "id-worker-2-example", + workerDescriptorFront: "", + url: "http://example.com/worker.js", + state: 2, + stateText: "installed", + }, + ], +}; + +const SINGLE_WORKER_DEFAULT_DOMAIN_LIST = [ + { + id: "id-reg-1-example", + scope: "SCOPE 123", + registrationFront: "", + workers: [ + { + id: "id-worker-1-example", + workerDescriptorFront: "", + url: "http://example.com/worker.js", + state: 4, + stateText: "activated", + }, + ], + }, +]; + +const SINGLE_WORKER_DIFFERENT_DOMAIN_LIST = [ + { + id: "id-reg-1-example", + scope: "SCOPE 123", + registrationFront: "", + workers: [ + { + id: "id-worker-1-example", + workerDescriptorFront: "", + url: "http://different-example.com/worker.js", + state: 4, + stateText: "activated", + }, + ], + }, +]; + +const MULTIPLE_WORKER_LIST = [ + { + id: "id-reg-1-example", + scope: "SCOPE1", + registrationFront: "", + workers: [ + { + id: "id-worker-1-example", + workerDescriptorFront: "", + url: "http://example.com/worker.js", + state: 4, + stateText: "activated", + }, + ], + }, + { + id: "id-reg-1-example", + scope: "SCOPE2", + registrationFront: "", + workers: [ + { + id: "id-worker-2-example", + workerDescriptorFront: "", + url: "http://example.com/worker.js", + state: 2, + stateText: "installed", + }, + ], + }, + { + id: "id-reg-3-example", + scope: "SCOPE3", + registrationFront: "", + workers: [ + { + id: "id-worker-3-example", + workerDescriptorFront: "", + url: "http://example.com/worker.js", + state: 4, + stateText: "activated", + }, + ], + }, +]; + +const MULTIPLE_WORKER_MIXED_DOMAINS_LIST = [ + { + id: "id-reg-1-example", + scope: "SCOPE1", + registrationFront: "", + workers: [ + { + id: "id-worker-1-example", + workerDescriptorFront: "", + url: "http://example.com/worker.js", + state: 4, + stateText: "activated", + }, + ], + }, + { + id: "id-reg-2-example", + scope: "SCOPE2", + registrationFront: "", + workers: [ + { + id: "id-worker-2-example", + workerDescriptorFront: "", + url: "http://example.com/worker.js", + state: 4, + stateText: "activated", + }, + ], + }, + { + id: "id-reg-3-example", + scope: "SCOPE3", + registrationFront: "", + workers: [ + { + id: "id-worker-3-example", + workerDescriptorFront: "", + url: "http://different-example.com/worker.js", + state: 4, + stateText: "activated", + }, + ], + }, +]; + +// props for a simple manifest +const MANIFEST_SIMPLE = { + icons: [ + { + key: { sizes: "1x1", contentType: "image/png" }, + value: { src: "something.png", purpose: "any" }, + type: "icon", + }, + ], + identity: [{ key: "name", value: "foo", type: "string" }], + presentation: [ + { key: "lorem", value: "ipsum", type: "string" }, + { key: "foo", value: "bar", type: "string" }, + ], + validation: [{ level: "warning", message: "This is a warning" }], +}; + +// props for a manifest with string values +const MANIFEST_STRING_MEMBERS = { + icons: [], + identity: [{ key: "name", value: "foo", type: "string" }], + presentation: [], + validation: [], +}; + +// props for a manifest with color values +const MANIFEST_COLOR_MEMBERS = { + icons: [], + identity: [], + presentation: [ + { key: "background_color", value: "red", type: "color" }, + { key: "theme_color", value: "rgb(0, 0, 0)", type: "color" }, + ], + validation: [], +}; + +// props for a manifest with icon values +const MANIFEST_ICON_MEMBERS = { + icons: [ + { + key: { sizes: "1x1", contentType: "image/png" }, + value: { src: "something.png", purpose: "any" }, + type: "icon", + }, + { + key: { sizes: "", contentType: "" }, + value: { src: "something.svg", purpose: "any maskable" }, + type: "icon", + }, + ], + identity: [], + presentation: [], + validation: [], +}; + +// props for a manifest with values that have an unrecognized type +const MANIFEST_UNKNOWN_TYPE_MEMBERS = { + icons: [], + identity: [{ key: "lorem", value: "ipsum", type: "foo" }], + presentation: [], + validation: [], +}; + +// props for a manifest with url values +const MANIFEST_URL_MEMBERS = { + icons: [], + identity: [], + presentation: [ + { key: "start_url", value: "https://example.com/", type: "url" }, + { key: "scope", value: "https://example.com/", type: "url" }, + ], +}; + +const MANIFEST_WITH_ISSUES = { + icons: [], + identity: [{ key: "name", value: "foo", type: "string" }], + presentation: [ + { key: "lorem", value: "ipsum", type: "string" }, + { key: "foo", value: "bar", type: "string" }, + ], + validation: [{ level: "warning", message: "This is a warning" }], +}; + +// props for a manifest with no validation issues +const MANIFEST_NO_ISSUES = { + icons: [], + identity: [{ key: "name", value: "foo", type: "string" }], + presentation: [ + { key: "lorem", value: "ipsum", type: "string" }, + { key: "foo", value: "bar", type: "string" }, + ], + validation: [], +}; + +module.exports = { + // service worker related fixtures + EMPTY_WORKER_LIST, + MULTIPLE_WORKER_LIST, + MULTIPLE_WORKER_MIXED_DOMAINS_LIST, + REGISTRATION_MULTIPLE_WORKERS, + REGISTRATION_SINGLE_WORKER, + SINGLE_WORKER_DEFAULT_DOMAIN_LIST, + SINGLE_WORKER_DIFFERENT_DOMAIN_LIST, + WORKER_RUNNING, + WORKER_STOPPED, + WORKER_WAITING, + // manifest related fixtures + MANIFEST_NO_ISSUES, + MANIFEST_WITH_ISSUES, + MANIFEST_SIMPLE, + MANIFEST_COLOR_MEMBERS, + MANIFEST_ICON_MEMBERS, + MANIFEST_STRING_MEMBERS, + MANIFEST_UNKNOWN_TYPE_MEMBERS, + MANIFEST_URL_MEMBERS, +}; |