forked from mozilla/testpilot
-
Notifications
You must be signed in to change notification settings - Fork 0
/
background.js
38 lines (31 loc) · 1.12 KB
/
background.js
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
/* 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/. */
/* global browser */
import PubSub from 'pubsub-js';
import { log, debug } from './lib/utils';
import { setupStorage } from './lib/storage';
import { setupEnvironment } from './lib/environments';
import { setupContent } from './lib/content';
import { setupBrowserAction } from './lib/browserAction';
import { setupMetrics } from './lib/metrics';
import { setupBootstrapPort, sendBootstrapMessage } from './lib/bootstrap';
PubSub.immediateExceptions = true;
function setup() {
setupDebug()
.then(setupStorage)
.then(setupBrowserAction)
.then(setupMetrics)
.then(setupEnvironment)
.then(setupContent)
.then(setupBootstrapPort)
.then(() => sendBootstrapMessage('ready'))
.catch(err => log('init error', err));
}
async function setupDebug() {
if (!debug) return;
['bootstrap', 'webExtension'].forEach(root =>
PubSub.subscribe(root, (message, data) => log('pubsub', message, data))
);
}
setup();