Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue #128 - separate codepath for MV2 and MV3 #129

Merged
merged 1 commit into from
Dec 30, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions .github/workflows/running-tests-mv3.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
name: Tests MV3

on:
- push

jobs:
run-puppeteer:
name: Run tests MV3
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Setup Node
uses: actions/setup-node@v2

- name: Prepare dependencies
run: sudo apt-get install xvfb && npm install

- name: Run linters
run: npm run lint

- name: Run tests MV3
run: MV3=1 xvfb-run npm test
File renamed without changes.
29 changes: 29 additions & 0 deletions src/manifest/mv3.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
{
"background": {
"scripts": ["js/back.js"],
"persistent": false
},
"browser_action": {
"default_icon": "logo.png",
"default_popup": "popup.html"
},
"content_scripts": [ {
"all_frames": true,
"js": ["js/browser-polyfill.min.js", "js/jquery-1.7.2.min.js", "js/cs.js"],
"matches": [ "https://*/*", "http://*/*" ],
"run_at": "document_end"
} ],
"content_security_policy": "script-src 'self' 'unsafe-eval' https://ssl.google-analytics.com; object-src 'self'",
"description": "Extension for automating chromium browser, Create project -> Record -> Edit Automation -> Manage -> Play (MV3)",
"icons": {
"128": "css/icons/128x128.png",
"16": "css/icons/16x16.png",
"48": "css/icons/48x48.png"
},
"manifest_version": 2,
"name": "Chromium browser automation",
"options_page": "options.html",
"permissions": ["cookies", "http://*/*", "https://*/*", "tabs", "storage"],
"update_url": "https://clients2.google.com/service/update2/crx",
"version": "9.1.0"
}
8 changes: 8 additions & 0 deletions tests/tests/generic.js
Original file line number Diff line number Diff line change
Expand Up @@ -74,4 +74,12 @@ it("Sending highlight and unHighlight event should outline specific element acco
equal(await getStyle(query, "outline"), "");
});

if (process.env.MV3)
{
it("Run MV3 test", async() =>
{
equal(process.env.MV3, "1");
});
}

module.exports = {pageSetup};
8 changes: 7 additions & 1 deletion webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ const argv = require("minimist")(process.argv.slice(2));
const CopyPlugin = require('copy-webpack-plugin');
const {minify} = require("csso");
const {extname} = require("path");
const webpack = require("webpack");

const transformCss = (content, file) =>
{
Expand Down Expand Up @@ -57,7 +58,12 @@ module.exports =
{ from: "./src/js/jquery*.js", to: "js/jquery-1.7.2.min.js" },
{from: "node_modules/webextension-polyfill/dist/browser-polyfill.min.js",
to: "js" },
]})
{ from: `./src/manifest/${process.env.MV3 ? "mv3" : "mv2"}.json`,
to: "manifest.json" },
]}),
new webpack.EnvironmentPlugin({
MV3: process.env.MV3 || 0
})
]
};

Expand Down
Loading