MCPcopy
hub / github.com/mozilla/multi-account-containers / buildDom

Function buildDom

test/common.js:24–60  ·  view source on GitHub ↗
({background = {}, popup = {}})

Source from the content-addressed store, hash-verified

22const manifestPath = path.resolve(path.join(__dirname, "../src/manifest.json"));
23
24const buildDom = async ({background = {}, popup = {}}) => {
25 background = {
26 ...background,
27 jsdom: {
28 ...background.jsom,
29 beforeParse(window) {
30 window.browser.permissions.getAll.resolves({permissions: ["bookmarks"]});
31 window.crypto = {
32 getRandomValues: arr => crypto.randomBytes(arr.length),
33 };
34 // By default, the mock contextMenus.remove() returns undefined;
35 // Let it return a Promise instead, so that .then() calls chained to
36 // it (in src/js/background/assignManager.js) do not fail.
37 window.browser.contextMenus.remove.resolves();
38 }
39 }
40 };
41
42 popup = {
43 ...popup,
44 jsdom: {
45 ...popup.jsdom,
46 pretendToBeVisual: true
47 }
48 };
49
50 const webExtension = await webExtensionsJSDOM.fromManifest(manifestPath, {
51 apiFake: true,
52 wiring: true,
53 sinon: global.sinon,
54 background,
55 popup
56 });
57
58 webExtension.browser = webExtension.background.browser;
59 return webExtension;
60};
61
62const buildBackgroundDom = background => {
63 return buildDom({

Callers 3

buildBackgroundDomFunction · 0.85
buildPopupDomFunction · 0.85
initializeWithTabFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected