Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / third_party / WebKit / LayoutTests / http / tests / xmlhttprequest / post-arraybuffer-data-view.html
blob0f3af0f1f11dff6f7fad4b0d4d7df916a5752f70
1 <!DOCTYPE html>
3 <script src="/js-test-resources/js-test.js"></script>
4 <script>
5 description('Test for ArrayBuffer POST in XMLHttpRequest send');
6 window.jsTestIsAsync = true;
8 new Promise(function(resolve, reject) {
9 var array = new Uint8Array([0, 1, 2, 25, 45, 58, 255]);
10 var xhr = new XMLHttpRequest;
11 xhr.open('POST', 'resources/post-echo-as-ascii.cgi', true);
12 xhr.onreadystatechange = function() {
13 if (xhr.readyState === 4) {
14 debug('xhr.readyState = ' + xhr.readyState + ': responseURL = ' + xhr.responseURL);
15 resolve(xhr);
18 xhr.send(new DataView(array.buffer));
19 }).then(function(xhr) {
20 window.status = xhr.status;
21 shouldBeEqualToString('status', '200');
22 responseText = xhr.responseText;
23 shouldBeEqualToString('responseText', '0 1 2 25 45 58 255');
24 }).catch(function(reason) {
25 testFailed(String(reason));
26 }).then(finishJSTest, finishJSTest);
28 </script>