Skip to content

Commit

Permalink
Update the build etc scripts and docs to reflect the Chrome MV3 migra…
Browse files Browse the repository at this point in the history
…tion

We are migrating Chrome extension users over onto the manifest
v3 (MV3) build, in time for the June deadline[1]. Once that's
finished, only Firefox users will remain on the MV2 build. Let's
rename the build, release, and test scripts and related documentation
to reflect that change.

Note: We unfortunately can't remove the chrome-mv2 build target
      entirely, since Playwright does not yet support testing Firefox
      extensions[2]. To test the MV2 code via the integration tests,
      using the chrome-mv2 build is the best we can do for now.

1 - https://developer.chrome.com/blog/resuming-the-transition-to-mv3/
2 - microsoft/playwright#7297
  • Loading branch information
kzar committed Apr 30, 2024
1 parent f65b74f commit cdea87f
Show file tree
Hide file tree
Showing 12 changed files with 109 additions and 126 deletions.
10 changes: 5 additions & 5 deletions .github/workflows/beta.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ on:
workflow_dispatch:

jobs:
chrome_mv3_beta:
chrome_beta:
runs-on: ubuntu-latest

steps:
Expand All @@ -22,7 +22,7 @@ jobs:
run: |
npm run bundle-config
node scripts/bumpVersion.js $(date "+%Y.%m.%d")
echo "VERSION=$(jq -r .version ./browsers/chrome-mv3/manifest.json)" >> $GITHUB_ENV
echo "VERSION=$(jq -r .version ./browsers/chrome/manifest.json)" >> $GITHUB_ENV
- name: Commit config and version updates
uses: stefanzweifel/git-auto-commit-action@8621497c8c39c72f3e2a999a26b4ca1b5058a842
Expand All @@ -31,14 +31,14 @@ jobs:
create_branch: true
branch: "release/beta/${{ env.VERSION }}"

