Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(420)

Side by Side Diff: chrome/test/data/safe_browsing/malware_websocket.html

Issue 2971333002: SafeBrowsing test for WebSocket connection from worker (Closed)
Patch Set: Created 3 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « chrome/browser/safe_browsing/safe_browsing_service_browsertest.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 <title>Test whether a WebSocket connection triggers a SafeBrowsing interstitial< /title> 1 <title>Test whether a WebSocket connection triggers a SafeBrowsing interstitial< /title>
2 <script> 2 <script>
3 const url = new URL(document.location.href);
4 const type = url.searchParams.get('type');
3 // Construct the WebSocket URL from the page URL. The server should not be 5 // Construct the WebSocket URL from the page URL. The server should not be
4 // configured to accept a WebSocket handshake at this endpoint, or the "not 6 // configured to accept a WebSocket handshake at this endpoint, or the "not
5 // blocked" test will fail. A 404 error is perfect. 7 // blocked" test will fail. A 404 error is perfect.
6 const wsUrl = new URL('/safe_browsing/malware-ws', document.location.href); 8 const wsUrl = new URL('/safe_browsing/malware-ws', url);
7 wsUrl.protocol = 'ws'; 9 wsUrl.protocol = 'ws';
8 const ws = new WebSocket(wsUrl.href); 10
9 // The "not blocked" test looks for this title change to verify that the request 11 function workerTest() {
10 // has not been blocked. 12 const src = `
11 ws.onerror = () => { document.title = 'COMPLETED'; }; 13 const ws = new WebSocket('${wsUrl}');
14 ws.onerror = () => {
15 postMessage('COMPLETED');
16 };
17 `;
18 const blob = new Blob([src]);
19 const srcUrl = URL.createObjectURL(blob);
20 const worker = new Worker(srcUrl);
21 worker.onmessage = signalComplete;
22 }
23
24 switch (type) {
25 case 'worker':
26 workerTest();
27 break;
28
29 default:
30 windowTest();
31 break;
32 }
33
34 function windowTest() {
35 const ws = new WebSocket(wsUrl.href);
36 ws.onerror = signalComplete;
37 }
38
39 function signalComplete() {
40 // The "not blocked" test looks for this title change to verify that the
41 // request has not been blocked.
42 document.title = 'COMPLETED';
43 }
12 </script> 44 </script>
OLDNEW
« no previous file with comments | « chrome/browser/safe_browsing/safe_browsing_service_browsertest.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698