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

Unified Diff: chrome/test/data/subresource_filter/page_with_websocket.html

Issue 2714573002: Enable websocket filtering via SubresourceFilter (Closed)
Patch Set: OWNERS Created 3 years, 10 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 side-by-side diff with in-line comments
Download patch
Index: chrome/test/data/subresource_filter/page_with_websocket.html
diff --git a/chrome/test/data/subresource_filter/page_with_websocket.html b/chrome/test/data/subresource_filter/page_with_websocket.html
new file mode 100644
index 0000000000000000000000000000000000000000..8a04d73f51ef86cda6d02d759e0b59b672cb3796
--- /dev/null
+++ b/chrome/test/data/subresource_filter/page_with_websocket.html
@@ -0,0 +1,28 @@
+<script src='websocket_connection.js'></script>
+<script>
+// Listens for 'onmessage' or 'onclose' messages from the websocket, and sends
+// them to the test fixture.
+function connectionListener(e) {
+ if (e.data == 'onmessage') {
+ window.domAutomationController.send(true);
+ } else if (e.data == 'onclose') {
+ window.domAutomationController.send(false);
+ }
+}
+
+// This page has two modes, one where the websocket connection lives in the
+// document context, and one where it lives in a worker. This is encoded by the
+// 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.
+var url = new URL(location);
+if (url.searchParams.get('inWorker')) {
+ var worker = new Worker('websocket_connection.js');
+ worker.addEventListener('message', connectionListener);
+
+ // Redefine connectWebSocket to instead post a message to start the worker.
+ connectWebSocket = function(url) {
+ worker.postMessage({url: url});
+ }
+} else {
+ addEventListener('message', connectionListener);
+}
+</script>

Powered by Google App Engine
This is Rietveld 408576698