- name: Build Chrome MV3 Beta
- name: Build Chrome Beta
run: |
npm run beta-chrome-mv3
npm run beta-chrome
- name: Publish to Chrome Store
env:
CWS_CLIENT_ID: ${{ secrets.CWS_CLIENT_ID }}
CWS_CLIENT_SECRET: ${{ secrets.CWS_CLIENT_SECRET }}
CWS_REFRESH_TOKEN: ${{ secrets.CWS_REFRESH_TOKEN }}
run: |
bash ./scripts/chrome-store-publish.sh ${{ secrets.CWS_BETA_EXTENSION_ID }} ./build/chrome-mv3/release/chrome-mv3-release-*.zip
bash ./scripts/chrome-store-publish.sh ${{ secrets.CWS_BETA_EXTENSION_ID }} ./build/chrome/release/chrome-release-*.zip
4 changes: 2 additions & 2 deletions .github/workflows/checks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ jobs:
matrix:
version: [18]
os: [ubuntu-latest, macos-latest]
target: ['release-firefox', 'release-chrome', 'release-chrome-mv3']
target: ['release-firefox', 'release-chrome']
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4
Expand All @@ -49,7 +49,7 @@ jobs:
strategy:
fail-fast: false
matrix:
test: [playwright, playwright-mv3]
test: [playwright, playwright-mv2]
shard: [1/4, 2/4, 3/4, 4/4]
steps:
- uses: actions/checkout@v4
Expand Down
5 changes: 0 additions & 5 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,6 @@ jobs:
run: |
npm run release-chrome
- name: Build Chrome MV3
run: |
npm run release-chrome-mv3
- name: Package Firefox
run: |
cd build/firefox/release && web-ext build
Expand All @@ -61,7 +57,6 @@ jobs:
files: |
./build/firefox/release/web-ext-artifacts/*.zip
./build/chrome/release/*.zip
./build/chrome-mv3/release/*.zip
- name: Asana Workflow
env:
Expand Down
6 changes: 1 addition & 5 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,10 +48,6 @@ Most bug fixes are handled internally, but we will except pull requests for bug
2. Load the extension in Chrome from the `build/chrome/dev` directory
[Getting Started: Building a Chrome Extension - Google Chrome](https://developer.chrome.com/extensions/getstarted#unpacked)

- Chrome MV3 (Work in progress, not working yet.)
1. Run `npm run dev-chrome-mv3`
2. Load the extension in Chrome from the `build/chrome-mv3/dev` directory

Note: Development builds of the extension have a few differences from the release builds and are more convenient to use during development:
- The background page/ServiceWorker has an `dbg` Object that provides access to some of the extension's internal configuration and other state.
- Click to Load placeholders are created with an open shadowRoot, instead of a closed shadowRoot. This allows the integration tests to click the placeholder's buttons reliably.
Expand Down Expand Up @@ -118,4 +114,4 @@ The extension imports several DDG-owned modules (see [package.json](https://gith

### Testing
- Unit tests: `npm test` (full docs [here](./unit-test/README.md))
- Integration tests: `npm run playwright` (full docs [here](./integration-test/README.md))
- Integration tests: `npm run playwright` and `npm run playwright-mv2` (full docs [here](./integration-test/README.md))
34 changes: 14 additions & 20 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
###--- Shared variables ---###
# Browser type (browser, but "chrome-mv3" becomes "chrome").
# Browser type (browser, but "chrome-mv2" becomes "chrome").
BROWSER_TYPE = $(browser)
ifeq ('$(browser)','chrome-mv3')
ifeq ('$(browser)','chrome-mv2')
BROWSER_TYPE = chrome
endif

Expand All @@ -28,16 +28,16 @@ endif
# - Add check that browser+type are set when necessary.

## release: Create a release build for a platform in build/$(browser)/release
## specify browser=(chrome|chrome-mv3|firefox) type=release
## specify browser=(chrome|chrome-mv2|firefox) type=release
release: clean npm copy build

.PHONY: release

## chrome-mv3-beta: Create a beta Chrome MV3 build in build/$(browser)/release
## specify browser=chrome-mv3 type=release
chrome-mv3-beta: release chrome-mv3-beta-zip
## chrome-beta: Create a beta Chrome build in build/$(browser)/release
## specify browser=chrome type=release
chrome-beta: release chrome-beta-zip

.PHONY: chrome-mv3-beta
.PHONY: chrome-beta

## beta-firefox: Create a beta Firefox build in build/$(browser)/release
## specify browser=firefox type=release
Expand All @@ -47,15 +47,15 @@ beta-firefox: release beta-firefox-zip

## dev: Create a debug build for a platform in build/$(browser)/dev.
## Pass reloader=0 to disable automatic extension reloading.
## specify browser=(chrome|chrome-mv3|firefox) type=dev [reloader=1]
## specify browser=(chrome|chrome-mv2|firefox) type=dev [reloader=1]
dev: copy build $(BUILD_DIR)/buildtime.txt

.PHONY: dev

## watch: Create a debug build for a platform in build/$(browser)/dev, and keep
## it up to date as files are changed.
## Pass reloader=0 to disable automatic extension reloading.
## specify browser=(chrome|chrome-mv3|firefox) type=dev [reloader=1]
## specify browser=(chrome|chrome-mv2|firefox) type=dev [reloader=1]
MAKE = make $(type) browser=$(browser) type=$(type)
watch:
$(MAKE)
Expand Down Expand Up @@ -99,20 +99,14 @@ chrome-release-zip:

.PHONY: chrome-release-zip

chrome-mv3-release-zip:
rm -f build/chrome-mv3/release/chrome-mv3-release-*.zip
cd build/chrome-mv3/release/ && zip -rq chrome-mv3-release-$(shell date +"%Y%m%d_%H%M%S").zip *

.PHONY: chrome-mv3-release-zip

chrome-mv3-beta-zip: prepare-chrome-beta chrome-mv3-release-zip
chrome-beta-zip: prepare-chrome-beta chrome-release-zip


.PHONY: chrome-mv3-beta-zip
.PHONY: chrome-beta-zip

prepare-chrome-beta:
sed 's/__MSG_appName__/DuckDuckGo Privacy Essentials MV3 Beta/' ./browsers/chrome-mv3/manifest.json > build/chrome-mv3/release/manifest.json
cp -r build/chrome-mv3/release/img/beta/* build/chrome-mv3/release/img/
sed 's/__MSG_appName__/DuckDuckGo Privacy Essentials Beta/' ./browsers/chrome/manifest.json > build/chrome/release/manifest.json
cp -r build/chrome/release/img/beta/* build/chrome/release/img/

.PHONY: prepare-chrome-beta

Expand Down Expand Up @@ -292,7 +286,7 @@ build/.smarter_encryption.txt:
$(BUILD_DIR)/data/bundled/smarter-encryption-rules.json: build/.smarter_encryption.txt
npx ddg2dnr smarter-encryption $< $@

ifeq ('$(browser)','chrome-mv3')
ifeq ('$(browser)','chrome')
BUILD_TARGETS += $(BUILD_DIR)/data/bundled/smarter-encryption-rules.json
endif

Expand Down
File renamed without changes.
78 changes: 36 additions & 42 deletions browsers/chrome-mv3/manifest.json → browsers/chrome-mv2/manifest.json
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@
"description": "__MSG_appDesc__",
"default_locale": "en",
"version": "2024.4.26",
"minimum_chrome_version": "92.0",
"icons": {
"16": "img/icon_16.png",
"48": "img/icon_48.png",
"128": "img/icon_128.png"
},
"manifest_version": 3,
"minimum_chrome_version": "121.0",
"action": {
"manifest_version": 2,
"browser_action": {
"default_icon": "img/icon_browser_action.png",
"default_popup": "dashboard/html/browser.html"
},
Expand All @@ -19,7 +19,9 @@
},
"options_page": "html/options.html",
"background": {
"service_worker": "public/js/background.js"
"scripts": [
"public/js/background.js"
]
},
"chrome_settings_overrides": {
"search_provider": {
Expand All @@ -33,10 +35,23 @@
"suggest_url": "https://duckduckgo.com/ac/?q={searchTerms}&type=list"
}
},
"content_security_policy": {
"extension_pages": "script-src 'self'; object-src 'self'; frame-ancestors https://duckduckgo.com https://*.duckduckgo.com"
},
"content_security_policy": "script-src 'self'; object-src 'self'; frame-ancestors https://duckduckgo.com https://*.duckduckgo.com",
"content_scripts": [
{
"matches": [
"<all_urls>"
],
"exclude_matches": [
"*://localhost/*",
"*://*.localhost/*"
],
"match_about_blank": true,
"all_frames": true,
"js": [
"public/js/inject.js"
],
"run_at": "document_start"
},
{
"js": [
"public/js/content-scripts/autofill.js"
Expand All @@ -53,55 +68,34 @@
],
"all_frames": true,
"run_at": "document_start",
"match_origin_as_fallback": true,
"match_about_blank": true
}
],
"permissions": [
"activeTab",
"alarms",
"contextMenus",
"declarativeNetRequest",
"declarativeNetRequestFeedback",
"scripting",
"storage",
"tabs",
"webRequest",
"webRequestBlocking",
"*://*/*",
"webNavigation",
"activeTab",
"tabs",
"storage",
"<all_urls>",
"alarms",
"cookies"
],
"optional_permissions": [
"browsingData"
],
"host_permissions": [
"*://*/*"
],
"web_accessible_resources": [
{
"resources": [
"/web_accessible_resources/*",
"/img/logo-small.svg",
"/img/logo-small-grayscale.svg",
"/public/css/autofill.css",
"/public/font/*",
"/html/tracker-stats.html"
],
"use_dynamic_url": true,
"matches": [
"<all_urls>"
]
}
"/web_accessible_resources/*",
"/img/logo-small.svg",
"/img/logo-small-grayscale.svg",
"/public/css/autofill.css",
"/public/font/*",
"/html/tracker-stats.html"
],
"storage": {
"managed_schema": "managed-schema.json"
},
"declarative_net_request": {
"rule_resources": [
{
"id": "smarter_encryption",
"enabled": true,
"path": "data/bundled/smarter-encryption-rules.json"
}
]
}
}
}
Loading

0 comments on commit cdea87f

Please sign in to comment.