Skip to content

Commit

Permalink
Add WebSocket mixed content wpt
Browse files Browse the repository at this point in the history
Also modify common.sub.js so it doesn't try to make insecure connections
in secure contents.

Firefox passes the new mixed-content test in all contexts.

Safari fails the new mixed-content test in all contexts.

Change-Id: Ia3e82096e738095a04d3c7b5f8d21819f5de2faf
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4624022
Reviewed-by: Kenichi Ishibashi <bashi@chromium.org>
Commit-Queue: Adam Rice <ricea@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1161711}
  • Loading branch information
ricea authored and Chromium LUCI CQ committed Jun 23, 2023
1 parent 2fee207 commit a8f91f2
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 14 deletions.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
const __SERVER__NAME = "{{host}}";
const __PATH = "echo";

var __SCHEME;
var __PORT;
if (url_has_variant('wss')) {
__SCHEME = 'wss';
__PORT = "{{ports[wss][0]}}";
} else if (url_has_flag('h2')) {
let __SCHEME;
let __PORT;
if (url_has_flag('h2')) {
__SCHEME = 'wss';
__PORT = "{{ports[h2][0]}}";
} else if (url_has_variant('wss') || location.protocol === 'https:') {
__SCHEME = 'wss';
__PORT = "{{ports[wss][0]}}";
} else {
__SCHEME = 'ws';
__PORT = "{{ports[ws][0]}}";
Expand Down Expand Up @@ -74,6 +74,12 @@ function CreateWebSocketWithRepeatedProtocolsCaseInsensitive() {
wsocket = new WebSocket(url, ["echo", "eCho"]);
}

function CreateInsecureWebSocket() {
IsWebSocket();
const url = `ws://${__SERVER__NAME}:{{ports[ws][0]}}/${__PATH}`;
return new WebSocket(url);
}

function CreateWebSocket(isProtocol, isProtocols) {
IsWebSocket();
const url = SCHEME_DOMAIN_PORT + "/" + __PATH;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
// META: global=window,worker
// META: script=constants.sub.js

test(() => {
assert_throws_dom('SecurityError', () => CreateInsecureWebSocket(),
'constructor should throw');
}, 'constructing an insecure WebSocket in a secure context should throw');
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
This is a testharness.js-based test.
FAIL constructing an insecure WebSocket in a secure context should throw assert_throws_dom: constructor should throw function "() => CreateInsecureWebSocket()" did not throw
Harness: the test ran to completion.

This file was deleted.

0 comments on commit a8f91f2

Please sign in to comment.