Skip to content

Commit b2b518e

Browse files
authored
Merge branch 'main' into ctl-add-new-msg-format
2 parents 0caacb2 + e12550d commit b2b518e

27 files changed

+6914
-613
lines changed

integration-test/playwright/data/har/duckduckgo.com/search.har

Lines changed: 5843 additions & 0 deletions
Large diffs are not rendered by default.
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
import { test, expect } from '@playwright/test'
2+
// @ts-expect-error - no synthetic default export
3+
import path from 'path'
4+
import { readFileSync } from 'fs'
5+
6+
const testRoot = path.join('integration-test', 'playwright')
7+
8+
function getHARPath (harFile) {
9+
return path.join(testRoot, 'data', 'har', harFile)
10+
}
11+
12+
const config = './integration-test/test-pages/runtime-checks/config/replace-element.json'
13+
const css = readFileSync('./build/integration/contentScope.js', 'utf8')
14+
const parsedConfig = JSON.parse(readFileSync(config, 'utf8'))
15+
16+
function wrapScript (js, replacements) {
17+
for (const [find, replace] of Object.entries(replacements)) {
18+
js = js.replace(find, JSON.stringify(replace))
19+
}
20+
return js
21+
}
22+
23+
const tests = [
24+
// Generated using `node scripts/generate-har.js`
25+
{ url: 'duckduckgo.com/c-s-s-says-hello', har: getHARPath('duckduckgo.com/search.har') }
26+
]
27+
28+
test.describe('Remotely loaded files tests', () => {
29+
tests.forEach(testCase => {
30+
test(`${testCase.url} should load resources and look correct`, async ({ page }, testInfo) => {
31+
const injectedJS = wrapScript(css, {
32+
$CONTENT_SCOPE$: parsedConfig,
33+
$USER_UNPROTECTED_DOMAINS$: [],
34+
$USER_PREFERENCES$: {
35+
// @ts-expect-error - no platform key
36+
platform: { name: testInfo.project.use.platform },
37+
debug: true
38+
}
39+
})
40+
await page.addInitScript({ content: injectedJS })
41+
await page.routeFromHAR(testCase.har)
42+
await page.goto(`https://${testCase.url}`, { waitUntil: 'networkidle' })
43+
const values = await page.evaluate(() => {
44+
return {
45+
results: document.querySelectorAll('[data-layout="organic"]').length
46+
}
47+
})
48+
expect(values.results).toBeGreaterThan(1)
49+
})
50+
})
51+
})

integration-test/test-pages.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,8 @@ describe('Test integration pages', () => {
2727
'runtime-checks/pages/replace-element.html': 'runtime-checks/config/replace-element.json',
2828
'runtime-checks/pages/filter-props.html': 'runtime-checks/config/filter-props.json',
2929
'runtime-checks/pages/shadow-dom.html': 'runtime-checks/config/shadow-dom.json',
30-
'runtime-checks/pages/script-overload.html': 'runtime-checks/config/script-overload.json'
30+
'runtime-checks/pages/script-overload.html': 'runtime-checks/config/script-overload.json',
31+
'runtime-checks/pages/generic-overload.html': 'runtime-checks/config/generic-overload.json'
3132
}
3233
for (const pageName in pages) {
3334
const configName = pages[pageName]

integration-test/test-pages/runtime-checks/config/basic-run.json

Lines changed: 46 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,52 @@
1515
"domains": [
1616
],
1717
"stackDomains": [
18-
]
18+
],
19+
"breakpoints": [
20+
{"height": 768, "width": 1024},
21+
{"height": 1024, "width": 768},
22+
{"height": 375, "width": 812},
23+
{"height": 812, "width": 375}
24+
],
25+
"injectGenericOverloads": {
26+
"Date": {
27+
"stackCheck": true
28+
},
29+
"Date.prototype.getTimezoneOffset": {
30+
"stackCheck": true
31+
},
32+
"NavigatorUAData.prototype.getHighEntropyValues": {
33+
"stackCheck": true
34+
},
35+
"localStorage": {
36+
"stackCheck": true,
37+
"scheme": "session"
38+
},
39+
"sessionStorage": {
40+
"stackCheck": true,
41+
"scheme": "memory"
42+
},
43+
"innerHeight": {
44+
"stackCheck": true,
45+
"offset": 100
46+
},
47+
"innerWidth": {
48+
"stackCheck": true,
49+
"offset": 100
50+
},
51+
"outerHeight": {
52+
"stackCheck": true
53+
},
54+
"outerWidth": {
55+
"stackCheck": true
56+
},
57+
"Screen.prototype.height": {
58+
"stackCheck": true
59+
},
60+
"Screen.prototype.width": {
61+
"stackCheck": true
62+
}
63+
}
1964
}
2065
}
2166
}

