diff --git a/dom/websocket/WebSocket.cpp b/dom/websocket/WebSocket.cpp index 3ea2b63f5f678..bac4cb734353a 100644 --- a/dom/websocket/WebSocket.cpp +++ b/dom/websocket/WebSocket.cpp @@ -552,6 +552,13 @@ nsIWebSocketImpl h " # +include +" +nsIURIMutator +. +h +" +# define OPEN_EVENT_STRING u @@ -887,6 +894,9 @@ const nsAString & aURL +nsIURI +* +aBaseURI ) ; nsresult @@ -4733,6 +4743,17 @@ return true ; } +nsIPrincipal +* +principal += +mWorkerPrivate +- +> +GetPrincipal +( +) +; mErrorCode = mImpl @@ -4745,12 +4766,7 @@ jsapi cx ( ) -mWorkerPrivate -- -> -GetPrincipal -( -) +principal - > SchemeIs @@ -4759,12 +4775,7 @@ SchemeIs https " ) -doc -- -> -NodePrincipal -( -) +principal mClientInfo mWorkerPrivate - @@ -7217,11 +7228,25 @@ IsSystemPrincipal ( ) ; +nsCOMPtr +< +nsIURI +> +baseURI += +aPrincipal +- +> +GetURI +( +) +; rv = ParseURL ( aURL +baseURI ) ; NS_ENSURE_SUCCESS @@ -9239,6 +9264,9 @@ const nsAString & aURL +nsIURI +* +aBaseURI ) { AssertIsOnMainThread @@ -9297,6 +9325,8 @@ getter_AddRefs uri ) aURL +nullptr +aBaseURI ) ; NS_ENSURE_SUCCESS @@ -9324,18 +9354,17 @@ rv NS_ERROR_DOM_SYNTAX_ERR ) ; -bool -hasRef +nsAutoCString +scheme ; rv = parsedURL - > -GetHasRef +GetScheme ( -& -hasRef +scheme ) ; NS_ENSURE_TRUE @@ -9347,21 +9376,92 @@ rv & & ! -hasRef +scheme +. +IsEmpty +( +) NS_ERROR_DOM_SYNTAX_ERR ) ; -nsAutoCString +if +( scheme += += +" +http +" +| +| +scheme += += +" +https +" +) +{ +scheme += +scheme += += +" +https +" +? +" +wss +" +_ns +: +" +ws +" +_ns +; +NS_MutateURI +mutator +( +parsedURL +) +; +mutator +. +SetScheme +( +scheme +) +; +rv += +mutator +. +Finalize +( +parsedURL +) +; +NS_ENSURE_SUCCESS +( +rv +NS_ERROR_DOM_SYNTAX_ERR +) +; +} +bool +hasRef ; rv = parsedURL - > -GetScheme +GetHasRef ( -scheme +& +hasRef ) ; NS_ENSURE_TRUE @@ -9373,11 +9473,7 @@ rv & & ! -scheme -. -IsEmpty -( -) +hasRef NS_ERROR_DOM_SYNTAX_ERR ) ; diff --git a/dom/websocket/tests/file_websocket_wsh.py b/dom/websocket/tests/file_websocket_wsh.py index b9cad72c0bc76..35b44144c5a91 100644 --- a/dom/websocket/tests/file_websocket_wsh.py +++ b/dom/websocket/tests/file_websocket_wsh.py @@ -278,6 +278,48 @@ " test - +1 +" +or +request +. +ws_protocol += += +" +test +- +4 +" +: + +msgutil +. +send_message +( +request +" +server +data +" +) + +msgutil +. +close_connection +( +request +) + +elif +request +. +ws_protocol += += +" +test +- 2 . 1 diff --git a/dom/websocket/tests/websocket_tests.js b/dom/websocket/tests/websocket_tests.js index 694f5fefa5b90..04c415a60a517 100644 --- a/dom/websocket/tests/websocket_tests.js +++ b/dom/websocket/tests/websocket_tests.js @@ -13,8 +13,6 @@ resolve reject ) { -try -{ var ws = @@ -41,38 +39,56 @@ tests / file_websocket " +" +test +- +1 +" ) ; +ws +. +onmessage += +function +( +) +{ ok ( -false +true " -test1 -failed +created +websocket +with +http +scheme " ) ; } -catch +; +ws +. +onclose += +function ( e ) { -ok +shouldCloseCleanly ( -true -" -test1 -failed -" +e ) ; -} resolve ( ) ; } +; +} ) ; } @@ -449,8 +465,6 @@ resolve reject ) { -try -{ var ws = @@ -459,42 +473,56 @@ CreateTestWS " file_websocket " -) -; -ok -( -false " test - 4 -failed " ) ; -} -catch +ws +. +onmessage += +function ( -e ) { ok ( true " -test -- -4 -failed +created +websocket +with +relative +scheme " ) ; } +; +ws +. +onclose += +function +( +e +) +{ +shouldCloseCleanly +( +e +) +; resolve ( ) ; } +; +} ) ; } diff --git a/testing/web-platform/meta/websockets/Create-http-urls.any.js.ini b/testing/web-platform/meta/websockets/Create-http-urls.any.js.ini deleted file mode 100644 index 8c0c227fd5b85..0000000000000 --- a/testing/web-platform/meta/websockets/Create-http-urls.any.js.ini +++ /dev/null @@ -1,50 +0,0 @@ -[ -Create -- -http -- -urls -. -any -. -worker -. -html -] -[ -WebSocket -: -ensure -both -HTTP -schemes -are -supported -] -expected -: -FAIL -[ -Create -- -http -- -urls -. -any -. -html -] -[ -WebSocket -: -ensure -both -HTTP -schemes -are -supported -] -expected -: -FAIL diff --git a/testing/web-platform/meta/websockets/Create-invalid-urls.any.js.ini b/testing/web-platform/meta/websockets/Create-invalid-urls.any.js.ini deleted file mode 100644 index bbcb29765eff5..0000000000000 --- a/testing/web-platform/meta/websockets/Create-invalid-urls.any.js.ini +++ /dev/null @@ -1,192 +0,0 @@ -[ -Create -- -invalid -- -urls -. -any -. -worker -. -html -? -wpt_flags -= -h2 -] -expected -: -if -( -os -= -= -" -android -" -) -and -fission -: -[ -OK -TIMEOUT -] -[ -Create -- -invalid -- -urls -. -any -. -html -] -expected -: -if -( -os -= -= -" -android -" -) -and -fission -: -[ -OK -TIMEOUT -] -[ -Create -- -invalid -- -urls -. -any -. -html -? -wss -] -expected -: -if -( -os -= -= -" -android -" -) -and -fission -: -[ -OK -TIMEOUT -] -[ -Create -- -invalid -- -urls -. -any -. -worker -. -html -? -wss -] -expected -: -if -( -os -= -= -" -android -" -) -and -fission -: -[ -OK -TIMEOUT -] -[ -Create -- -invalid -- -urls -. -any -. -worker -. -html -] -expected -: -if -( -os -= -= -" -android -" -) -and -fission -: -[ -OK -TIMEOUT -] -[ -Create -- -invalid -- -urls -. -any -. -html -? -wpt_flags -= -h2 -] -expected -: -if -( -os -= -= -" -android -" -) -and -fission -: -[ -OK -TIMEOUT -] diff --git a/testing/web-platform/meta/websockets/Create-non-absolute-url.any.js.ini b/testing/web-platform/meta/websockets/Create-non-absolute-url.any.js.ini deleted file mode 100644 index bf5c25ad674fd..0000000000000 --- a/testing/web-platform/meta/websockets/Create-non-absolute-url.any.js.ini +++ /dev/null @@ -1,324 +0,0 @@ -[ -Create -- -non -- -absolute -- -url -. -any -. -html -] -expected -: -if -( -os -= -= -" -android -" -) -and -fission -: -[ -OK -TIMEOUT -] -[ -Create -WebSocket -- -Pass -a -non -absolute -URL -: -test -] -expected -: -FAIL -[ -Create -WebSocket -- -Pass -a -non -absolute -URL -: -? -] -expected -: -FAIL -[ -Create -WebSocket -- -Pass -a -non -absolute -URL -: -null -] -expected -: -FAIL -[ -Create -WebSocket -- -Pass -a -non -absolute -URL -: -123 -] -expected -: -FAIL -[ -Create -- -non -- -absolute -- -url -. -any -. -html -? -wpt_flags -= -h2 -] -expected -: -if -( -os -= -= -" -android -" -) -and -fission -: -[ -OK -TIMEOUT -] -[ -Create -- -non -- -absolute -- -url -. -any -. -html -? -wss -] -expected -: -if -( -os -= -= -" -android -" -) -and -fission -: -[ -OK -TIMEOUT -] -[ -Create -- -non -- -absolute -- -url -. -any -. -worker -. -html -? -wpt_flags -= -h2 -] -expected -: -if -( -os -= -= -" -android -" -) -and -fission -: -[ -OK -TIMEOUT -] -[ -Create -- -non -- -absolute -- -url -. -any -. -worker -. -html -? -wss -] -expected -: -if -( -os -= -= -" -android -" -) -and -fission -: -[ -OK -TIMEOUT -] -[ -Create -- -non -- -absolute -- -url -. -any -. -worker -. -html -] -expected -: -if -( -os -= -= -" -android -" -) -and -fission -: -[ -OK -TIMEOUT -] -[ -Create -WebSocket -- -Pass -a -non -absolute -URL -: -test -] -expected -: -FAIL -[ -Create -WebSocket -- -Pass -a -non -absolute -URL -: -? -] -expected -: -FAIL -[ -Create -WebSocket -- -Pass -a -non -absolute -URL -: -null -] -expected -: -FAIL -[ -Create -WebSocket -- -Pass -a -non -absolute -URL -: -123 -] -expected -: -FAIL diff --git a/testing/web-platform/meta/websockets/Create-url-with-windows-1252-encoding.html.ini b/testing/web-platform/meta/websockets/Create-url-with-windows-1252-encoding.html.ini deleted file mode 100644 index 227c8d578dd52..0000000000000 --- a/testing/web-platform/meta/websockets/Create-url-with-windows-1252-encoding.html.ini +++ /dev/null @@ -1,34 +0,0 @@ -[ -Create -- -url -- -with -- -windows -- -1252 -- -encoding -. -html -] -[ -URL -' -s -percent -- -encoding -is -always -in -UTF -- -8 -for -WebSocket -] -expected -: -FAIL diff --git a/testing/web-platform/meta/websockets/multi-globals/url-parsing/url-parsing.html.ini b/testing/web-platform/meta/websockets/multi-globals/url-parsing/url-parsing.html.ini deleted file mode 100644 index 3c76263a29378..0000000000000 --- a/testing/web-platform/meta/websockets/multi-globals/url-parsing/url-parsing.html.ini +++ /dev/null @@ -1,20 +0,0 @@ -[ -url -- -parsing -. -html -] -[ -Multiple -globals -for -base -URL -in -WebSocket -constructor -] -expected -: -FAIL