Reland "Prerender: Run WPT for CSP with target hint"
This reverts commit c7d04919d65f45e49225b88737004c0741eaf4fa.
The original CL forgot to update the test expectations.
Original change's description:
> Revert "Prerender: Run WPT for CSP with target hint"
>
> This reverts commit 195504db54e81c95256097493b65140314be9d10.
>
> Reason for revert: Breaks tests on mac builders
>
> First failed build:
>
> https://ci.chromium.org/ui/p/chromium/builders/ci/mac12-arm64-rel-tests/15213/overview
>
> Original change's description:
> > Prerender: Run WPT for CSP with target hint
> >
> > Bug: 1501674
> > Change-Id: I7428467793000f1f37acdcde0b5310a9a3b364d7
> > Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5043782
> > Reviewed-by: Lingqi Chi <lingqi@chromium.org>
> > Commit-Queue: Hiroki Nakagawa <nhiroki@chromium.org>
> > Cr-Commit-Position: refs/heads/main@{#1226729}
>
> Bug: 1503635
> Change-Id: If7314c3814251fe6d92191e3deab3249c7396d2a
> No-Presubmit: true
> No-Tree-Checks: true
> No-Try: true
> Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5043730
> Owners-Override: Andreea Costinas <acostinas@google.com>
> Reviewed-by: Andreea Costinas <acostinas@google.com>
> Reviewed-by: Oleg Davydov <burunduk@chromium.org>
> Bot-Commit: Rubber Stamper <rubber-stamper@appspot.gserviceaccount.com>
> Commit-Queue: Oleg Davydov <burunduk@chromium.org>
> Cr-Commit-Position: refs/heads/main@{#1226765}
Bug: 1503635
Change-Id: I788157400410f8b0e8bfcd4af9d7b047a4e7057a
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5047871
Bot-Commit: Rubber Stamper <rubber-stamper@appspot.gserviceaccount.com>
Reviewed-by: Lingqi Chi <lingqi@chromium.org>
Commit-Queue: Hiroki Nakagawa <nhiroki@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1227331}
diff --git a/speculation-rules/prerender/csp-script-src-elem-inline-speculation-rules.html b/speculation-rules/prerender/csp-script-src-elem-inline-speculation-rules.html
index 6268918..7f33c32 100644
--- a/speculation-rules/prerender/csp-script-src-elem-inline-speculation-rules.html
+++ b/speculation-rules/prerender/csp-script-src-elem-inline-speculation-rules.html
@@ -1,4 +1,6 @@
<!DOCTYPE html>
+<meta name="variant" content="?target_hint=_self">
+<meta name="variant" content="?target_hint=_blank">
<meta name="timeout" content="long">
<script src="/common/utils.js"></script>
<script src="/resources/testharness.js"></script>
@@ -17,7 +19,7 @@
// Open the test runner in a popup - it will prerender itself, record the
// test results, and send them back to this harness.
const url =
- `resources/csp-script-src-elem-inline-speculation-rules.html?key=${key}`;
+ `resources/csp-script-src-elem-inline-speculation-rules.html?key=${key}&target_hint=${getTargetHint()}`;
window.open(url, '_blank', 'noopener');
// Wait until the test sends us the results.
diff --git a/speculation-rules/prerender/csp-script-src-inline-speculation-rules.html b/speculation-rules/prerender/csp-script-src-inline-speculation-rules.html
index 6c3a817..1d5b35c 100644
--- a/speculation-rules/prerender/csp-script-src-inline-speculation-rules.html
+++ b/speculation-rules/prerender/csp-script-src-inline-speculation-rules.html
@@ -1,5 +1,7 @@
<!DOCTYPE html>
<meta name="timeout" content="long">
+<meta name="variant" content="?target_hint=_self">
+<meta name="variant" content="?target_hint=_blank">
<script src="/common/utils.js"></script>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
@@ -17,7 +19,7 @@
// Open the test runner in a popup - it will prerender itself, record the
// test results, and send them back to this harness.
const url =
- `resources/csp-script-src-inline-speculation-rules.html?key=${key}`;
+ `resources/csp-script-src-inline-speculation-rules.html?key=${key}&target_hint=${getTargetHint()}`;
window.open(url, '_blank', 'noopener');
// Wait until the test sends us the results.
diff --git a/speculation-rules/prerender/csp-script-src-self.html b/speculation-rules/prerender/csp-script-src-self.html
index 46fbfd7..86cf9de 100644
--- a/speculation-rules/prerender/csp-script-src-self.html
+++ b/speculation-rules/prerender/csp-script-src-self.html
@@ -1,4 +1,6 @@
<!DOCTYPE html>
+<meta name="variant" content="?target_hint=_self">
+<meta name="variant" content="?target_hint=_blank">
<meta name="timeout" content="long">
<script src="/common/utils.js"></script>
<script src="/resources/testharness.js"></script>
@@ -17,7 +19,7 @@
// Open the test runner in a popup - it will prerender itself, record the
// test results, and send them back to this harness.
const url =
- `resources/csp-script-src-self.html?key=${key}`;
+ `resources/csp-script-src-self.html?key=${key}&target_hint=${getTargetHint()}`;
window.open(url, '_blank', 'noopener');
// Wait until the test sends us the results.
diff --git a/speculation-rules/prerender/csp-script-src-strict-dynamic.html b/speculation-rules/prerender/csp-script-src-strict-dynamic.html
index d84ea3e..d5d8079 100644
--- a/speculation-rules/prerender/csp-script-src-strict-dynamic.html
+++ b/speculation-rules/prerender/csp-script-src-strict-dynamic.html
@@ -1,4 +1,6 @@
<!DOCTYPE html>
+<meta name="variant" content="?target_hint=_self">
+<meta name="variant" content="?target_hint=_blank">
<meta name="timeout" content="long">
<script src="/common/utils.js"></script>
<script src="/resources/testharness.js"></script>
@@ -17,7 +19,7 @@
// Open the test runner in a popup - it will prerender itself, record the
// test results, and send them back to this harness.
const url =
- `resources/csp-script-src-strict-dynamic.html?key=${key}`;
+ `resources/csp-script-src-strict-dynamic.html?key=${key}&target_hint=${getTargetHint()}`;
window.open(url, '_blank', 'noopener');
// Wait until the test sends us the results.
diff --git a/speculation-rules/prerender/csp-script-src-unsafe-inline.html b/speculation-rules/prerender/csp-script-src-unsafe-inline.html
index ea2879b..b9b3092 100644
--- a/speculation-rules/prerender/csp-script-src-unsafe-inline.html
+++ b/speculation-rules/prerender/csp-script-src-unsafe-inline.html
@@ -1,4 +1,6 @@
<!DOCTYPE html>
+<meta name="variant" content="?target_hint=_self">
+<meta name="variant" content="?target_hint=_blank">
<meta name="timeout" content="long">
<script src="/common/utils.js"></script>
<script src="/resources/testharness.js"></script>
@@ -17,7 +19,7 @@
// Open the test runner in a popup - it will prerender itself, record the
// test results, and send them back to this harness.
const url =
- `resources/csp-script-src-unsafe-inline.html?key=${key}`;
+ `resources/csp-script-src-unsafe-inline.html?key=${key}&target_hint=${getTargetHint()}`;
window.open(url, '_blank', 'noopener');
// Wait until the test sends us the results.
diff --git a/speculation-rules/prerender/resources/csp-script-src.js b/speculation-rules/prerender/resources/csp-script-src.js
index 866acaa..6107819 100644
--- a/speculation-rules/prerender/resources/csp-script-src.js
+++ b/speculation-rules/prerender/resources/csp-script-src.js
@@ -3,6 +3,9 @@
// Take a key used for storing a test result in the server.
const key = params.get('key');
+// Take a target hint to decide a target context for prerendering.
+const rule_extras = {'target_hint': getTargetHint()};
+
// Speculation rules injection is blocked in the csp-script-src 'self' test.
const block = location.pathname.endsWith('csp-script-src-self.html');
@@ -37,7 +40,7 @@
});
}
- startPrerendering(url.toString());
+ startPrerendering(url.toString(), rule_extras);
// Wait until the prerendered page signals us it's ready to close.
nextValueFromServer(done_key).then(() => {