integration-test/test-pages/runtime-checks/config/filter-props.json

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,31 @@
1919
"attribute": ["madeupattr1", "madeupattr3"]
2020
}
2121
}
22+
},
23+
"breakpoints": [
24+
{"height": 768, "width": 1024},
25+
{"height": 1024, "width": 768},
26+
{"height": 375, "width": 812},
27+
{"height": 812, "width": 375}
28+
],
29+
"injectGenericOverloads": {
30+
"Date": {},
31+
"Date.prototype.getTimezoneOffset": {},
32+
"NavigatorUAData.prototype.getHighEntropyValues": {},
33+
"localStorage": {
34+
"scheme": "session"
35+
},
36+
"sessionStorage": {
37+
"scheme": "memory"
38+
},
39+
"innerHeight": {
40+
"offset": 100
41+
},
42+
"innerWidth": {
43+
"offset": 100
44+
},
45+
"Screen.prototype.height": {},
46+
"Screen.prototype.width": {}
2247
}
2348
}
2449
}
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
{
2+
"features": {
3+
"runtimeChecks": {
4+
"state": "enabled",
5+
"exceptions": [],
6+
"settings": {
7+
"taintCheck": "enabled",
8+
"matchAllDomains": "enabled",
9+
"matchAllStackDomains": "enabled",
10+
"overloadInstanceOf": "enabled",
11+
"domains": [
12+
],
13+
"stackDomains": [
14+
],
15+
"scriptOverload": {
16+
},
17+
"breakpoints": [
18+
{"height": 768, "width": 1024},
19+
{"height": 1024, "width": 768},
20+
{"height": 375, "width": 812},
21+
{"height": 812, "width": 375}
22+
],
23+
"injectGenericOverloads": {
24+
"Date": {},
25+
"Date.prototype.getTimezoneOffset": {},
26+
"NavigatorUAData.prototype.getHighEntropyValues": {},
27+
"localStorage": {
28+
"scheme": "session"
29+
},
30+
"sessionStorage": {
31+
"scheme": "memory"
32+
},
33+
"innerHeight": {
34+
"offset": 100
35+
},
36+
"innerWidth": {
37+
"offset": 100
38+
},
39+
"Screen.prototype.height": {},
40+
"Screen.prototype.width": {}
41+
}
42+
}
43+
}
44+
}
45+
}

integration-test/test-pages/runtime-checks/config/replace-element.json

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,32 @@
1616
"domains": [
1717
],
1818
"stackDomains": [
19-
]
19+
],
20+
"breakpoints": [
21+
{"height": 768, "width": 1024},
22+
{"height": 1024, "width": 768},
23+
{"height": 375, "width": 812},
24+
{"height": 812, "width": 375}
25+
],
26+
"injectGenericOverloads": {
27+
"Date": {},
28+
"Date.prototype.getTimezoneOffset": {},
29+
"NavigatorUAData.prototype.getHighEntropyValues": {},
30+
"localStorage": {
31+
"scheme": "session"
32+
},
33+
"sessionStorage": {
34+
"scheme": "memory"
35+
},
36+
"innerHeight": {
37+
"offset": 100
38+
},
39+
"innerWidth": {
40+
"offset": 100
41+
},
42+
"Screen.prototype.height": {},
43+
"Screen.prototype.width": {}
44+
}
2045
}
2146
}
2247
}

