aboutsummaryrefslogtreecommitdiff
path: root/test/spec/LibreJSSpec.js
diff options
context:
space:
mode:
authorYuchen Pei <hi@ypei.me>2022-10-13 13:03:45 +1100
committerYuchen Pei <hi@ypei.me>2022-10-13 13:03:45 +1100
commit63995b6c6f434361a4a680f959bacbcd4a083795 (patch)
tree836082692b8c4a682a6603a93718d10379fdd8cc /test/spec/LibreJSSpec.js
parent55c748d6a50af4e93b138bf73e37c71f946fab19 (diff)
Adding test for noscript.jsnoscript-toggle
Diffstat (limited to 'test/spec/LibreJSSpec.js')
-rw-r--r--test/spec/LibreJSSpec.js24
1 files changed, 20 insertions, 4 deletions
diff --git a/test/spec/LibreJSSpec.js b/test/spec/LibreJSSpec.js
index 70ec339..459c8b4 100644
--- a/test/spec/LibreJSSpec.js
+++ b/test/spec/LibreJSSpec.js
@@ -50,7 +50,6 @@ describe('LibreJS\' components', () => {
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 whitelist/blacklist manager', () => {
@@ -257,15 +256,32 @@ describe('LibreJS\' components', () => {
});
});
- describe('FIXME: dummy test to get noscript.js displayed in the console debugger', () => {
+ describe('User forces noscript element content', () => {
beforeAll(async () => {
await browser.tabs.executeScript(tab.id, {
file: '/content/noscript.js'
});
});
- it('IGNORE ME', () => {
- expect(1).toBe(1);
+ it('forces noscript element content from content script', async () => {
+ const [numNsBefore] = await browser.tabs.executeScript(tab.id, {
+ code: 'document.querySelectorAll("noscript").length'
+ });
+ expect(numNsBefore).toBe(1);
+ const contentBefore = await browser.tabs.executeScript(tab.id, {
+ code: 'document.querySelectorAll("noscript")[0].innerHTML'
+ });
+ await browser.tabs.sendMessage(tab.id, {
+ action: 'forceNoscript'
+ });
+ const [numNsAfter] = await browser.tabs.executeScript(tab.id, {
+ code: 'document.querySelectorAll("noscript").length'
+ });
+ expect(numNsAfter).toBe(0);
+ const contentAfter = await browser.tabs.executeScript(tab.id, {
+ code: 'document.querySelectorAll("span[data-librejs-show-noscript]")[0].innerHTML'
+ });
+ expect(contentBefore).toEqual(contentAfter);
});
});