Skip to content

Commit

Permalink
Update content-scripts-register-polyfill (#55)
Browse files Browse the repository at this point in the history
  • Loading branch information
fregante authored Jul 20, 2023
1 parent 90be2aa commit 8208a26
Show file tree
Hide file tree
Showing 9 changed files with 408 additions and 61 deletions.
7 changes: 7 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,13 @@ jobs:
- run: npm run build
- run: npm run demo:build

UnitTest:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- run: npm ci
- run: npm run vitest

Test:
runs-on: ubuntu-latest
strategy:
Expand Down
47 changes: 13 additions & 34 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "webext-dynamic-content-scripts",
"version": "9.2.2",
"version": "10.0.0-3",
"description": "WebExtension module: Automatically registers your `content_scripts` on domains added via `permission.request` or on `activeTab`",
"keywords": [
"contentscript",
Expand Down Expand Up @@ -61,7 +61,7 @@
]
},
"dependencies": {
"content-scripts-register-polyfill": "^3.2.2",
"content-scripts-register-polyfill": "^4.0.1",
"webext-additional-permissions": "^2.3.0",
"webext-content-scripts": "^2.5.3",
"webext-detect-page": "^4.0.1",
Expand Down
189 changes: 189 additions & 0 deletions source/__snapshots__/deduplicator.test.ts.snap
Original file line number Diff line number Diff line change
@@ -0,0 +1,189 @@
// Vitest Snapshot v1

exports[`excludeDuplicateFiles > safe > it should drop the whole block if if empty 1`] = `
[
{
"css": [
"first.css",
],
"js": [
"alpha.js",
],
},
]
`;

exports[`excludeDuplicateFiles > safe > it should remove duplicate scripts 1`] = `
[
{
"css": [],
"js": [
"first.js",
],
},
{
"css": [],
"js": [
"second.js",
],
},
]
`;

exports[`excludeDuplicateFiles > safe > it should remove duplicate scripts and stylesheets 1`] = `
[
{
"css": [
"first.css",
],
"js": [
"alpha.js",
],
},
{
"css": [
"second.css",
],
"js": [],
},
]
`;

exports[`excludeDuplicateFiles > safe > it should remove duplicate stylesheets 1`] = `
[
{
"css": [
"first.css",
],
"js": [],
},
{
"css": [
"second.css",
],
"js": [],
},
]
`;

exports[`excludeDuplicateFiles > warning > it should not warn when a differentiator is the same 1`] = `
[
{
"css": [],
"exclude_matches": [
"https://*/admin/*",
],
"js": [
"first.js",
],
},
]
`;

exports[`excludeDuplicateFiles > warning > it should warn when a differentiator is different 1`] = `
[
{
"css": [
"first.css",
],
"js": [],
},
{
"css": [
"second.css",
],
"js": [],
"run_at": "document_start",
},
]
`;

exports[`excludeDuplicateFiles > warning > it should warn when a differentiator is different 2`] = `
[
{
"css": [],
"js": [
"first.js",
"second.js",
],
"run_at": "document_end",
},
]
`;

exports[`excludeDuplicateFiles > warning > it should warn when a differentiator is different 3`] = `
[
{
"all_frames": true,
"css": [
"first.css",
],
"js": [],
},
{
"css": [
"second.css",
],
"js": [],
},
]
`;

exports[`excludeDuplicateFiles > warning 1`] = `
[MockFunction warn] {
"calls": [
[
"Duplicate file in the manifest content_scripts: first.css
More info: https://github.com/fregante/webext-dynamic-content-scripts/issues/62",
],
],
"results": [
{
"type": "return",
"value": undefined,
},
],
}
`;

exports[`excludeDuplicateFiles > warning 2`] = `
[MockFunction warn] {
"calls": [
[
"Duplicate file in the manifest content_scripts: first.js
More info: https://github.com/fregante/webext-dynamic-content-scripts/issues/62",
],
[
"Duplicate file in the manifest content_scripts: second.js
More info: https://github.com/fregante/webext-dynamic-content-scripts/issues/62",
],
],
"results": [
{
"type": "return",
"value": undefined,
},
{
"type": "return",
"value": undefined,
},
],
}
`;

exports[`excludeDuplicateFiles > warning 3`] = `
[MockFunction warn] {
"calls": [
[
"Duplicate file in the manifest content_scripts: first.css
More info: https://github.com/fregante/webext-dynamic-content-scripts/issues/62",
],
],
"results": [
{
"type": "return",
"value": undefined,
},
],
}
`;
30 changes: 10 additions & 20 deletions source/__snapshots__/lib.test.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,8 @@ exports[`init - registerContentScript > should register multiple manifest script
[
{
"allFrames": undefined,
"css": undefined,
"excludeMatches": [
"https://content-script.example.com/*",
],
"css": [],
"excludeMatches": undefined,
"js": [
"/script.js",
],
Expand All @@ -22,10 +20,8 @@ exports[`init - registerContentScript > should register multiple manifest script
[
{
"allFrames": undefined,
"css": undefined,
"excludeMatches": [
"https://content-script-extra.example.com/*",
],
"css": [],
"excludeMatches": undefined,
"js": [
"/otherScript.js",
],
Expand Down Expand Up @@ -55,10 +51,8 @@ exports[`init - registerContentScript > should register the manifest scripts on
[
{
"allFrames": undefined,
"css": undefined,
"excludeMatches": [
"https://content-script.example.com/*",
],
"css": [],
"excludeMatches": undefined,
"js": [
"/script.js",
],
Expand All @@ -71,10 +65,8 @@ exports[`init - registerContentScript > should register the manifest scripts on
[
{
"allFrames": undefined,
"css": undefined,
"excludeMatches": [
"https://content-script.example.com/*",
],
"css": [],
"excludeMatches": undefined,
"js": [
"/script.js",
],
Expand Down Expand Up @@ -104,10 +96,8 @@ exports[`init - registerContentScript > should register the manifest scripts on
[
{
"allFrames": undefined,
"css": undefined,
"excludeMatches": [
"https://content-script.example.com/*",
],
"css": [],
"excludeMatches": undefined,
"js": [
"/script.js",
],
Expand Down
Loading

0 comments on commit 8208a26

Please sign in to comment.