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

Test base URL with multiple globals for WebSocket #39978

Merged
merged 3 commits into from
May 16, 2023
Merged
Show file tree
Hide file tree
Changes from 2 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
2 changes: 2 additions & 0 deletions websockets/multi-globals/url-parsing/current/current.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
<!DOCTYPE html>
<title>Current page used as a test helper</title>
13 changes: 13 additions & 0 deletions websockets/multi-globals/url-parsing/incumbent/incumbent.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<!DOCTYPE html>
<title>Incumbent page used as a test helper</title>

<iframe src="../current/current.html" id="current"></iframe>

<script>
const current = document.querySelector("#current").contentWindow;

window.hello = () => {
window.ws = new current.WebSocket('foo');
ws.close();
};
</script>
19 changes: 19 additions & 0 deletions websockets/multi-globals/url-parsing/url-parsing.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<!DOCTYPE html>
<title>Multiple globals for base URL in WebSocket constructor</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>

<!-- This is the entry global -->

<iframe src="incumbent/incumbent.html"></iframe>

<script>
async_test((t) => {
onload = t.step_func_done(() => {
frames[0].hello();
const expectedUrl = new URL('current/foo', location.href); // TODO WebSocket spec says relevant
expectedUrl.protocol = 'ws:';
assert_equals(frames[0].ws.url, expectedUrl.href);
});
});
</script>