OLD | NEW |
(Empty) | |
| 1 <!DOCTYPE html> |
| 2 <meta charset=utf-8> |
| 3 <title>Verify the coversion of various types of BufferSource</title> |
| 4 <link rel="author" title="Mozilla" href="https://www.mozilla.org"> |
| 5 <link rel="help" href="http://w3c.github.io/IndexedDB/#key-construct"> |
| 6 <script src=/resources/testharness.js></script> |
| 7 <script src=/resources/testharnessreport.js></script> |
| 8 |
| 9 <script> |
| 10 test(function() { |
| 11 let binary = new ArrayBuffer(0); |
| 12 let key = IDBKeyRange.lowerBound(binary).lower; |
| 13 |
| 14 assert_true(key instanceof ArrayBuffer); |
| 15 assert_equals(key.byteLength, 0); |
| 16 assert_equals(key.byteLength, binary.byteLength); |
| 17 }, "Empty ArrayBuffer"); |
| 18 |
| 19 test(function() { |
| 20 let binary = new ArrayBuffer(4); |
| 21 let dataView = new DataView(binary); |
| 22 dataView.setUint32(0, 1234567890); |
| 23 |
| 24 let key = IDBKeyRange.lowerBound(binary).lower; |
| 25 |
| 26 assert_true(key instanceof ArrayBuffer); |
| 27 assert_equals(key.byteLength, 4); |
| 28 assert_equals(dataView.getUint32(0), new DataView(key).getUint32(0)); |
| 29 }, "ArrayBuffer"); |
| 30 |
| 31 test(function() { |
| 32 let binary = new ArrayBuffer(4); |
| 33 let dataView = new DataView(binary); |
| 34 dataView.setUint32(0, 1234567890); |
| 35 |
| 36 let key = IDBKeyRange.lowerBound(dataView).lower; |
| 37 |
| 38 assert_true(key instanceof ArrayBuffer); |
| 39 assert_equals(key.byteLength, 4); |
| 40 assert_equals(dataView.getUint32(0), new DataView(key).getUint32(0)); |
| 41 }, "DataView"); |
| 42 |
| 43 test(function() { |
| 44 let binary = new ArrayBuffer(4); |
| 45 let dataView = new DataView(binary); |
| 46 let int8Array = new Int8Array(binary); |
| 47 int8Array.set([16, -32, 64, -128]); |
| 48 |
| 49 let key = IDBKeyRange.lowerBound(int8Array).lower; |
| 50 let keyInInt8Array = new Int8Array(key); |
| 51 |
| 52 assert_true(key instanceof ArrayBuffer); |
| 53 assert_equals(key.byteLength, 4); |
| 54 for(let i = 0; i < int8Array.length; i++) { |
| 55 assert_equals(keyInInt8Array[i], int8Array[i]); |
| 56 } |
| 57 }, "TypedArray(Int8Array)"); |
| 58 |
| 59 test(function() { |
| 60 let binary = new ArrayBuffer(4); |
| 61 let dataView = new DataView(binary); |
| 62 let int8Array = new Int8Array(binary); |
| 63 int8Array.set([16, -32, 64, -128]); |
| 64 |
| 65 let key = IDBKeyRange.lowerBound([int8Array]).lower; |
| 66 |
| 67 assert_true(key instanceof Array); |
| 68 assert_true(key[0] instanceof ArrayBuffer); |
| 69 assert_equals(key[0].byteLength, 4); |
| 70 |
| 71 let keyInInt8Array = new Int8Array(key[0]); |
| 72 |
| 73 for(let i = 0; i < int8Array.length; i++) { |
| 74 assert_equals(keyInInt8Array[i], int8Array[i]); |
| 75 } |
| 76 }, "Array of TypedArray(Int8Array)"); |
| 77 </script> |
| 78 |
| 79 <div id=log></div> |
OLD | NEW |