| Index: chrome/test/data/safe_browsing/malware_websocket.html
|
| diff --git a/chrome/test/data/safe_browsing/malware_websocket.html b/chrome/test/data/safe_browsing/malware_websocket.html
|
| index df66c39c641cb4957d10dbe85f674a6a9c4918d7..deb0a007ab2f7a7f6716453c458844cba81720b5 100644
|
| --- a/chrome/test/data/safe_browsing/malware_websocket.html
|
| +++ b/chrome/test/data/safe_browsing/malware_websocket.html
|
| @@ -1,12 +1,44 @@
|
| <title>Test whether a WebSocket connection triggers a SafeBrowsing interstitial</title>
|
| <script>
|
| +const url = new URL(document.location.href);
|
| +const type = url.searchParams.get('type');
|
| // Construct the WebSocket URL from the page URL. The server should not be
|
| // configured to accept a WebSocket handshake at this endpoint, or the "not
|
| // blocked" test will fail. A 404 error is perfect.
|
| -const wsUrl = new URL('/safe_browsing/malware-ws', document.location.href);
|
| +const wsUrl = new URL('/safe_browsing/malware-ws', url);
|
| wsUrl.protocol = 'ws';
|
| -const ws = new WebSocket(wsUrl.href);
|
| -// The "not blocked" test looks for this title change to verify that the request
|
| -// has not been blocked.
|
| -ws.onerror = () => { document.title = 'COMPLETED'; };
|
| +
|
| +function workerTest() {
|
| + const src = `
|
| +const ws = new WebSocket('${wsUrl}');
|
| +ws.onerror = () => {
|
| + postMessage('COMPLETED');
|
| +};
|
| +`;
|
| + const blob = new Blob([src]);
|
| + const srcUrl = URL.createObjectURL(blob);
|
| + const worker = new Worker(srcUrl);
|
| + worker.onmessage = signalComplete;
|
| +}
|
| +
|
| +switch (type) {
|
| + case 'worker':
|
| + workerTest();
|
| + break;
|
| +
|
| + default:
|
| + windowTest();
|
| + break;
|
| +}
|
| +
|
| +function windowTest() {
|
| + const ws = new WebSocket(wsUrl.href);
|
| + ws.onerror = signalComplete;
|
| +}
|
| +
|
| +function signalComplete() {
|
| + // The "not blocked" test looks for this title change to verify that the
|
| + // request has not been blocked.
|
| + document.title = 'COMPLETED';
|
| +}
|
| </script>
|
|
|