diff options
author | Yuchen Pei <hi@ypei.me> | 2022-10-13 11:50:15 +1100 |
---|---|---|
committer | Yuchen Pei <hi@ypei.me> | 2022-10-13 11:50:15 +1100 |
commit | 55c748d6a50af4e93b138bf73e37c71f946fab19 (patch) | |
tree | 8f78d7535e741cf51f15bac73de5c8de4c97cb4b | |
parent | b849b8d461479cf6530c77b97b094807840ce0d7 (diff) |
minor fix of noscript.js, and make it show up in console debugger
-rw-r--r-- | content/noscript.js | 20 | ||||
-rw-r--r-- | html/display_panel/content/main_panel.js | 4 | ||||
-rw-r--r-- | main_background.js | 4 | ||||
-rw-r--r-- | test/spec/LibreJSSpec.js | 12 |
4 files changed, 29 insertions, 11 deletions
diff --git a/content/noscript.js b/content/noscript.js index 9ea2f08..9cf1ac1 100644 --- a/content/noscript.js +++ b/content/noscript.js @@ -20,16 +20,20 @@ */ "use strict"; { - browser.runtime.onMessage.addListener(async m => { + const showNoScript = () => { + for (const noscript of document.querySelectorAll( + 'noscript:not([data-librejs-nodisplay])')) { + const replacement = document.createElement('span'); + replacement.innerHTML = noscript.innerHTML; + noscript.replaceWith(replacement); + } + }; + + browser.runtime.onMessage.addListener(m => { if (m.action === 'forceNoscript') { try { - debug("Received message", m); - for (const noscript of document.querySelectorAll( - 'noscript:not([data-librejs-nodisplay])')) { - const replacement = document.createElement('span'); - replacement.innerHTML = noscript.innerHTML; - noscript.replaceWith(replacement); - } + console.log("Received message", m); + showNoScript(); } catch (e) { console.error(e); } diff --git a/html/display_panel/content/main_panel.js b/html/display_panel/content/main_panel.js index dc3ee2d..e2988d6 100644 --- a/html/display_panel/content/main_panel.js +++ b/html/display_panel/content/main_panel.js @@ -93,8 +93,8 @@ document.querySelector("#complain").onclick = _ => { close(); } -document.querySelector("#force-noscript").onclick = async _ => { - await browser.tabs.sendMessage(currentReport.tabId, { +document.querySelector("#force-noscript").onclick = _ => { + browser.tabs.sendMessage(currentReport.tabId, { action: 'forceNoscript' }); document.querySelector("#force-noscript").disabled = true; diff --git a/main_background.js b/main_background.js index 87b80ae..ab70d00 100644 --- a/main_background.js +++ b/main_background.js @@ -891,7 +891,9 @@ async function initAddon() { editHtml, handleScript, ExternalLicenses, - ListManager, ListStore, Storage, + ListManager, + ListStore, + Storage }; // create or focus the autotest tab if it's a debugging session if ((await browser.management.getSelf()).installType === 'development') { diff --git a/test/spec/LibreJSSpec.js b/test/spec/LibreJSSpec.js index 7828bcb..70ec339 100644 --- a/test/spec/LibreJSSpec.js +++ b/test/spec/LibreJSSpec.js @@ -257,6 +257,18 @@ describe('LibreJS\' components', () => { }); }); + describe('FIXME: dummy test to get noscript.js displayed in the console debugger', () => { + beforeAll(async () => { + await browser.tabs.executeScript(tab.id, { + file: '/content/noscript.js' + }); + }); + + it('IGNORE ME', () => { + expect(1).toBe(1); + }); + }); + describe('The external (Web Labels) license checker', () => { let { ExternalLicenses } = LibreJS; let check; |