Skip to content

Prettier the test-pages #1776

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

Merged
merged 4 commits into from
Jul 6, 2025
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
1 change: 1 addition & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,6 @@ injected/src/features/Scriptlets
**/*.md
!injected/docs/**/*.md
**/*.html
!injected/integration-test/test-pages/*
**/*.har
**/*.css
8 changes: 4 additions & 4 deletions injected/integration-test/test-pages/blank.html
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<html lang="en">
<body>
<h1>Blank Integration page</h1>
<p>This page is used by extension test code, which will inject a content script</p>
</body>
<body>
<h1>Blank Integration page</h1>
<p>This page is used by extension test code, which will inject a content script</p>
</body>
</html>
10 changes: 5 additions & 5 deletions injected/integration-test/test-pages/index.html
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<html>
<body>
<h1>Integration page</h1>
<p>This loads the injection file as if it were loaded through the content script.</p>
<script src="./build/contentScope.js"></script>
</body>
<body>
<h1>Integration page</h1>
<p>This loads the injection file as if it were loaded through the content script.</p>
<script src="./build/contentScope.js"></script>
</body>
</html>
Original file line number Diff line number Diff line change
@@ -1,49 +1,40 @@
<!DOCTYPE html>
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title>Conditional Matching experiments</title>
<link rel="stylesheet" href="../../shared/style.css">
</head>
<body>
<script src="../../shared/utils.js"></script>
<p><a href="../index.html">[Infra]</a></p>
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width" />
<title>Conditional Matching experiments</title>
<link rel="stylesheet" href="../../shared/style.css" />
</head>
<body>
<script src="../../shared/utils.js"></script>
<p><a href="../index.html">[Infra]</a></p>

<p>This page verifies that APIs get modified when in an experiment. Ensure you're sending the following cohorts:
<code>
currentCohorts: [
{
"feature": "contentScopeExperiments",
"subfeature": "bloops",
"cohort": "control",
},
{
"feature": "contentScopeExperiments",
"subfeature": "test",
"cohort": "treatment",
},
],
</code>
</p>
<p>
This page verifies that APIs get modified when in an experiment. Ensure you're sending the following cohorts:
<code>
currentCohorts: [ { "feature": "contentScopeExperiments", "subfeature": "bloops", "cohort": "control", }, { "feature":
"contentScopeExperiments", "subfeature": "test", "cohort": "treatment", }, ],
</code>
</p>

<script>
test('Conditional matching experiments', async () => {
const res = navigator.hardwareConcurrency;
// Either is valid here, but 100 is the default which would mean the experiment is not running
const expected = res === 200 ? 200 : 300;
const results = [
{
name: "APIs changing, expecting to always match",
result: res,
expected: expected,
}
];
return results;
});
<script>
test('Conditional matching experiments', async () => {
const res = navigator.hardwareConcurrency;
// Either is valid here, but 100 is the default which would mean the experiment is not running
const expected = res === 200 ? 200 : 300;
const results = [
{
name: 'APIs changing, expecting to always match',
result: res,
expected: expected,
},
];
return results;
});

// eslint-disable-next-line no-undef
renderResults();
</script>
</body>
// eslint-disable-next-line no-undef
renderResults();
</script>
</body>
</html>
Original file line number Diff line number Diff line change
@@ -1,64 +1,63 @@
<!DOCTYPE html>
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title>Conditional Matching</title>
<link rel="stylesheet" href="../../shared/style.css">
</head>
<body>
<script src="../../shared/utils.js"></script>
<p><a href="../index.html">[Infra]</a></p>
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width" />
<title>Conditional Matching</title>
<link rel="stylesheet" href="../../shared/style.css" />
</head>
<body>
<script src="../../shared/utils.js"></script>
<p><a href="../index.html">[Infra]</a></p>

<p>This page verifies that APIs get modified</p>
<p>This page verifies that APIs get modified</p>

<script>
test('Conditional matching', async () => {
const results = [
{
name: "APIs changing, expecting to always match",
<script>
test('Conditional matching', async () => {
const results = [
{
name: 'APIs changing, expecting to always match',
result: navigator.hardwareConcurrency,
expected: 222,
},
];
const oldPathname = window.location.pathname;
const newUrl = new URL(window.location.href);
newUrl.pathname = '/test/test/path';
window.history.pushState(null, '', newUrl.href);
await new Promise((resolve) => requestIdleCallback(resolve));
results.push({
name: 'Expect URL to be changed',
result: window.location.pathname,
expected: '/test/test/path',
});
results.push({
name: 'APIs changing, expecting to match only when the URL is correct',
result: navigator.hardwareConcurrency,
expected: 222
}
];
const oldPathname = window.location.pathname;
const newUrl = new URL(window.location.href);
newUrl.pathname = "/test/test/path";
window.history.pushState(null, '', newUrl.href);
await new Promise(resolve => requestIdleCallback(resolve));
results.push({
name: "Expect URL to be changed",
result: window.location.pathname,
expected: '/test/test/path'
})
results.push({
name: "APIs changing, expecting to match only when the URL is correct",
result: navigator.hardwareConcurrency,
expected: 333
})
const popStatePromise = new Promise(resolve => {
window.addEventListener('popstate', resolve, { once: true });
});
// Call pop state to revert the URL
window.history.back();
await popStatePromise;
results.push({
name: "Expect URL to be reverted",
result: window.location.pathname,
expected: oldPathname
})
results.push({
name: "APIs changing, expecting to match only when the URL is correct",
result: navigator.hardwareConcurrency,
expected: 222
})

return results;
});
expected: 333,
});
const popStatePromise = new Promise((resolve) => {
window.addEventListener('popstate', resolve, { once: true });
});
// Call pop state to revert the URL
window.history.back();
await popStatePromise;
results.push({
name: 'Expect URL to be reverted',
result: window.location.pathname,
expected: oldPathname,
});
results.push({
name: 'APIs changing, expecting to match only when the URL is correct',
result: navigator.hardwareConcurrency,
expected: 222,
});

return results;
});

// eslint-disable-next-line no-undef
renderResults();
</script>
</body>
// eslint-disable-next-line no-undef
renderResults();
</script>
</body>
</html>
Original file line number Diff line number Diff line change
@@ -1,36 +1,36 @@
<!DOCTYPE html>
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title>Min Supported Version (Int)</title>
<link rel="stylesheet" href="../../shared/style.css">
</head>
<body>
<script src="../../shared/utils.js"></script>
<p><a href="../index.html">[Infra]</a></p>
<p>This page verifies minSupportedVersion (int) conditional patching. Load with 99 as the version number.</p>
<script>
test('minSupportedVersion (int)', async () => {
const results = [];
results.push({
name: "versionIntTestBelow should always be true",
result: window.versionIntTestBelow,
expected: true
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width" />
<title>Min Supported Version (Int)</title>
<link rel="stylesheet" href="../../shared/style.css" />
</head>
<body>
<script src="../../shared/utils.js"></script>
<p><a href="../index.html">[Infra]</a></p>
<p>This page verifies minSupportedVersion (int) conditional patching. Load with 99 as the version number.</p>
<script>
test('minSupportedVersion (int)', async () => {
const results = [];
results.push({
name: 'versionIntTestBelow should always be true',
result: window.versionIntTestBelow,
expected: true,
});
results.push({
name: 'versionIntTestSame should always be true',
result: window.versionIntTestSame,
expected: true,
});
results.push({
name: 'versionIntTestAbove should be undefined',
result: window.versionIntTestAbove,
expected: undefined,
});
return results;
});
results.push({
name: "versionIntTestSame should always be true",
result: window.versionIntTestSame,
expected: true
});
results.push({
name: "versionIntTestAbove should be undefined",
result: window.versionIntTestAbove,
expected: undefined
});
return results;
});
renderResults();
</script>
</body>
</html>
renderResults();
</script>
</body>
</html>
Original file line number Diff line number Diff line change
@@ -1,36 +1,36 @@
<!DOCTYPE html>
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title>Min Supported Version (String)</title>
<link rel="stylesheet" href="../../shared/style.css">
</head>
<body>
<script src="../../shared/utils.js"></script>
<p><a href="../index.html">[Infra]</a></p>
<p>This page verifies minSupportedVersion (string) conditional patching. Load with 1.5.0 as the version number.</p>
<script>
test('minSupportedVersion (string)', async () => {
const results = [];
results.push({
name: "versionStringTestBelow should always be true",
result: window.versionStringTestBelow,
expected: true
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width" />
<title>Min Supported Version (String)</title>
<link rel="stylesheet" href="../../shared/style.css" />
</head>
<body>
<script src="../../shared/utils.js"></script>
<p><a href="../index.html">[Infra]</a></p>
<p>This page verifies minSupportedVersion (string) conditional patching. Load with 1.5.0 as the version number.</p>
<script>
test('minSupportedVersion (string)', async () => {
const results = [];
results.push({
name: 'versionStringTestBelow should always be true',
result: window.versionStringTestBelow,
expected: true,
});
results.push({
name: 'versionStringTestSame should always be true',
result: window.versionStringTestSame,
expected: true,
});
results.push({
name: 'versionStringTestAbove should be undefined',
result: window.versionStringTestAbove,
expected: undefined,
});
return results;
});
results.push({
name: "versionStringTestSame should always be true",
result: window.versionStringTestSame,
expected: true
});
results.push({
name: "versionStringTestAbove should be undefined",
result: window.versionStringTestAbove,
expected: undefined
});
return results;
});
renderResults();
</script>
</body>
</html>
renderResults();
</script>
</body>
</html>
Loading