Skip to content

Commit f1dee2a

Browse files
Prettier the test-pages (#1776)
1 parent 7ded2fc commit f1dee2a

File tree

7 files changed

+169
-178
lines changed

7 files changed

+169
-178
lines changed

.prettierignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,5 +9,6 @@ injected/src/features/Scriptlets
99
**/*.md
1010
!injected/docs/**/*.md
1111
**/*.html
12+
!injected/integration-test/test-pages/*
1213
**/*.har
1314
**/*.css
Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<html lang="en">
2-
<body>
3-
<h1>Blank Integration page</h1>
4-
<p>This page is used by extension test code, which will inject a content script</p>
5-
</body>
2+
<body>
3+
<h1>Blank Integration page</h1>
4+
<p>This page is used by extension test code, which will inject a content script</p>
5+
</body>
66
</html>
Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<html>
2-
<body>
3-
<h1>Integration page</h1>
4-
<p>This loads the injection file as if it were loaded through the content script.</p>
5-
<script src="./build/contentScope.js"></script>
6-
</body>
2+
<body>
3+
<h1>Integration page</h1>
4+
<p>This loads the injection file as if it were loaded through the content script.</p>
5+
<script src="./build/contentScope.js"></script>
6+
</body>
77
</html>
Lines changed: 35 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -1,49 +1,40 @@
1-
<!DOCTYPE html>
1+
<!doctype html>
22
<html>
3-
<head>
4-
<meta charset="utf-8">
5-
<meta name="viewport" content="width=device-width">
6-
<title>Conditional Matching experiments</title>
7-
<link rel="stylesheet" href="../../shared/style.css">
8-
</head>
9-
<body>
10-
<script src="../../shared/utils.js"></script>
11-
<p><a href="../index.html">[Infra]</a></p>
3+
<head>
4+
<meta charset="utf-8" />
5+
<meta name="viewport" content="width=device-width" />
6+
<title>Conditional Matching experiments</title>
7+
<link rel="stylesheet" href="../../shared/style.css" />
8+
</head>
9+
<body>
10+
<script src="../../shared/utils.js"></script>
11+
<p><a href="../index.html">[Infra]</a></p>
1212

13-
<p>This page verifies that APIs get modified when in an experiment. Ensure you're sending the following cohorts:
14-
<code>
15-
currentCohorts: [
16-
{
17-
"feature": "contentScopeExperiments",
18-
"subfeature": "bloops",
19-
"cohort": "control",
20-
},
21-
{
22-
"feature": "contentScopeExperiments",
23-
"subfeature": "test",
24-
"cohort": "treatment",
25-
},
26-
],
27-
</code>
28-
</p>
13+
<p>
14+
This page verifies that APIs get modified when in an experiment. Ensure you're sending the following cohorts:
15+
<code>
16+
currentCohorts: [ { "feature": "contentScopeExperiments", "subfeature": "bloops", "cohort": "control", }, { "feature":
17+
"contentScopeExperiments", "subfeature": "test", "cohort": "treatment", }, ],
18+
</code>
19+
</p>
2920

30-
<script>
31-
test('Conditional matching experiments', async () => {
32-
const res = navigator.hardwareConcurrency;
33-
// Either is valid here, but 100 is the default which would mean the experiment is not running
34-
const expected = res === 200 ? 200 : 300;
35-
const results = [
36-
{
37-
name: "APIs changing, expecting to always match",
38-
result: res,
39-
expected: expected,
40-
}
41-
];
42-
return results;
43-
});
21+
<script>
22+
test('Conditional matching experiments', async () => {
23+
const res = navigator.hardwareConcurrency;
24+
// Either is valid here, but 100 is the default which would mean the experiment is not running
25+
const expected = res === 200 ? 200 : 300;
26+
const results = [
27+
{
28+
name: 'APIs changing, expecting to always match',
29+
result: res,
30+
expected: expected,
31+
},
32+
];
33+
return results;
34+
});
4435

45-
// eslint-disable-next-line no-undef
46-
renderResults();
47-
</script>
48-
</body>
36+
// eslint-disable-next-line no-undef
37+
renderResults();
38+
</script>
39+
</body>
4940
</html>
Lines changed: 56 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -1,64 +1,63 @@
1-
<!DOCTYPE html>
1+
<!doctype html>
22
<html>
3-
<head>
4-
<meta charset="utf-8">
5-
<meta name="viewport" content="width=device-width">
6-
<title>Conditional Matching</title>
7-
<link rel="stylesheet" href="../../shared/style.css">
8-
</head>
9-
<body>
10-
<script src="../../shared/utils.js"></script>
11-
<p><a href="../index.html">[Infra]</a></p>
3+
<head>
4+
<meta charset="utf-8" />
5+
<meta name="viewport" content="width=device-width" />
6+
<title>Conditional Matching</title>
7+
<link rel="stylesheet" href="../../shared/style.css" />
8+
</head>
9+
<body>
10+
<script src="../../shared/utils.js"></script>
11+
<p><a href="../index.html">[Infra]</a></p>
1212

13-
<p>This page verifies that APIs get modified</p>
13+
<p>This page verifies that APIs get modified</p>
1414

15-
<script>
16-
test('Conditional matching', async () => {
17-
const results = [
18-
{
19-
name: "APIs changing, expecting to always match",
15+
<script>
16+
test('Conditional matching', async () => {
17+
const results = [
18+
{
19+
name: 'APIs changing, expecting to always match',
20+
result: navigator.hardwareConcurrency,
21+
expected: 222,
22+
},
23+
];
24+
const oldPathname = window.location.pathname;
25+
const newUrl = new URL(window.location.href);
26+
newUrl.pathname = '/test/test/path';
27+
window.history.pushState(null, '', newUrl.href);
28+
await new Promise((resolve) => requestIdleCallback(resolve));
29+
results.push({
30+
name: 'Expect URL to be changed',
31+
result: window.location.pathname,
32+
expected: '/test/test/path',
33+
});
34+
results.push({
35+
name: 'APIs changing, expecting to match only when the URL is correct',
2036
result: navigator.hardwareConcurrency,
21-
expected: 222
22-
}
23-
];
24-
const oldPathname = window.location.pathname;
25-
const newUrl = new URL(window.location.href);
26-
newUrl.pathname = "/test/test/path";
27-
window.history.pushState(null, '', newUrl.href);
28-
await new Promise(resolve => requestIdleCallback(resolve));
29-
results.push({
30-
name: "Expect URL to be changed",
31-
result: window.location.pathname,
32-
expected: '/test/test/path'
33-
})
34-
results.push({
35-
name: "APIs changing, expecting to match only when the URL is correct",
36-
result: navigator.hardwareConcurrency,
37-
expected: 333
38-
})
39-
const popStatePromise = new Promise(resolve => {
40-
window.addEventListener('popstate', resolve, { once: true });
41-
});
42-
// Call pop state to revert the URL
43-
window.history.back();
44-
await popStatePromise;
45-
results.push({
46-
name: "Expect URL to be reverted",
47-
result: window.location.pathname,
48-
expected: oldPathname
49-
})
50-
results.push({
51-
name: "APIs changing, expecting to match only when the URL is correct",
52-
result: navigator.hardwareConcurrency,
53-
expected: 222
54-
})
55-
56-
return results;
57-
});
37+
expected: 333,
38+
});
39+
const popStatePromise = new Promise((resolve) => {
40+
window.addEventListener('popstate', resolve, { once: true });
41+
});
42+
// Call pop state to revert the URL
43+
window.history.back();
44+
await popStatePromise;
45+
results.push({
46+
name: 'Expect URL to be reverted',
47+
result: window.location.pathname,
48+
expected: oldPathname,
49+
});
50+
results.push({
51+
name: 'APIs changing, expecting to match only when the URL is correct',
52+
result: navigator.hardwareConcurrency,
53+
expected: 222,
54+
});
5855

56+
return results;
57+
});
5958

60-
// eslint-disable-next-line no-undef
61-
renderResults();
62-
</script>
63-
</body>
59+
// eslint-disable-next-line no-undef
60+
renderResults();
61+
</script>
62+
</body>
6463
</html>
Lines changed: 34 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,36 @@
1-
<!DOCTYPE html>
1+
<!doctype html>
22
<html>
3-
<head>
4-
<meta charset="utf-8">
5-
<meta name="viewport" content="width=device-width">
6-
<title>Min Supported Version (Int)</title>
7-
<link rel="stylesheet" href="../../shared/style.css">
8-
</head>
9-
<body>
10-
<script src="../../shared/utils.js"></script>
11-
<p><a href="../index.html">[Infra]</a></p>
12-
<p>This page verifies minSupportedVersion (int) conditional patching. Load with 99 as the version number.</p>
13-
<script>
14-
test('minSupportedVersion (int)', async () => {
15-
const results = [];
16-
results.push({
17-
name: "versionIntTestBelow should always be true",
18-
result: window.versionIntTestBelow,
19-
expected: true
3+
<head>
4+
<meta charset="utf-8" />
5+
<meta name="viewport" content="width=device-width" />
6+
<title>Min Supported Version (Int)</title>
7+
<link rel="stylesheet" href="../../shared/style.css" />
8+
</head>
9+
<body>
10+
<script src="../../shared/utils.js"></script>
11+
<p><a href="../index.html">[Infra]</a></p>
12+
<p>This page verifies minSupportedVersion (int) conditional patching. Load with 99 as the version number.</p>
13+
<script>
14+
test('minSupportedVersion (int)', async () => {
15+
const results = [];
16+
results.push({
17+
name: 'versionIntTestBelow should always be true',
18+
result: window.versionIntTestBelow,
19+
expected: true,
20+
});
21+
results.push({
22+
name: 'versionIntTestSame should always be true',
23+
result: window.versionIntTestSame,
24+
expected: true,
25+
});
26+
results.push({
27+
name: 'versionIntTestAbove should be undefined',
28+
result: window.versionIntTestAbove,
29+
expected: undefined,
30+
});
31+
return results;
2032
});
21-
results.push({
22-
name: "versionIntTestSame should always be true",
23-
result: window.versionIntTestSame,
24-
expected: true
25-
});
26-
results.push({
27-
name: "versionIntTestAbove should be undefined",
28-
result: window.versionIntTestAbove,
29-
expected: undefined
30-
});
31-
return results;
32-
});
33-
renderResults();
34-
</script>
35-
</body>
36-
</html>
33+
renderResults();
34+
</script>
35+
</body>
36+
</html>
Lines changed: 34 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,36 @@
1-
<!DOCTYPE html>
1+
<!doctype html>
22
<html>
3-
<head>
4-
<meta charset="utf-8">
5-
<meta name="viewport" content="width=device-width">
6-
<title>Min Supported Version (String)</title>
7-
<link rel="stylesheet" href="../../shared/style.css">
8-
</head>
9-
<body>
10-
<script src="../../shared/utils.js"></script>
11-
<p><a href="../index.html">[Infra]</a></p>
12-
<p>This page verifies minSupportedVersion (string) conditional patching. Load with 1.5.0 as the version number.</p>
13-
<script>
14-
test('minSupportedVersion (string)', async () => {
15-
const results = [];
16-
results.push({
17-
name: "versionStringTestBelow should always be true",
18-
result: window.versionStringTestBelow,
19-
expected: true
3+
<head>
4+
<meta charset="utf-8" />
5+
<meta name="viewport" content="width=device-width" />
6+
<title>Min Supported Version (String)</title>
7+
<link rel="stylesheet" href="../../shared/style.css" />
8+
</head>
9+
<body>
10+
<script src="../../shared/utils.js"></script>
11+
<p><a href="../index.html">[Infra]</a></p>
12+
<p>This page verifies minSupportedVersion (string) conditional patching. Load with 1.5.0 as the version number.</p>
13+
<script>
14+
test('minSupportedVersion (string)', async () => {
15+
const results = [];
16+
results.push({
17+
name: 'versionStringTestBelow should always be true',
18+
result: window.versionStringTestBelow,
19+
expected: true,
20+
});
21+
results.push({
22+
name: 'versionStringTestSame should always be true',
23+
result: window.versionStringTestSame,
24+
expected: true,
25+
});
26+
results.push({
27+
name: 'versionStringTestAbove should be undefined',
28+
result: window.versionStringTestAbove,
29+
expected: undefined,
30+
});
31+
return results;
2032
});
21-
results.push({
22-
name: "versionStringTestSame should always be true",
23-
result: window.versionStringTestSame,
24-
expected: true
25-
});
26-
results.push({
27-
name: "versionStringTestAbove should be undefined",
28-
result: window.versionStringTestAbove,
29-
expected: undefined
30-
});
31-
return results;
32-
});
33-
renderResults();
34-
</script>
35-
</body>
36-
</html>
33+
renderResults();
34+
</script>
35+
</body>
36+
</html>

0 commit comments

Comments
 (0)