forked from web-platform-tests/wpt
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathresponse_block.tentative.sub.https.html
More file actions
44 lines (39 loc) · 1.74 KB
/
response_block.tentative.sub.https.html
File metadata and controls
44 lines (39 loc) · 1.74 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
<!DOCTYPE html>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<body>
<script>
// Test handling of blocked responses in CORB/ORB.
function probe() {
// We will cross-origin load a script resource that should get blocked by all
// versions of CORB/ORB. Three things may happen:
//
// 1, The script might execute. (CORB/ORB not supported. Or a bug.)
// 2, An empty response is injected: The script loads but nothing is executed.
// (Expected behaviour for CORB and "ORB v0.1".)
// 3, An error is injected and script loading aborts. (Expected for ORB.)
// A cross-origin response labelled as text/csv, which will call
// script_callback when executed.
const probe = "https://{{domains[www1]}}:{{ports[https][0]}}" +
"/fetch/corb/resources/response_block_probe.js";
// Load the probe as a script.
const script = document.createElement("script");
script.src = probe;
document.body.appendChild(script);
// Return a promise that will return a string description corresponding to the
// three conditions above. Not that a script_callback call is processed
// synchronously and hence will occur before the onload event is dispatched.
return new Promise((resolve, reject) => {
script.onload = _ => resolve("script loaded");
script.onerror = _ => resolve("script errored");
window.script_callback = _ => resolve("script executed");
});
}
promise_test(t => probe().then(
value => assert_equals(value, "script errored")),
"ORB: Expect error response.");
// This test ensures we're _not_ seeing CORB behaviour.
promise_test(t => probe().then(
value => assert_not_equals(value, "script loaded")),
"!CORB: CORB would have expected an empty response.");
</script>