Skip to content
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

Add WPT test for Document-Policy: expect-no-linked-resources #49617

Merged
merged 2 commits into from
Dec 11, 2024
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
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<!DOCTYPE html>
<meta charset=utf-8>
<title>Speculative parsing, expect-no-linked-resources Document-Policy</title>
<meta name="timeout" content="long">
<script src=/resources/testharness.js></script>
<script src=/resources/testharnessreport.js></script>
<script src="/resources/testdriver.js"></script>
<script src="/resources/testdriver-vendor.js"></script>
<script src="/common/utils.js"></script>
<script>
async function get_results(uuid) {
const response = await fetch(`/html/syntax/speculative-parsing/expect-no-linked-resources/resources/stash.py?action=get&uuid=${uuid}`);
return await response.text();
}

promise_test(async () => {
const uuid = token();

await test_driver.bless('Open a URL with expect-no-linked-resources Document-Policy');
const popup = window.open(`/html/syntax/speculative-parsing/expect-no-linked-resources/resources/no-speculative-fetch.sub.html?pipe=sub&uuid=${uuid}`, '_blank');
await new Promise(resolve => popup.addEventListener('load', resolve));

const result = await get_results(uuid);
assert_equals(result, '', 'speculative case fetched');
}, `expect-no-linked-resources hint was ignored`);
</script>
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<!doctype html>
<title>Navigating to a page with expect-no-linked-resources</title>

<body>
<script>
document.write('<plaintext>');
</script>
<img
src="/html/syntax/speculative-parsing/expect-no-linked-resources/resources/stash.py?action=put&uuid={{GET[uuid]}}">
</body>
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Document-Policy: expect-no-linked-resources
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import time

def main(request, response):
if request.GET[b"action"] == b"put":
# Received result data from target page
request.server.stash.put(request.GET[b"uuid"], request.GET[b"uuid"], u'/expect-no-linked-resources/')
return u"ok"
else:
# Request for result data from test page
value = request.server.stash.take(request.GET[b"uuid"], u'/expect-no-linked-resources/')
return value