Skip to content

Commit 81775b0

Browse files
committed
Add WPT test for Document-Policy: expect-no-linked-resources
This PR adds a tentative and optional test case for whatwg/html#10718
1 parent d8cdb54 commit 81775b0

5 files changed

+54
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
<!DOCTYPE html>
2+
<meta charset=utf-8>
3+
<title>Speculative parsing, expect-no-linked-resources Document-Policy</title>
4+
<meta name="timeout" content="long">
5+
<script src=/resources/testharness.js></script>
6+
<script src=/resources/testharnessreport.js></script>
7+
<script src="/resources/testdriver.js"></script>
8+
<script src="/resources/testdriver-vendor.js"></script>
9+
<script src="/common/utils.js"></script>
10+
<script src="stash.js"></script>
11+
<script>
12+
promise_test(t => new Promise((resolve, reject) => {
13+
const uuid = token();
14+
async function on_load_test_document() {
15+
resolve(await get_results(uuid));
16+
}
17+
18+
test_driver.bless('Open a URL with expect-no-linked-resources Document-Policy', () => {
19+
const popup = window.open(`/html/syntax/speculative-parsing/expect-no-linked-resources/no-speculative-fetch.tentative.optional.sub.html?pipe=sub&uuid=${uuid}`, '_blank');
20+
popup.addEventListener('load', on_load_test_document, false);
21+
});
22+
}).then(result => {
23+
assert_equals(result, '', 'speculative case fetched');
24+
}), `no-linked-resources speculative hint was ignored`);
25+
26+
</script>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
<!doctype html>
2+
<title>Navigating to a page with expect-no-linked-resources</title>
3+
4+
<body>
5+
<script>
6+
document.write('<plaintext>');
7+
</script>
8+
<img
9+
src="/html/syntax/speculative-parsing/expect-no-linked-resources/stash.py?action=put&uuid={{GET[uuid]}}&encodingcheck=&Gbreve;">
10+
</body>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Document-Policy: expect-no-linked-resources
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
// Fetch test results from the Stash
2+
async function get_results(uuid) {
3+
const response = await fetch(`/html/syntax/speculative-parsing/expect-no-linked-resources/stash.py?action=get&uuid=${uuid}`);
4+
const text = await response.text();
5+
return text;
6+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import time
2+
3+
def main(request, response):
4+
if request.GET[b"action"] == b"put":
5+
# Received result data from target page
6+
request.server.stash.put(request.GET[b"uuid"], request.GET[b"uuid"], u'/expect-no-linked-resources/')
7+
return u"ok"
8+
else:
9+
# Request for result data from test page
10+
value = request.server.stash.take(request.GET[b"uuid"], u'/expect-no-linked-resources/')
11+
return value

0 commit comments

Comments
 (0)