Skip to content
Permalink
Browse files
Remove deprecated uppercase URL attribute alias on WebSocket interface
Remove deprecated uppercase URL attribute alias on WebSocket interface
https://bugs.webkit.org/show_bug.cgi?id=248781

Reviewed by Chris Dumez.

This patch is to align Webkit with Blink / Chromium, Gecko / Firefox and Web-Specification:

https://html.spec.whatwg.org/multipage/comms.html#the-websocket-interface

Partial Merge - https://chromium.googlesource.com/chromium/blink/+/825c9732ce83f380fadfc062331cc12495e5eb12

The `URL` attribute is from early iterations of the spec and was
maintained for compatibility even after `url` was standardized but now it is not in the latest web-specification and was removed from Blink in 2015 as well.

* Source/WebCore/Modules/websockets/WebSocket.idl: Remove 'URL' attribute and also add link to web-spec
* LayoutTests/http/tests/websocket/tests/hybi/network-process-crash-error.html: Rebaselined
* LayoutTests/http/tests/websocket/tests/hybi/simple.html: Rebaselined
* LayoutTests/http/tests/websocket/tests/hybi/url-attribute.html: Rebaselined
* LayoutTests/http/tests/websocket/tests/hybi/url-attribute-expected.txt: Rebaselined
* LayoutTests/http/tests/websocket/tests/hybi/url-parsing.html: Rebaselined
* LayoutTests/imported/w3c/web-platform-tests/websockets/interfaces/WebSocket/url/004-expected.txt: Rebaselined
* LayoutTests/http/tests/websockets/tests/hybi/url-parsing-expected.txt: Rebaselined
* LayoutTests/platform/glib/imported/w3c/web-platform-tests/websockets/interfaces/WebSocket/url/004-expected.txt: Rebaselined
* LayoutTests/http/tests/websocket/tests/hybi/simple-wss.html: Rebaselined

Canonical link: https://commits.webkit.org/257467@main
  • Loading branch information
Ahmad-S792 authored and Ahmad Saleem committed Dec 7, 2022
1 parent 9ddfeb6 commit a05af340527ab26ff2e81de10b6630b25b83e922
Show file tree
Hide file tree
Showing 10 changed files with 18 additions and 19 deletions.
@@ -11,7 +11,7 @@
}

var ws = new WebSocket("ws://127.0.0.1:8880/websocket/tests/hybi/slow-reply");
alert("Created a socket to '" + ws.URL + "'; readyState " + ws.readyState + ".");
alert("Created a socket to '" + ws.url + "'; readyState " + ws.readyState + ".");

ws.onopen = function()
{
@@ -21,7 +21,7 @@
}

var ws = new WebSocket("wss://127.0.0.1:9323/websocket/tests/hybi/simple");
debug("Created a socket to '" + ws.URL + "'; readyState " + ws.readyState + ".");
debug("Created a socket to '" + ws.url + "'; readyState " + ws.readyState + ".");

ws.onopen = function()
{
@@ -18,7 +18,7 @@
}

var ws = new WebSocket("ws://127.0.0.1:8880/websocket/tests/hybi/simple");
debug("Created a socket to '" + ws.URL + "'; readyState " + ws.readyState + ".");
debug("Created a socket to '" + ws.url + "'; readyState " + ws.readyState + ".");

