Loading content/base/src/nsWebSocket.cpp +10 −10 Original line number Original line Diff line number Diff line Loading @@ -301,10 +301,14 @@ nsWebSocketEstablishedConnection::Init(nsWebSocket *aOwner) NS_ENSURE_SUCCESS(rv, rv); NS_ENSURE_SUCCESS(rv, rv); } } nsCString utf8Origin; nsCString asciiOrigin; CopyUTF16toUTF8(mOwner->mUTF16Origin, utf8Origin); rv = nsContentUtils::GetASCIIOrigin(mOwner->mPrincipal, asciiOrigin); NS_ENSURE_SUCCESS(rv, rv); ToLowerCase(asciiOrigin); rv = mWebSocketChannel->AsyncOpen(mOwner->mURI, rv = mWebSocketChannel->AsyncOpen(mOwner->mURI, utf8Origin, this, nsnull); asciiOrigin, this, nsnull); NS_ENSURE_SUCCESS(rv, rv); NS_ENSURE_SUCCESS(rv, rv); return NS_OK; return NS_OK; Loading Loading @@ -1079,10 +1083,6 @@ nsWebSocket::ParseURL(const nsString& aURL) rv = parsedURL->GetQuery(query); rv = parsedURL->GetQuery(query); NS_ENSURE_SUCCESS(rv, NS_ERROR_DOM_SYNTAX_ERR); NS_ENSURE_SUCCESS(rv, NS_ERROR_DOM_SYNTAX_ERR); nsCString origin; rv = nsContentUtils::GetASCIIOrigin(mPrincipal, origin); NS_ENSURE_SUCCESS(rv, NS_ERROR_DOM_SYNTAX_ERR); if (scheme.LowerCaseEqualsLiteral("ws")) { if (scheme.LowerCaseEqualsLiteral("ws")) { mSecure = PR_FALSE; mSecure = PR_FALSE; mPort = (port == -1) ? DEFAULT_WS_SCHEME_PORT : port; mPort = (port == -1) ? DEFAULT_WS_SCHEME_PORT : port; Loading @@ -1093,8 +1093,8 @@ nsWebSocket::ParseURL(const nsString& aURL) return NS_ERROR_DOM_SYNTAX_ERR; return NS_ERROR_DOM_SYNTAX_ERR; } } ToLowerCase(origin); rv = nsContentUtils::GetUTFOrigin(parsedURL, mUTF16Origin); CopyUTF8toUTF16(origin, mUTF16Origin); NS_ENSURE_SUCCESS(rv, NS_ERROR_DOM_SYNTAX_ERR); mAsciiHost = host; mAsciiHost = host; ToLowerCase(mAsciiHost); ToLowerCase(mAsciiHost); Loading content/base/test/file_websocket_wsh.py +1 −12 Original line number Original line Diff line number Diff line Loading @@ -51,18 +51,7 @@ def web_socket_transfer_data(request): msgutil.send_message(request, resp.decode('utf-8')) msgutil.send_message(request, resp.decode('utf-8')) msgutil.close_connection(request) msgutil.close_connection(request) elif request.ws_protocol == "test-7": elif request.ws_protocol == "test-7": try: msgutil.send_message(request, "test-7 data") while not request.client_terminated: msgutil.receive_message(request) except msgutil.ConnectionTerminatedException, e: pass msgutil.send_message(request, "server data") msgutil.send_message(request, "server data") msgutil.send_message(request, "server data") msgutil.send_message(request, "server data") msgutil.send_message(request, "server data") time.sleep(30) msgutil.close_connection(request, True) elif request.ws_protocol == "test-10": elif request.ws_protocol == "test-10": msgutil.close_connection(request) msgutil.close_connection(request) elif request.ws_protocol == "test-11": elif request.ws_protocol == "test-11": Loading content/base/test/test_websocket.html +20 −20 Original line number Original line Diff line number Diff line Loading @@ -23,8 +23,7 @@ * 4. client tries to connect using a relative url; * 4. client tries to connect using a relative url; * 5. client uses an invalid protocol value; * 5. client uses an invalid protocol value; * 6. counter and encoding check; * 6. counter and encoding check; * 7. client calls close() and the server keeps sending messages and it doesn't * 7. onmessage event origin property check * send the close frame; * 8. client calls close() and the server sends the close frame in * 8. client calls close() and the server sends the close frame in * acknowledgement; * acknowledgement; * 9. client closes the connection before the ws connection is established; * 9. client closes the connection before the ws connection is established; Loading Loading @@ -326,25 +325,26 @@ function test6() function test7() function test7() { { // with pywebsockets for -06 ths test no longer does anything useful var ws = CreateTestWS("ws://sub2.test2.example.org/tests/content/base/test/file_websocket", "test-7"); // as the server handles the receipt of the close event directly, not var gotmsg = false; // as part of the wsh - so we cannot fake the non-clean close which is // what we're trying to do here. ok(true, "test disabled"); ws.onopen = function() current_test++; { ok(true, "test 7 open"); } ws.onmessage = function(e) { ok(true, "test 7 message"); ok(e.origin == "ws://sub2.test2.example.org", "onmessage origin set to ws:// host"); gotmsg = true; ws.close(); } ws.onclose = function(e) { ok(gotmsg, "recvd message in test 7 before close"); shouldCloseCleanly(e); doTest(8); doTest(8); }; // var ws = CreateTestWS("ws://mochi.test:8888/tests/content/base/test/file_websocket", "test-7"); // ws.onopen = function() // { // ws.close(); // } // ws.onclose = function(e) // { // shouldCloseNotCleanly(e); // doTest(8); // }; } } function test8() function test8() Loading Loading
content/base/src/nsWebSocket.cpp +10 −10 Original line number Original line Diff line number Diff line Loading @@ -301,10 +301,14 @@ nsWebSocketEstablishedConnection::Init(nsWebSocket *aOwner) NS_ENSURE_SUCCESS(rv, rv); NS_ENSURE_SUCCESS(rv, rv); } } nsCString utf8Origin; nsCString asciiOrigin; CopyUTF16toUTF8(mOwner->mUTF16Origin, utf8Origin); rv = nsContentUtils::GetASCIIOrigin(mOwner->mPrincipal, asciiOrigin); NS_ENSURE_SUCCESS(rv, rv); ToLowerCase(asciiOrigin); rv = mWebSocketChannel->AsyncOpen(mOwner->mURI, rv = mWebSocketChannel->AsyncOpen(mOwner->mURI, utf8Origin, this, nsnull); asciiOrigin, this, nsnull); NS_ENSURE_SUCCESS(rv, rv); NS_ENSURE_SUCCESS(rv, rv); return NS_OK; return NS_OK; Loading Loading @@ -1079,10 +1083,6 @@ nsWebSocket::ParseURL(const nsString& aURL) rv = parsedURL->GetQuery(query); rv = parsedURL->GetQuery(query); NS_ENSURE_SUCCESS(rv, NS_ERROR_DOM_SYNTAX_ERR); NS_ENSURE_SUCCESS(rv, NS_ERROR_DOM_SYNTAX_ERR); nsCString origin; rv = nsContentUtils::GetASCIIOrigin(mPrincipal, origin); NS_ENSURE_SUCCESS(rv, NS_ERROR_DOM_SYNTAX_ERR); if (scheme.LowerCaseEqualsLiteral("ws")) { if (scheme.LowerCaseEqualsLiteral("ws")) { mSecure = PR_FALSE; mSecure = PR_FALSE; mPort = (port == -1) ? DEFAULT_WS_SCHEME_PORT : port; mPort = (port == -1) ? DEFAULT_WS_SCHEME_PORT : port; Loading @@ -1093,8 +1093,8 @@ nsWebSocket::ParseURL(const nsString& aURL) return NS_ERROR_DOM_SYNTAX_ERR; return NS_ERROR_DOM_SYNTAX_ERR; } } ToLowerCase(origin); rv = nsContentUtils::GetUTFOrigin(parsedURL, mUTF16Origin); CopyUTF8toUTF16(origin, mUTF16Origin); NS_ENSURE_SUCCESS(rv, NS_ERROR_DOM_SYNTAX_ERR); mAsciiHost = host; mAsciiHost = host; ToLowerCase(mAsciiHost); ToLowerCase(mAsciiHost); Loading
content/base/test/file_websocket_wsh.py +1 −12 Original line number Original line Diff line number Diff line Loading @@ -51,18 +51,7 @@ def web_socket_transfer_data(request): msgutil.send_message(request, resp.decode('utf-8')) msgutil.send_message(request, resp.decode('utf-8')) msgutil.close_connection(request) msgutil.close_connection(request) elif request.ws_protocol == "test-7": elif request.ws_protocol == "test-7": try: msgutil.send_message(request, "test-7 data") while not request.client_terminated: msgutil.receive_message(request) except msgutil.ConnectionTerminatedException, e: pass msgutil.send_message(request, "server data") msgutil.send_message(request, "server data") msgutil.send_message(request, "server data") msgutil.send_message(request, "server data") msgutil.send_message(request, "server data") time.sleep(30) msgutil.close_connection(request, True) elif request.ws_protocol == "test-10": elif request.ws_protocol == "test-10": msgutil.close_connection(request) msgutil.close_connection(request) elif request.ws_protocol == "test-11": elif request.ws_protocol == "test-11": Loading
content/base/test/test_websocket.html +20 −20 Original line number Original line Diff line number Diff line Loading @@ -23,8 +23,7 @@ * 4. client tries to connect using a relative url; * 4. client tries to connect using a relative url; * 5. client uses an invalid protocol value; * 5. client uses an invalid protocol value; * 6. counter and encoding check; * 6. counter and encoding check; * 7. client calls close() and the server keeps sending messages and it doesn't * 7. onmessage event origin property check * send the close frame; * 8. client calls close() and the server sends the close frame in * 8. client calls close() and the server sends the close frame in * acknowledgement; * acknowledgement; * 9. client closes the connection before the ws connection is established; * 9. client closes the connection before the ws connection is established; Loading Loading @@ -326,25 +325,26 @@ function test6() function test7() function test7() { { // with pywebsockets for -06 ths test no longer does anything useful var ws = CreateTestWS("ws://sub2.test2.example.org/tests/content/base/test/file_websocket", "test-7"); // as the server handles the receipt of the close event directly, not var gotmsg = false; // as part of the wsh - so we cannot fake the non-clean close which is // what we're trying to do here. ok(true, "test disabled"); ws.onopen = function() current_test++; { ok(true, "test 7 open"); } ws.onmessage = function(e) { ok(true, "test 7 message"); ok(e.origin == "ws://sub2.test2.example.org", "onmessage origin set to ws:// host"); gotmsg = true; ws.close(); } ws.onclose = function(e) { ok(gotmsg, "recvd message in test 7 before close"); shouldCloseCleanly(e); doTest(8); doTest(8); }; // var ws = CreateTestWS("ws://mochi.test:8888/tests/content/base/test/file_websocket", "test-7"); // ws.onopen = function() // { // ws.close(); // } // ws.onclose = function(e) // { // shouldCloseNotCleanly(e); // doTest(8); // }; } } function test8() function test8() Loading