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

Side by Side Diff: third_party/WebKit/LayoutTests/http/tests/websocket/send-arraybufferview.html

Issue 2707243006: [SharedArrayBuffer] Prevent SharedArrayBuffer being used in Web APIs (Closed)
Patch Set: update comment, add TODO Created 3 years, 8 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
OLDNEW
1 <!DOCTYPE html> 1 <!DOCTYPE html>
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 <div id="description"></div> 7 <div id="description"></div>
8 <div id="console"></div> 8 <div id="console"></div>
9 <script type="text/javascript"> 9 <script type="text/javascript">
10 description("WebSocket: Send ArrayBufferViews."); 10 description("WebSocket: Send ArrayBufferViews.");
(...skipping 22 matching lines...) Expand all
33 function createArrayBufferViewContainingAllDistinctBytes() 33 function createArrayBufferViewContainingAllDistinctBytes()
34 { 34 {
35 // Return a slice of ArrayBuffer. 35 // Return a slice of ArrayBuffer.
36 var buffer = new ArrayBuffer(1000); 36 var buffer = new ArrayBuffer(1000);
37 var array = new Uint8Array(buffer, 123, 256); 37 var array = new Uint8Array(buffer, 123, 256);
38 for (var i = 0; i < 256; ++i) 38 for (var i = 0; i < 256; ++i)
39 array[i] = i; 39 array[i] = i;
40 return array; 40 return array;
41 } 41 }
42 42
43 function createSharedArrayBufferView()
44 {
45 return new Uint8Array(new SharedArrayBuffer(16));
46 }
47
43 var url = "ws://127.0.0.1:8880/check-binary-messages"; 48 var url = "ws://127.0.0.1:8880/check-binary-messages";
44 var ws = new WebSocket(url); 49 var ws = new WebSocket(url);
45 var closeEvent; 50 var closeEvent;
46 51
47 ws.onopen = function() 52 ws.onopen = function()
48 { 53 {
49 ws.send(createArrayBufferViewContainingHelloWorld()); 54 ws.send(createArrayBufferViewContainingHelloWorld());
50 ws.send(createEmptyArrayBufferView()); 55 ws.send(createEmptyArrayBufferView());
51 ws.send(createArrayBufferViewContainingAllDistinctBytes()); 56 ws.send(createArrayBufferViewContainingAllDistinctBytes());
57
58 if (window.SharedArrayBuffer) {
59 shouldThrow("ws.send(createSharedArrayBufferView())");
60 }
52 }; 61 };
53 62
54 ws.onmessage = function(event) 63 ws.onmessage = function(event)
55 { 64 {
56 var message = event.data; 65 var message = event.data;
57 if (startsWith(message, "PASS")) 66 if (startsWith(message, "PASS"))
58 testPassed(message); 67 testPassed(message);
59 else 68 else
60 testFailed(message); 69 testFailed(message);
61 }; 70 };
62 71
63 ws.onclose = function(event) 72 ws.onclose = function(event)
64 { 73 {
65 closeEvent = event; 74 closeEvent = event;
66 shouldBeTrue("closeEvent.wasClean"); 75 shouldBeTrue("closeEvent.wasClean");
67 finishJSTest(); 76 finishJSTest();
68 }; 77 };
69 78
70 </script> 79 </script>
71 </body> 80 </body>
72 </html> 81 </html>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698