tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

constants.js (7253B)


      1 /* This Source Code Form is subject to the terms of the Mozilla Public
      2 * License, v. 2.0. If a copy of the MPL was not distributed with this
      3 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
      4 
      5 "use strict";
      6 
      7 // NOTE: worker state values are defined in an enum in nsIServiceWorkerManager
      8 // https://searchfox.org/mozilla-central/source/dom/interfaces/base/nsIServiceWorkerManager.idl
      9 
     10 const EMPTY_WORKER_LIST = [];
     11 
     12 const WORKER_RUNNING = {
     13  id: "id-worker-1-example",
     14  workerDescriptorFront: true,
     15  url: "http://example.com/worker.js",
     16  state: 4,
     17  stateText: "activated",
     18 };
     19 
     20 const WORKER_STOPPED = {
     21  id: "id-worker-1-example",
     22  workerDescriptorFront: false,
     23  url: "http://example.com/worker.js",
     24  state: 4,
     25  stateText: "activated",
     26 };
     27 
     28 const WORKER_WAITING = {
     29  id: "id-worker-1-example",
     30  workerDescriptorFront: false,
     31  url: "http://example.com/worker.js",
     32  state: 2,
     33  stateText: "installed",
     34 };
     35 
     36 const REGISTRATION_SINGLE_WORKER = {
     37  id: "id-reg-1-example",
     38  scope: "SCOPE 123",
     39  registrationFront: "",
     40  workers: [
     41    {
     42      id: "id-worker-1-example",
     43      workerDescriptorFront: "",
     44      url: "http://example.com/worker.js",
     45      state: 4,
     46      stateText: "activated",
     47    },
     48  ],
     49 };
     50 
     51 const REGISTRATION_MULTIPLE_WORKERS = {
     52  id: "id-reg-1-example",
     53  scope: "SCOPE 123",
     54  registrationFront: "",
     55  workers: [
     56    {
     57      id: "id-worker-1-example",
     58      workerDescriptorFront: "",
     59      url: "http://example.com/worker.js",
     60      state: 4,
     61      stateText: "activated",
     62    },
     63    {
     64      id: "id-worker-2-example",
     65      workerDescriptorFront: "",
     66      url: "http://example.com/worker.js",
     67      state: 2,
     68      stateText: "installed",
     69    },
     70  ],
     71 };
     72 
     73 const SINGLE_WORKER_DEFAULT_DOMAIN_LIST = [
     74  {
     75    id: "id-reg-1-example",
     76    scope: "SCOPE 123",
     77    registrationFront: "",
     78    workers: [
     79      {
     80        id: "id-worker-1-example",
     81        workerDescriptorFront: "",
     82        url: "http://example.com/worker.js",
     83        state: 4,
     84        stateText: "activated",
     85      },
     86    ],
     87  },
     88 ];
     89 
     90 const SINGLE_WORKER_DIFFERENT_DOMAIN_LIST = [
     91  {
     92    id: "id-reg-1-example",
     93    scope: "SCOPE 123",
     94    registrationFront: "",
     95    workers: [
     96      {
     97        id: "id-worker-1-example",
     98        workerDescriptorFront: "",
     99        url: "http://different-example.com/worker.js",
    100        state: 4,
    101        stateText: "activated",
    102      },
    103    ],
    104  },
    105 ];
    106 
    107 const MULTIPLE_WORKER_LIST = [
    108  {
    109    id: "id-reg-1-example",
    110    scope: "SCOPE1",
    111    registrationFront: "",
    112    workers: [
    113      {
    114        id: "id-worker-1-example",
    115        workerDescriptorFront: "",
    116        url: "http://example.com/worker.js",
    117        state: 4,
    118        stateText: "activated",
    119      },
    120    ],
    121  },
    122  {
    123    id: "id-reg-1-example",
    124    scope: "SCOPE2",
    125    registrationFront: "",
    126    workers: [
    127      {
    128        id: "id-worker-2-example",
    129        workerDescriptorFront: "",
    130        url: "http://example.com/worker.js",
    131        state: 2,
    132        stateText: "installed",
    133      },
    134    ],
    135  },
    136  {
    137    id: "id-reg-3-example",
    138    scope: "SCOPE3",
    139    registrationFront: "",
    140    workers: [
    141      {
    142        id: "id-worker-3-example",
    143        workerDescriptorFront: "",
    144        url: "http://example.com/worker.js",
    145        state: 4,
    146        stateText: "activated",
    147      },
    148    ],
    149  },
    150 ];
    151 
    152 const MULTIPLE_WORKER_MIXED_DOMAINS_LIST = [
    153  {
    154    id: "id-reg-1-example",
    155    scope: "SCOPE1",
    156    registrationFront: "",
    157    workers: [
    158      {
    159        id: "id-worker-1-example",
    160        workerDescriptorFront: "",
    161        url: "http://example.com/worker.js",
    162        state: 4,
    163        stateText: "activated",
    164      },
    165    ],
    166  },
    167  {
    168    id: "id-reg-2-example",
    169    scope: "SCOPE2",
    170    registrationFront: "",
    171    workers: [
    172      {
    173        id: "id-worker-2-example",
    174        workerDescriptorFront: "",
    175        url: "http://example.com/worker.js",
    176        state: 4,
    177        stateText: "activated",
    178      },
    179    ],
    180  },
    181  {
    182    id: "id-reg-3-example",
    183    scope: "SCOPE3",
    184    registrationFront: "",
    185    workers: [
    186      {
    187        id: "id-worker-3-example",
    188        workerDescriptorFront: "",
    189        url: "http://different-example.com/worker.js",
    190        state: 4,
    191        stateText: "activated",
    192      },
    193    ],
    194  },
    195 ];
    196 
    197 // props for a simple manifest
    198 const MANIFEST_SIMPLE = {
    199  icons: [
    200    {
    201      key: { sizes: "1x1", contentType: "image/png" },
    202      value: { src: "something.png", purpose: "any" },
    203      type: "icon",
    204    },
    205  ],
    206  identity: [{ key: "name", value: "foo", type: "string" }],
    207  presentation: [
    208    { key: "lorem", value: "ipsum", type: "string" },
    209    { key: "foo", value: "bar", type: "string" },
    210  ],
    211  validation: [{ level: "warning", message: "This is a warning" }],
    212 };
    213 
    214 // props for a manifest with string values
    215 const MANIFEST_STRING_MEMBERS = {
    216  icons: [],
    217  identity: [{ key: "name", value: "foo", type: "string" }],
    218  presentation: [],
    219  validation: [],
    220 };
    221 
    222 // props for a manifest with color values
    223 const MANIFEST_COLOR_MEMBERS = {
    224  icons: [],
    225  identity: [],
    226  presentation: [
    227    { key: "background_color", value: "red", type: "color" },
    228    { key: "theme_color", value: "rgb(0, 0, 0)", type: "color" },
    229  ],
    230  validation: [],
    231 };
    232 
    233 // props for a manifest with icon values
    234 const MANIFEST_ICON_MEMBERS = {
    235  icons: [
    236    {
    237      key: { sizes: "1x1", contentType: "image/png" },
    238      value: { src: "something.png", purpose: "any" },
    239      type: "icon",
    240    },
    241    {
    242      key: { sizes: "", contentType: "" },
    243      value: { src: "something.svg", purpose: "any maskable" },
    244      type: "icon",
    245    },
    246  ],
    247  identity: [],
    248  presentation: [],
    249  validation: [],
    250 };
    251 
    252 // props for a manifest with values that have an unrecognized type
    253 const MANIFEST_UNKNOWN_TYPE_MEMBERS = {
    254  icons: [],
    255  identity: [{ key: "lorem", value: "ipsum", type: "foo" }],
    256  presentation: [],
    257  validation: [],
    258 };
    259 
    260 // props for a manifest with url values
    261 const MANIFEST_URL_MEMBERS = {
    262  icons: [],
    263  identity: [],
    264  presentation: [
    265    { key: "start_url", value: "https://example.com/", type: "url" },
    266    { key: "scope", value: "https://example.com/", type: "url" },
    267  ],
    268 };
    269 
    270 const MANIFEST_WITH_ISSUES = {
    271  icons: [],
    272  identity: [{ key: "name", value: "foo", type: "string" }],
    273  presentation: [
    274    { key: "lorem", value: "ipsum", type: "string" },
    275    { key: "foo", value: "bar", type: "string" },
    276  ],
    277  validation: [{ level: "warning", message: "This is a warning" }],
    278 };
    279 
    280 // props for a manifest with no validation issues
    281 const MANIFEST_NO_ISSUES = {
    282  icons: [],
    283  identity: [{ key: "name", value: "foo", type: "string" }],
    284  presentation: [
    285    { key: "lorem", value: "ipsum", type: "string" },
    286    { key: "foo", value: "bar", type: "string" },
    287  ],
    288  validation: [],
    289 };
    290 
    291 module.exports = {
    292  // service worker related fixtures
    293  EMPTY_WORKER_LIST,
    294  MULTIPLE_WORKER_LIST,
    295  MULTIPLE_WORKER_MIXED_DOMAINS_LIST,
    296  REGISTRATION_MULTIPLE_WORKERS,
    297  REGISTRATION_SINGLE_WORKER,
    298  SINGLE_WORKER_DEFAULT_DOMAIN_LIST,
    299  SINGLE_WORKER_DIFFERENT_DOMAIN_LIST,
    300  WORKER_RUNNING,
    301  WORKER_STOPPED,
    302  WORKER_WAITING,
    303  // manifest related fixtures
    304  MANIFEST_NO_ISSUES,
    305  MANIFEST_WITH_ISSUES,
    306  MANIFEST_SIMPLE,
    307  MANIFEST_COLOR_MEMBERS,
    308  MANIFEST_ICON_MEMBERS,
    309  MANIFEST_STRING_MEMBERS,
    310  MANIFEST_UNKNOWN_TYPE_MEMBERS,
    311  MANIFEST_URL_MEMBERS,
    312 };