Index: pages/filters/websocket.tmpl |
=================================================================== |
new file mode 100644 |
--- /dev/null |
+++ b/pages/filters/websocket.tmpl |
@@ -0,0 +1,60 @@ |
+title = $websocket - ABP Test Pages |
+template = testcase |
+ |
+{% set testcase_moreinfo = [ |
+ ("Filter Options", "https://adblockplus.org/filters#options"), |
+] %} |
+ |
+ |
+<script> |
+function pagelog(message) { |
+ var log = document.getElementById("testcase-fo-websocket"); |
+ log.innerText = log.innerText + message + "\n"; |
+ console.log(message); |
+} |
+ |
+function ws_open(evt) { |
+ pagelog("Connected"); |
+ websocket.send("Test message was echoed back"); |
+} |
+function ws_close(evt) { |
+ pagelog("Disconnected"); |
+} |
+function ws_message(evt) { |
+ pagelog("Received message: "); |
+ pagelog(evt.data); |
+} |
+function ws_error(evt) { |
+ pagelog("WebSocket error / Blocked"); |
+} |
+ |
+function ws_disconnect() |
+{ |
+ websocket.close(); |
+} |
+ |
+function ws_connect() { |
+ var url ="wss://echo.websocket.org"; |
+ websocket = new WebSocket(url); |
+ websocket.onopen = function(evt) { ws_open(evt) }; |
+ websocket.onclose = function(evt) { ws_disconnect(evt) }; |
+ websocket.onmessage = function(evt) { ws_message(evt) }; |
+ websocket.onerror = function(evt) { ws_error(evt) }; |
+} |
+ |
+document.addEventListener('DOMContentLoaded', ws_connect, false); |
+</script> |
+ |
+<section class="site-panel"> |
+ <h2>$websocket</h2> |
+ <p>Check that usage of the $websocket filter option works as expected.</p> |
+</section> |
+ |
+<section class="site-panel"> |
+ <h2>Test case</h2> |
+ <div class="testcase-container"> |
+ <div class="testcase-row"><h3>WebSocket Request</h3><div id="testcase-fo-websocket"></div></div> |
+ </div> |
+ <h3>Filters</h3> |
+ $websocket,domain=testpages.adblockplus.org |
+</section> |