ws.onopen = function()
{
@@ -1,10 +1,9 @@
Both .URL and .url attributes should work (for compatibility reasons).
.url attribute should work, previously supported .URL should not.

On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".

PASS ws.url is "ws://127.0.0.1:8880/"
PASS ws.URL is "ws://127.0.0.1:8880/"
PASS ws.URL === ws.url is true
PASS ws.URL is undefined.
PASS successfullyParsed is true

TEST COMPLETE
@@ -8,14 +8,13 @@
<div id="console"></div>
<script type="text/javascript">

description("Both .URL and .url attributes should work (for compatibility reasons).");
description(".url attribute should work, previously supported .URL should not.");

var url = "ws://127.0.0.1:8880/";
var ws = new WebSocket(url);

shouldBeEqualToString("ws.url", url);
shouldBeEqualToString("ws.URL", url);
shouldBeTrue("ws.URL === ws.url");
shouldBeUndefined("ws.URL");

</script>
<script src="../../../../js-test-resources/js-test-post.js"></script>
@@ -13,9 +13,9 @@ PASS new WebSocket(null) threw exception SyntaxError: The string did not match t
PASS new WebSocket("ws://javascript:a") threw exception SyntaxError: The string did not match the expected pattern..
PASS new WebSocket("/applet") threw exception SyntaxError: The string did not match the expected pattern..
PASS new WebSocket("javascript:a") threw exception SyntaxError: The string did not match the expected pattern..
PASS (new WebSocket("ws://127.0.0.1:8880/a/../websocket/tests/hybi/simple")).URL is "ws://127.0.0.1:8880/websocket/tests/hybi/simple"
PASS (new WebSocket("ws://127.0.0.1:8880/websocket/tests/hybi/simple?")).URL is "ws://127.0.0.1:8880/websocket/tests/hybi/simple?"
PASS (new WebSocket("ws://127.0.0.1:8880/websocket/tests/hybi/simple?k=v")).URL is "ws://127.0.0.1:8880/websocket/tests/hybi/simple?k=v"
PASS (new WebSocket("ws://127.0.0.1:8880/a/../websocket/tests/hybi/simple")).url is "ws://127.0.0.1:8880/websocket/tests/hybi/simple"
PASS (new WebSocket("ws://127.0.0.1:8880/websocket/tests/hybi/simple?")).url is "ws://127.0.0.1:8880/websocket/tests/hybi/simple?"
PASS (new WebSocket("ws://127.0.0.1:8880/websocket/tests/hybi/simple?k=v")).url is "ws://127.0.0.1:8880/websocket/tests/hybi/simple?k=v"
PASS new WebSocket("ws://127.0.0.1/path#") threw exception SyntaxError: The string did not match the expected pattern..
PASS new WebSocket("ws://127.0.0.1/path#fragment") threw exception SyntaxError: The string did not match the expected pattern..
PASS successfullyParsed is true
@@ -26,9 +26,9 @@

// Resolve the url string using the resolve a Web address algorithm.
// Use 127.0.0.1:8880 and existing ws handler to make sure we don't receive unexpected response (so no console message appears)
shouldBe('(new WebSocket("ws://127.0.0.1:8880/a/../websocket/tests/hybi/simple")).URL', '"ws://127.0.0.1:8880/websocket/tests/hybi/simple"');
shouldBe('(new WebSocket("ws://127.0.0.1:8880/websocket/tests/hybi/simple?")).URL', '"ws://127.0.0.1:8880/websocket/tests/hybi/simple?"');
shouldBe('(new WebSocket("ws://127.0.0.1:8880/websocket/tests/hybi/simple?k=v")).URL', '"ws://127.0.0.1:8880/websocket/tests/hybi/simple?k=v"');
shouldBe('(new WebSocket("ws://127.0.0.1:8880/a/../websocket/tests/hybi/simple")).url', '"ws://127.0.0.1:8880/websocket/tests/hybi/simple"');
shouldBe('(new WebSocket("ws://127.0.0.1:8880/websocket/tests/hybi/simple?")).url', '"ws://127.0.0.1:8880/websocket/tests/hybi/simple?"');
shouldBe('(new WebSocket("ws://127.0.0.1:8880/websocket/tests/hybi/simple?k=v")).url', '"ws://127.0.0.1:8880/websocket/tests/hybi/simple?k=v"');

// draft-hixie-thewebsocketprotocol-60 says If /url/ has a <fragment>
// component, then fail the parsing Web Socket URLs, so throw a SYNTAX_ERR
@@ -1,3 +1,3 @@

FAIL WebSockets: 'URL' assert_equals: expected (undefined) undefined but got (string) "ws://localhost:49001/"
PASS WebSockets: 'URL'

@@ -1,3 +1,3 @@

FAIL WebSockets: 'URL' assert_equals: expected (undefined) undefined but got (string) "ws://web-platform.test:49001/"
PASS WebSockets: 'URL'

@@ -1,6 +1,6 @@
/*
* Copyright (C) 2009 Google Inc. All rights reserved.
* Copyright (C) 2010, 2011 Apple Inc. All Rights Reserved.
* Copyright (C) 2010-2022 Apple Inc. All Rights Reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
@@ -29,6 +29,8 @@
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/

// https://html.spec.whatwg.org/multipage/comms.html#the-websocket-interface

[
ActiveDOMObject,
Exposed=(Window,Worker),
@@ -37,7 +39,6 @@
[CallWith=CurrentScriptExecutionContext] constructor(USVString url, optional sequence<DOMString> protocols = []);
[CallWith=CurrentScriptExecutionContext] constructor(USVString url, DOMString protocol);

readonly attribute USVString URL; // Lowercased .url is the one in the spec, but leaving .URL for compatibility reasons.
readonly attribute USVString url;

const unsigned short CONNECTING = 0;

0 comments on commit a05af34

Please sign in to comment.