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

Side by Side 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 unified diff | Download patch
OLDNEW
(Empty)
1 let port;
2 let received = false;
3
4 function reportFailure(details) {
5 port.postMessage('FAIL: ' + details);
6 }
7
8 onmessage = event => {
9 port = event.source;
10
11 const ws = new WebSocket('ws://localhost:8880/echo');
12 ws.onopen = () => {
13 ws.send('Hello');
14 };
15 ws.onmessage = msg => {
16 if (msg.data !== 'Hello') {
17 reportFailure('Unexpected reply: ' + msg.data);
18 return;
19 }
20
21 received = true;
22 ws.close();
23 };
24 ws.onclose = () => {
25 if (!received) {
26 reportFailure('Closed before receiving reply');
27 }
28
29 port.postMessage('PASS');
30 };
31 ws.onerror = () => {
32 reportFailure('Got an error event');
33 };
34 };
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
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698