({background = {}, popup = {}})
| 22 | const manifestPath = path.resolve(path.join(__dirname, "../src/manifest.json")); |
| 23 | |
| 24 | const 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 | |
| 62 | const buildBackgroundDom = background => { |
| 63 | return buildDom({ |
no outgoing calls
no test coverage detected