Skip to content

Commit 750f5b2

Browse files
authored
Merge branch 'main' into max/dev-firefox-fix
2 parents 3d89148 + 0aa34b5 commit 750f5b2

File tree

138 files changed

+2417
-383
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

138 files changed

+2417
-383
lines changed

.github/scripts/diff-directories.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ function upperCaseFirstLetter(string) {
2626
return string.charAt(0).toUpperCase() + string.slice(1);
2727
}
2828

29-
function displayDiffs(dir1Files, dir2Files, isOpen) {
29+
function displayDiffs(dir1Files, dir2Files) {
3030
const rollupGrouping = {};
3131
/**
3232
* Rolls up multiple files with the same diff into a single entry
@@ -79,13 +79,13 @@ function displayDiffs(dir1Files, dir2Files, isOpen) {
7979
}
8080
}
8181
outString += '\n\n' + rollup.string;
82-
return renderDetails(title, outString, isOpen);
82+
return renderDetails(title, outString);
8383
})
8484
.join('\n');
8585
return outString;
8686
}
8787

88-
function renderDetails(section, text, isOpen) {
88+
function renderDetails(section, text) {
8989
if (section === 'dist') {
9090
section = 'apple';
9191
}
@@ -120,5 +120,5 @@ sortFiles(readFilesRecursively(dir1 + sourcesOutput), 'dir1');
120120
sortFiles(readFilesRecursively(dir2 + sourcesOutput), 'dir2');
121121

122122
// console.log(Object.keys(files))
123-
const fileOut = displayDiffs(sections.dir1, sections.dir2, true);
123+
const fileOut = displayDiffs(sections.dir1, sections.dir2);
124124
console.log(fileOut);

.github/workflows/build-pr.yml

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,17 +68,25 @@ jobs:
6868
const repoUrl = `https://github.com/${context.repo.owner}/${context.repo.repo}`;
6969
const branchUrl = `${repoUrl}/tree/${branchName}`;
7070
const commitUrl = `${repoUrl}/commit/${commitHash}`;
71+
72+
// Get the current date
73+
const lastUpdatedDate = (new Date()).toLocaleString('en-US', {
74+
dateStyle: 'long',
75+
timeStyle: 'long'
76+
});
77+
7178
const commentBody = `
7279
### Temporary Branch Update
7380
7481
The temporary branch has been updated with the latest changes. Below are the details:
7582
7683
- **Branch Name**: [${branchName}](${branchUrl})
7784
- **Commit Hash**: [${commitHash}](${commitUrl})
85+
- **Last Updated**: ${lastUpdatedDate}
7886
- **Install Command**: \`npm i github:duckduckgo/content-scope-scripts#${commitHash}\`
7987
8088
Please use the above install command to update to the latest version.
81-
`;
89+
`;
8290
core.setOutput('comment_body', commentBody);
8391
core.setOutput('pr_number', prNumber);
8492
Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
name: Update Snapshots on a PR
2+
description: |
3+
Runs previously failed snapshot tests, and commits the changes.
4+
5+
Your PR will receive a commit with the changes so you can manually verify before merging.
6+
7+
on:
8+
workflow_dispatch:
9+
inputs:
10+
pr_number:
11+
description: 'Pull Request Number (Warning: This action will push a commit to the referenced PR)'
12+
required: true
13+
type: number
14+
15+
permissions:
16+
pull-requests: write
17+
contents: write
18+
19+
jobs:
20+
update-pr-with-snapshots:
21+
name: Update PR With Snapshots
22+
runs-on: macos-14
23+
steps:
24+
- uses: actions/checkout@v4
25+
- name: Checkout PR ${{ github.event.inputs.pr_number }}
26+
if: github.event_name == 'workflow_dispatch'
27+
run: gh pr checkout ${{ github.event.inputs.pr_number }}
28+
env:
29+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
30+
31+
- name: Use Node.js
32+
uses: actions/setup-node@v4
33+
with:
34+
node-version-file: '.nvmrc'
35+
- uses: actions/cache@v4
36+
with:
37+
path: |
38+
~/.npm
39+
~/.cache/ms-playwright
40+
key: ${{ runner.os }}-node-playwright-${{ hashFiles('**/package-lock.json') }}
41+
restore-keys: |
42+
${{ runner.os }}-node-playwright-
43+
${{ runner.os }}-node-
44+
45+
- name: Install dependencies
46+
run: npm ci
47+
48+
- name: Build all
49+
run: npm run build
50+
51+
- name: Install Playwright Browsers
52+
run: npx playwright install --with-deps
53+
54+
- name: Run Screenshot tests
55+
id: screenshot_tests
56+
run: npm run test-int-snapshots
57+
58+
- if: ${{ steps.screenshot_tests.conclusion == 'success' }}
59+
run: |
60+
echo "nothing to update - tests all passed"
61+
62+
- name: Re-Running Playwright to update snapshots
63+
id: screenshot_tests_update
64+
if: ${{ failure() && steps.screenshot_tests.conclusion == 'failure' }}
65+
run: npm run test-int-snapshots-update
66+
67+
- name: Commit the updated files to the PR branch
68+
if: ${{ failure() && steps.screenshot_tests_update.conclusion == 'success' }}
69+
env:
70+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
71+
run: |
72+
# Configure Git with a bot's username and email for committing changes
73+
# This makes it easy to identify in the PR
74+
git config user.name "github-actions[bot]"
75+
git config user.email "github-actions[bot]@users.noreply.github.com"
76+
77+
# Stage all updated PNG files for commit
78+
git add "*.png"
79+
80+
# Commit the changes with a descriptive message
81+
git commit -m "Updated snapshots via workflow"
82+
83+
# Push the changes to the current branch in the PR
84+
git push origin HEAD

.github/workflows/snapshots.yml

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
name: Test Snapshots
2+
description: |
3+
Runs snapshot tests and uploads test reports as artifacts
4+
5+
If this workflow fails, you can trigger `update-snapshots.yml` from the
6+
GitHub UI.
7+
8+
on:
9+
push:
10+
branches:
11+
- main
12+
pull_request:
13+
14+
permissions:
15+
contents: read
16+
17+
jobs:
18+
snapshots:
19+
timeout-minutes: 5
20+
runs-on: macos-14
21+
steps:
22+
- uses: actions/checkout@v4
23+
- name: Use Node.js
24+
uses: actions/setup-node@v4
25+
with:
26+
node-version-file: '.nvmrc'
27+
- uses: actions/cache@v4
28+
with:
29+
path: |
30+
~/.npm
31+
~/.cache/ms-playwright
32+
key: ${{ runner.os }}-node-playwright-${{ hashFiles('**/package-lock.json') }}
33+
restore-keys: |
34+
${{ runner.os }}-node-playwright-
35+
${{ runner.os }}-node-
36+
37+
- run: npm ci
38+
- run: npm run build
39+
40+
- run: npm run lint
41+
continue-on-error: true
42+
43+
- run: npm run stylelint
44+
continue-on-error: true
45+
46+
- run: npm run test-unit
47+
continue-on-error: true
48+
49+
- name: 'Clean tree'
50+
run: 'npm run test-clean-tree'
51+
52+
- name: Install Playwright Browsers
53+
run: npx playwright install --with-deps
54+
55+
- run: npm run test-int-snapshots
56+
57+
- uses: actions/upload-artifact@v4
58+
if: always()
59+
with:
60+
name: playwright-report-pages
61+
path: |
62+
special-pages/playwright-report
63+
special-pages/test-results
64+
injected/playwright-report
65+
injected/test-results
66+
retention-days: 5

.github/workflows/tests.yml

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -64,14 +64,12 @@ jobs:
6464
key: docs-output-${{ github.run_id }}
6565
- name: Install Playwright Browsers
6666
run: npx playwright install --with-deps
67-
- name: Install dependencies for CI integration tests
68-
run: sudo apt-get install xvfb
6967
- run: npm run test-int-x
7068
- uses: actions/upload-artifact@v4
7169
if: always()
7270
with:
7371
name: playwright-report-pages
74-
path: special-pages/test-results
72+
path: special-pages/playwright-report
7573
retention-days: 5
7674
- name: Build docs
7775
run: npm run docs

eslint.config.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ export default tseslint.config(
1111
'**/build/',
1212
'**/docs/',
1313
'injected/lib',
14+
'injected/playwright-report/',
1415
'Sources/ContentScopeScripts/dist/',
1516
'injected/integration-test/extension/contentScope.js',
1617
'injected/integration-test/test-pages/duckplayer/scripts/dist',

injected/docs/favicon.md

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
---
2+
title: Favicon Monitor
3+
---
4+
5+
# Favicon Monitor
6+
7+
Reports the presence of favicons on page-load, and optionally when they change.
8+
9+
## Notifications
10+
11+
### `faviconFound`
12+
- {@link "Favicon Messages".FaviconFoundNotification}
13+
- Sent on page load, sends {@link "Favicon Messages".FaviconFound}
14+
15+
**Example**
16+
17+
```json
18+
{
19+
"favicons": [
20+
{
21+
"href": "favicon.png",
22+
"rel": "stylesheet"
23+
}
24+
],
25+
"documentUrl": "https://example.com"
26+
}
27+
```
28+
29+
## Remote Config
30+
31+
## Enabled (default)
32+
{@includeCode ../integration-test/test-pages/favicon/config/favicon-enabled.json}
33+
34+
### Disable the monitor only.
35+
36+
To only receive the initial payload and nothing more (to mimic the old behavior),
37+
you can set `monitor: false` in the remote config, and it will not install the Mutation Observer.
38+
39+
{@includeCode ../integration-test/test-pages/favicon/config/favicon-monitor-disabled.json}

injected/entry-points/android.js

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
* @module Android integration
33
*/
44
import { load, init } from '../src/content-scope-features.js';
5-
import { processConfig, isGloballyDisabled } from './../src/utils';
5+
import { processConfig } from './../src/utils';
66
import { AndroidMessagingConfig } from '../../messaging/index.js';
77

88
function initCode() {
@@ -14,9 +14,6 @@ function initCode() {
1414
const userPreferences = $USER_PREFERENCES$;
1515

1616
const processedConfig = processConfig(config, userUnprotectedDomains, userPreferences);
17-
if (isGloballyDisabled(processedConfig)) {
18-
return;
19-
}
2017

2118
const configConstruct = processedConfig;
2219
const messageCallback = configConstruct.messageCallback;

injected/entry-points/apple.js

Lines changed: 10 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22
* @module Apple integration
33
*/
44
import { load, init } from '../src/content-scope-features.js';
5-
import { processConfig, isGloballyDisabled, platformSpecificFeatures } from './../src/utils';
6-
import { WebkitMessagingConfig, TestTransportConfig } from '../../messaging/index.js';
5+
import { processConfig, platformSpecificFeatures } from './../src/utils';
6+
import { WebkitMessagingConfig } from '../../messaging/index.js';
77

88
function initCode() {
99
// @ts-expect-error https://app.asana.com/0/1201614831475344/1203979574128023/f
@@ -15,31 +15,17 @@ function initCode() {
1515

1616
const processedConfig = processConfig(config, userUnprotectedDomains, userPreferences, platformSpecificFeatures);
1717

18-
if (isGloballyDisabled(processedConfig)) {
19-
return;
20-
}
21-
18+
const handlerNames = [];
2219
if (import.meta.injectName === 'apple-isolated') {
23-
processedConfig.messagingConfig = new WebkitMessagingConfig({
24-
webkitMessageHandlerNames: ['contentScopeScriptsIsolated'],
25-
secret: '',
26-
hasModernWebkitAPI: true,
27-
});
20+
handlerNames.push('contentScopeScriptsIsolated');
2821
} else {
29-
processedConfig.messagingConfig = new TestTransportConfig({
30-
notify() {
31-
// noop
32-
},
33-
request: async () => {
34-
// noop
35-
},
36-
subscribe() {
37-
return () => {
38-
// noop
39-
};
40-
},
41-
});
22+
handlerNames.push('contentScopeScripts');
4223
}
24+
processedConfig.messagingConfig = new WebkitMessagingConfig({
25+
webkitMessageHandlerNames: handlerNames,
26+
secret: '',
27+
hasModernWebkitAPI: true,
28+
});
4329

4430
load({
4531
platform: processedConfig.platform,

injected/entry-points/integration.js

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,14 @@ function generateConfig() {
2626
domain: topLevelUrl.hostname,
2727
isBroken: false,
2828
allowlisted: false,
29-
enabledFeatures: ['fingerprintingCanvas', 'fingerprintingScreenSize', 'navigatorInterface', 'cookie'],
29+
enabledFeatures: [
30+
'fingerprintingCanvas',
31+
'fingerprintingScreenSize',
32+
'navigatorInterface',
33+
'cookie',
34+
'webCompat',
35+
'apiManipulation',
36+
],
3037
},
3138
};
3239
}

injected/entry-points/windows.js

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
* @module Windows integration
33
*/
44
import { load, init } from '../src/content-scope-features.js';
5-
import { processConfig, isGloballyDisabled, platformSpecificFeatures } from './../src/utils';
5+
import { processConfig, platformSpecificFeatures } from './../src/utils';
66
import { WindowsMessagingConfig } from '../../messaging/index.js';
77

88
function initCode() {
@@ -14,9 +14,7 @@ function initCode() {
1414
const userPreferences = $USER_PREFERENCES$;
1515

1616
const processedConfig = processConfig(config, userUnprotectedDomains, userPreferences, platformSpecificFeatures);
17-
if (isGloballyDisabled(processedConfig)) {
18-
return;
19-
}
17+
2018
processedConfig.messagingConfig = new WindowsMessagingConfig({
2119
methods: {
2220
// @ts-expect-error - Type 'unknown' is not assignable to type...

0 commit comments

Comments
 (0)