summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ext/websocket/01_websocket.js9
-rw-r--r--tools/wpt/expectation.json5
2 files changed, 12 insertions, 2 deletions
diff --git a/ext/websocket/01_websocket.js b/ext/websocket/01_websocket.js
index 635979174..3f4e16b90 100644
--- a/ext/websocket/01_websocket.js
+++ b/ext/websocket/01_websocket.js
@@ -19,6 +19,7 @@ import {
MessageEvent,
} from "ext:deno_web/02_event.js";
import { Blob, BlobPrototype } from "ext:deno_web/09_file.js";
+import { getLocationHref } from "ext:deno_web/12_location.js";
const primordials = globalThis.__bootstrap.primordials;
const {
ArrayBufferPrototype,
@@ -143,11 +144,17 @@ class WebSocket extends EventTarget {
let wsURL;
try {
- wsURL = new URL(url);
+ wsURL = new URL(url, getLocationHref());
} catch (e) {
throw new DOMException(e.message, "SyntaxError");
}
+ if (wsURL.protocol === "http:") {
+ wsURL.protocol = "ws:";
+ } else if (wsURL.protocol === "https:") {
+ wsURL.protocol = "wss:";
+ }
+
if (wsURL.protocol !== "ws:" && wsURL.protocol !== "wss:") {
throw new DOMException(
"Only ws & wss schemes are allowed in a WebSocket URL.",
diff --git a/tools/wpt/expectation.json b/tools/wpt/expectation.json
index 5aab514cd..520ac1a30 100644
--- a/tools/wpt/expectation.json
+++ b/tools/wpt/expectation.json
@@ -7229,7 +7229,10 @@
"remove-own-iframe-during-onerror.window.html": false,
"remove-own-iframe-during-onerror.window.html?wpt_flags=h2": false,
"remove-own-iframe-during-onerror.window.html?wss": false,
- "Create-on-worker-shutdown.any.worker.html": false
+ "Create-on-worker-shutdown.any.worker.html": false,
+ "Create-http-urls.any.html": true,
+ "Create-invalid-urls.any.html": true,
+ "Create-non-absolute-url.any.html": true
},
"workers": {
"Worker-base64.any.worker.html": true,