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

Side by Side Diff: chrome/test/data/subresource_filter/page_with_websocket.html

Issue 2714573002: Enable websocket filtering via SubresourceFilter (Closed)
Patch Set: OWNERS Created 3 years, 9 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
OLDNEW
(Empty)
1 <script src='websocket_connection.js'></script>
2 <script>
3 // Listens for 'onmessage' or 'onclose' messages from the websocket, and sends
4 // them to the test fixture.
5 function connectionListener(e) {
6 if (e.data == 'onmessage') {
7 window.domAutomationController.send(true);
8 } else if (e.data == 'onclose') {
9 window.domAutomationController.send(false);
10 }
11 }
12
13 // This page has two modes, one where the websocket connection lives in the
14 // document context, and one where it lives in a worker. This is encoded by the
15 // extra 'inWorker' url param.
engedy 2017/03/06 16:31:01 nit: presence (or absence) of an URL param named `
Charlie Harrison 2017/03/06 19:22:11 Done.
16 var url = new URL(location);
17 if (url.searchParams.get('inWorker')) {
18 var worker = new Worker('websocket_connection.js');
19 worker.addEventListener('message', connectionListener);
20
21 // Redefine connectWebSocket to instead post a message to start the worker.
22 connectWebSocket = function(url) {
23 worker.postMessage({url: url});
24 }
25 } else {
26 addEventListener('message', connectionListener);
27 }
28 </script>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698