Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Unified Diff: pages/filters/websocket.tmpl

Issue 29755578: Issue 2148 - Rewrite the testpages test suite (Closed)
Patch Set: Created April 18, 2018, 11:54 a.m.
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
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>

Powered by Google App Engine
This is Rietveld