integration-test/test-pages/runtime-checks/config/script-overload.json

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,31 @@
3333
"type": "function",
3434
"functionName": "noop"
3535
}
36+
},
37+
"breakpoints": [
38+
{"height": 768, "width": 1024},
39+
{"height": 1024, "width": 768},
40+
{"height": 375, "width": 812},
41+
{"height": 812, "width": 375}
42+
],
43+
"injectGenericOverloads": {
44+
"Date": {},
45+
"Date.prototype.getTimezoneOffset": {},
46+
"NavigatorUAData.prototype.getHighEntropyValues": {},
47+
"localStorage": {
48+
"scheme": "session"
49+
},
50+
"sessionStorage": {
51+
"scheme": "memory"
52+
},
53+
"innerHeight": {
54+
"offset": 100
55+
},
56+
"innerWidth": {
57+
"offset": 100
58+
},
59+
"Screen.prototype.height": {},
60+
"Screen.prototype.width": {}
3661
}
3762
}
3863
}

integration-test/test-pages/runtime-checks/config/shadow-dom.json

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,32 @@
1313
"domains": [
1414
],
1515
"stackDomains": [
16-
]
16+
],
17+
"breakpoints": [
18+
{"height": 768, "width": 1024},
19+
{"height": 1024, "width": 768},
20+
{"height": 375, "width": 812},
21+
{"height": 812, "width": 375}
22+
],
23+
"injectGenericOverloads": {
24+
"Date": {},
25+
"Date.prototype.getTimezoneOffset": {},
26+
"NavigatorUAData.prototype.getHighEntropyValues": {},
27+
"localStorage": {
28+
"scheme": "session"
29+
},
30+
"sessionStorage": {
31+
"scheme": "memory"
32+
},
33+
"innerHeight": {
34+
"offset": 100
35+
},
36+
"innerWidth": {
37+
"offset": 100
38+
},
39+
"Screen.prototype.height": {},
40+
"Screen.prototype.width": {}
41+
}
1742
}
1843
}
1944
}

integration-test/test-pages/runtime-checks/config/site-specific-settings.json

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,32 @@
2525
}
2626
],
2727
"stackDomains": [
28-
]
28+
],
29+
"breakpoints": [
30+
{"height": 768, "width": 1024},
31+
{"height": 1024, "width": 768},
32+
{"height": 375, "width": 812},
33+
{"height": 812, "width": 375}
34+
],
35+
"injectGenericOverloads": {
36+
"Date": {},
37+
"Date.prototype.getTimezoneOffset": {},
38+
"NavigatorUAData.prototype.getHighEntropyValues": {},
39+
"localStorage": {
40+
"scheme": "session"
41+
},
42+
"sessionStorage": {
43+
"scheme": "memory"
44+
},
45+
"innerHeight": {
46+
"offset": 100
47+
},
48+
"innerWidth": {
49+
"offset": 100
50+
},
51+
"Screen.prototype.height": {},
52+
"Screen.prototype.width": {}
53+
}
2954
}
3055
}
3156
}

integration-test/test-pages/runtime-checks/index.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
<li><a href="./pages/filter-props.html">Filter props</a> - <a href="./config/filter-props.json">Config</a></li>
1515
<li><a href="./pages/script-overload.html">Script overloading</a> - <a href="./config/script-overload.json">Config</a></li>
1616
<li><a href="./pages/shadow-dom.html">Shadow dom support</a> - <a href="./config/shadow-dom.json">Config</a></li>
17+
<li><a href="./pages/generic-overload.html">Generic overload of APIs</a> - <a href="./config/generic-overload.json">Config</a></li>
1718
</ul>
1819

1920
</body>

0 commit comments

Comments
 (0)