From c82d0a82f4246667e1ac1238be4121fcaffdde6a Mon Sep 17 00:00:00 2001 From: hackademix Date: Tue, 2 Oct 2018 22:21:50 +0200 Subject: Work around for documentUrl = tab.url = about:blank if tests are launched from XPI --- test/spec/LibreJSSpec.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/test/spec/LibreJSSpec.js b/test/spec/LibreJSSpec.js index b2ca40e..eba69b5 100644 --- a/test/spec/LibreJSSpec.js +++ b/test/spec/LibreJSSpec.js @@ -43,11 +43,12 @@ describe("LibreJS' components", () => { let unknownLicensed = `// @license ${unknownLicense.id} ${unknownLicense.magnet}\n${nontrivial}\n// @license-end`; let malformedLicensed = `// @license\n${nontrivial}`; - let tab; + let tab, documentUrl; beforeAll(async () => { let url = browser.extension.getURL("/test/resources/index.html"); tab = (await browser.tabs.query({url}))[0] || (await browser.tabs.create({url})); + documentUrl = url; }); describe("The external script source processor", () => { @@ -56,7 +57,7 @@ describe("LibreJS' components", () => { let processScript = async (source, whitelisted = false) => await LibreJS.handle_script({ text: source, - request: {url, tabId: tab.id, documentUrl: tab.url, frameId: 0}, + request: {url, tabId: tab.id, documentUrl, frameId: 0}, }, whitelisted); it("should accept whitelisted scripts", async () => { @@ -175,7 +176,6 @@ describe("LibreJS' components", () => { let check; beforeAll(async () => { - let documentUrl = tab.url; let args = {tabId: tab.id, frameId: 0, documentUrl}; let resolve = url => new URL(url, documentUrl).href; check = async url => await ExternalLicenses.check(Object.assign({url: resolve(url)}, args)); -- cgit v1.2.3