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

Unified Diff: third_party/WebKit/LayoutTests/http/tests/serviceworker/websocket/resources/simple.js

Issue 2564493002: Make WebSocket available again in service workers (Closed)
Patch Set: Addressed #26 Created 4 years 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
« no previous file with comments | « no previous file | third_party/WebKit/LayoutTests/http/tests/serviceworker/websocket/websocket-in-service-worker.html » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/LayoutTests/http/tests/serviceworker/websocket/resources/simple.js
diff --git a/third_party/WebKit/LayoutTests/http/tests/serviceworker/websocket/resources/simple.js b/third_party/WebKit/LayoutTests/http/tests/serviceworker/websocket/resources/simple.js
new file mode 100644
index 0000000000000000000000000000000000000000..6b7c5ec81fb115c2628306115ca512eb66c7f77d
--- /dev/null
+++ b/third_party/WebKit/LayoutTests/http/tests/serviceworker/websocket/resources/simple.js
@@ -0,0 +1,35 @@
+let port;
+let received = false;
+
+function reportFailure(details) {
+ port.postMessage('FAIL: ' + details);
+}
+
+onmessage = event => {
+ port = event.source;
+
+ const ws = new WebSocket('ws://localhost:8880/echo');
+ ws.onopen = () => {
+ ws.send('Hello');
+ };
+ ws.onmessage = msg => {
+ if (msg.data !== 'Hello') {
+ reportFailure('Unexpected reply: ' + msg.data);
+ return;
+ }
+
+ received = true;
+ ws.close();
+ };
+ ws.onclose = () => {
+ if (!received) {
+ reportFailure('Closed before receiving reply');
+ return;
+ }
+
+ port.postMessage('PASS');
+ };
+ ws.onerror = () => {
+ reportFailure('Got an error event');
+ };
+};
« no previous file with comments | « no previous file | third_party/WebKit/LayoutTests/http/tests/serviceworker/websocket/websocket-in-service-worker.html » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698