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

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: 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 unified diff | 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 »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 return;
28 }
29
30 port.postMessage('PASS');
31 };
32 ws.onerror = () => {
33 reportFailure('Got an error event');
34 };
35 };
OLDNEW
« 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