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

Side by Side Diff: LayoutTests/http/tests/websocket/bufferedAmount-after-send.html

Issue 1295723003: Fix a flaky websocket test. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 5 years, 4 months 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 | Annotate | Revision Log
OLDNEW
1 <!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN"> 1 <!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
2 <html> 2 <html>
3 <head> 3 <head>
4 <script src="/js-test-resources/js-test.js"></script> 4 <script src="/js-test-resources/js-test.js"></script>
5 </head> 5 </head>
6 <body> 6 <body>
7 <script type="text/javascript"> 7 <script type="text/javascript">
8 description('WebSocket bufferedAmount after send'); 8 description('WebSocket bufferedAmount after send');
9 9
10 window.jsTestIsAsync = true; 10 window.jsTestIsAsync = true;
11 11
12 var ws = new WebSocket('ws://localhost:8880/echo'); 12 var ws = new WebSocket('ws://localhost:8880/echo');
13 13
14 ws.onopen = function() 14 ws.onopen = function()
15 { 15 {
16 debug('onopen'); 16 debug('onopen');
17 ws.send('hello'); 17 ws.send('hello');
18 shouldBe('ws.bufferedAmount', '5'); 18 shouldBe('ws.bufferedAmount', '5');
19 ws.send(new ArrayBuffer(32)); 19 ws.send(new ArrayBuffer(32));
20 shouldBe('ws.bufferedAmount', '37'); 20 shouldBe('ws.bufferedAmount', '37');
21 ws.send(new Blob(['abc', 'de'])); 21 ws.send(new Blob(['abc', 'de']));
22 shouldBe('ws.bufferedAmount', '42'); 22 shouldBe('ws.bufferedAmount', '42');
23 ws.send('bye'); 23 ws.send('bye');
24 shouldBe('ws.bufferedAmount', '45'); 24 shouldBe('ws.bufferedAmount', '45');
25 // FIXME: This is a bit flaky but I don't know how to fix it. 25 var id = setInterval(function() {
26 setTimeout(function() { 26 if (ws.bufferedAmount === 0) {
27 shouldBe('ws.bufferedAmount', '0'); 27 clearInterval(id);
28 ws.close(); 28 ws.close();
29 }
29 }, 50); 30 }, 50);
30 }; 31 };
31 32
32 ws.onclose = function() 33 ws.onclose = function()
33 { 34 {
34 debug('onclose'); 35 debug('onclose');
35 shouldBe('ws.bufferedAmount', '0'); 36 shouldBe('ws.bufferedAmount', '0');
36 finishJSTest(); 37 finishJSTest();
37 }; 38 };
38 39
39 </script> 40 </script>
40 </body> 41 </body>
41 </html> 42 </html>
OLDNEW
« no previous file with comments | « LayoutTests/TestExpectations ('k') | LayoutTests/http/tests/websocket/bufferedAmount-after-send-expected.txt » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698