summaryrefslogtreecommitdiffstats
path: root/devtools/client/application/test/node/fixtures/data/constants.js
blob: 795324525cc5cc080d973751674694625b35a72e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
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,
};