-
Notifications
You must be signed in to change notification settings - Fork 3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Test base URL with multiple globals for WebSocket
- Loading branch information
Showing
1 changed file
with
32 additions
and
0 deletions.
There are no files selected for viewing
32 changes: 32 additions & 0 deletions
32
.../browsing-the-web/navigating-across-documents/multiple-globals/context-for-websocket.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
<!DOCTYPE html> | ||
<script src="/resources/testharness.js"></script> | ||
<script src="/resources/testharnessreport.js"></script> | ||
<script src="resources/context-helper.js"></script> | ||
<script> | ||
window.scriptToRun = ` | ||
const result = {}; | ||
try { | ||
const ws = new WebSocket('foo'); | ||
ws.close(); | ||
result.url = ws.url; | ||
} catch (ex) { | ||
result.url = ex.name; | ||
} | ||
top.postMessage(result, '*'); | ||
`; | ||
|
||
async_test(t => { | ||
window.addEventListener("message", t.step_func_done(function(e) { | ||
// Base URL used for parsing a relative URL to `target` | ||
// should be the base URL of the relevant settings object in | ||
// https://websockets.spec.whatwg.org/#dom-websocket-websocket | ||
const expectedUrl = new URL('foo', relevantUrl); | ||
expectedUrl.protocol = 'ws:'; | ||
assert_equals( | ||
e.data.url, | ||
expectedUrl.href, | ||
'Base URL should use the relevant settings object'); | ||
})); | ||
}, 'URL resolution for WebSocket'); | ||
</script> | ||
<iframe id="entry" src="entry/entry.html"></iframe> |