Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 <!doctype html> | |
| 2 <meta charset=utf-8> | |
| 3 <title>IndexedDB: Neutered buffers supplied as binary keys</title> | |
|
jsbell
2017/02/07 21:50:17
Can you reword this from "neutered" to "detached"?
pwnall
2017/02/08 00:33:33
Done.
Cool, it sounds less creepy!
| |
| 4 <meta name="help" href="http://w3c.github.io/IndexedDB/#convert-a-value-to-a-key "> | |
| 5 <meta name="help" href="https://heycam.github.io/webidl/#dfn-get-buffer-source-c opy"> | |
| 6 <script src="/resources/testharness.js"></script> | |
| 7 <script src="/resources/testharnessreport.js"></script> | |
| 8 <script src="support.js"></script> | |
| 9 <script> | |
| 10 | |
| 11 indexeddb_test( | |
| 12 (t, db) => { db.createObjectStore('store'); }, | |
| 13 (t, db) => { | |
| 14 const tx = db.transaction('store', 'readwrite'); | |
| 15 const store = tx.objectStore('store'); | |
| 16 | |
| 17 const buffer = new Uint8Array([1,2,3,4]).buffer; | |
| 18 assert_equals(buffer.byteLength, 4); | |
| 19 | |
| 20 // Neuter the ArrayBuffer by transferring it to a worker. | |
|
jsbell
2017/02/07 21:50:17
-> Detach
pwnall
2017/02/08 00:33:33
Done.
| |
| 21 const worker = new Worker(URL.createObjectURL(new Blob([]))); | |
| 22 worker.postMessage('', [buffer]); | |
| 23 assert_equals(buffer.byteLength, 0); | |
| 24 | |
| 25 assert_throws(new TypeError, () => { store.put('', buffer); }); | |
| 26 t.done(); | |
| 27 }, | |
| 28 'Neutered ArrayBuffer' | |
|
jsbell
2017/02/07 21:50:17
-> Detached
pwnall
2017/02/08 00:33:33
Done.
| |
| 29 ); | |
| 30 | |
| 31 indexeddb_test( | |
| 32 (t, db) => { db.createObjectStore('store'); }, | |
| 33 (t, db) => { | |
| 34 const tx = db.transaction('store', 'readwrite'); | |
| 35 const store = tx.objectStore('store'); | |
| 36 | |
| 37 const array = new Uint8Array([1,2,3,4]); | |
| 38 assert_equals(array.length, 4); | |
| 39 | |
| 40 // Neuter the ArrayBuffer by transferring it to a worker. | |
|
jsbell
2017/02/07 21:50:17
-> Detach
pwnall
2017/02/08 00:33:33
Done.
| |
| 41 const worker = new Worker(URL.createObjectURL(new Blob([]))); | |
| 42 worker.postMessage('', [array.buffer]); | |
| 43 assert_equals(array.length, 0); | |
| 44 | |
| 45 assert_throws(new TypeError, () => { store.put('', array); }); | |
| 46 t.done(); | |
| 47 }, | |
| 48 'Neutered ArrayBufferView' | |
|
jsbell
2017/02/07 21:50:17
ArrayBufferView -> TypedArray
jsbell
2017/02/07 21:50:17
-> Detached
pwnall
2017/02/08 00:33:33
Done.
pwnall
2017/02/08 00:33:34
Done.
| |
| 49 ); | |
| 50 | |
| 51 </script> | |
| OLD | NEW |