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

Side by Side Diff: LayoutTests/storage/indexeddb/resources/key-type-binary.js

Issue 1087923003: Indexed DB: Adopt BufferSource model for binary keys (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Update test's shared lib usage Created 5 years, 6 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
(Empty)
1 if (this.importScripts) {
2 importScripts('../../../fast/js/resources/js-test-pre.js');
3 importScripts('shared.js');
4 }
5
6 description("Test IndexedDB binary keys");
7
8 indexedDBTest(prepareDatabase, testValidBinaryKeys);
9 function prepareDatabase()
10 {
11 db = event.target.result;
12 event.target.transaction.onabort = unexpectedAbortCallback;
13 objectStore = evalAndLog("db.createObjectStore('store');");
14 debug("");
15 }
16
17 function testValidBinaryKeys()
18 {
19 preamble();
20 evalAndLog("trans = db.transaction('store', 'readwrite')");
21 evalAndLog("store = trans.objectStore('store')");
22
23 var n = 0, cases = [
24 "[]",
25 "[0]",
26 "[0, 0]",
27 "[0, 1]",
28 "[1]",
29 "[1, 0]",
30 "[1, 1]",
31 "[255]",
32 ];
33
34 (function testCase() {
35 if (!cases.length)
36 return;
37
38 key = cases.shift();
39 value = n++;
40
41 debug("");
42 request = evalAndLog("store.put(" + JSON.stringify(value) + ", new Uint8 Array(" + key + "));");
43 request.onerror = unexpectedErrorCallback;
44 request.onsuccess = function() {
45 shouldBeEqualToString("request.result.toString()", "[object Uint8Arr ay]");
46 shouldBe("[].slice.call(request.result).toString()", key + ".toStrin g()");
47
48 request = evalAndLog("store.get(new Uint8Array(" + key + "));");
49 request.onerror = unexpectedErrorCallback;
50 request.onsuccess = function() {
51 shouldBe("request.result", JSON.stringify(value));
52 testCase();
53 };
54 };
55 }());
56
57 trans.oncomplete = testInvalidBinaryKeys;
58 }
59
60 function testInvalidBinaryKeys()
61 {
62 preamble();
63 evalAndLog("trans = db.transaction('store', 'readwrite')");
64 evalAndLog("store = trans.objectStore('store')");
65
66 var cases = [
67 "new Uint8ClampedArray([1,2,3])",
68 "new Uint16Array([1,2,3])",
69 "new Uint32Array([1,2,3])",
70 "new Int8Array([1,2,3])",
71 "new Int16Array([1,2,3])",
72 "new Int32Array([1,2,3])",
73 "new Float32Array([1,2,3])",
74 "new Float64Array([1,2,3])",
75 "new Uint8Array([1,2,3]).buffer",
76 "new DataView(new Uint8Array([1,2,3]).buffer)"
77 ];
78
79 cases.forEach(function(testCase) {
80 debug("");
81 evalAndExpectException("store.put('value', " + testCase + ")", "0", "'Da taError'");
82 });
83
84 finishJSTest();
85 }
OLDNEW
« no previous file with comments | « LayoutTests/storage/indexeddb/key-type-binary-expected.txt ('k') | Source/bindings/modules/v8/V8BindingForModules.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698