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

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: Removed unnecessary line 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
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..d6908a07e98f99e3a21677e2cf3fd7096b61ae12
--- /dev/null
+++ b/third_party/WebKit/LayoutTests/http/tests/serviceworker/websocket/resources/simple.js
@@ -0,0 +1,34 @@
+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');
+ }
+
+ port.postMessage('PASS');
+ };
+ ws.onerror = () => {
+ reportFailure('Got an error event');
+ };
+};
falken 2016/12/08 13:12:29 sorry I gave a bad review about simple.js formatti
tyoshino (SeeGerritForStatus) 2016/12/08 13:50:04 Oops. No. It's my bad, sorry. I was hurried and mi

Powered by Google App Engine
This is Rietveld 408576698