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

Side by Side Diff: third_party/WebKit/LayoutTests/external/wpt/IndexedDB/keygenerator-inject.html

Issue 2735213002: Indexed DB: Ensure large explicit keys consistently max out generator (Closed)
Patch Set: Created 3 years, 9 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
(Empty)
1 <!DOCTYPE html>
pwnall 2017/03/07 19:42:41 Nit: This test doesn't look related to the commit
jsbell 2017/03/07 20:27:57 Agreed, it's unrelated. Added a note to the CL des
2 <meta charset="utf-8">
3 <title>Key Generator behavior with explicit keys and value injection</title>
4 <link rel=help href="https://w3c.github.io/IndexedDB/#inject-key-into-value">
5 <script src="/resources/testharness.js"></script>
6 <script src="/resources/testharnessreport.js"></script>
7 <script src="support.js"></script>
8 <script>
9
10 indexeddb_test(
11 (t, db) => {
12 db.createObjectStore('store', {autoIncrement: true, keyPath: 'id'});
13 },
14 (t, db) => {
15 const tx = db.transaction('store', 'readwrite');
16 t.onabort = t.unreached_func('transaction should not abort');
17
18 const store = tx.objectStore('store');
19
20 store.put({name: 'a'}).onsuccess = t.step_func(e => {
21 const key = e.target.result;
22 assert_equals(key, 1, 'Key generator initial value should be 1');
23 store.get(key).onsuccess = t.step_func(e => {
24 const value = e.target.result;
25 assert_equals(typeof value, 'object', 'Result should be object');
26 assert_equals(value.name, 'a', 'Result should have name property');
27 assert_equals(value.id, key, 'Key should be injected');
28 t.done();
29 });
30 });
31 },
32 'Key is injected into value - simple path');
pwnall 2017/03/07 19:42:41 How about single-segment key path and multi-segmen
jsbell 2017/03/07 20:27:57 Done.
33
34 indexeddb_test(
35 (t, db) => {
36 db.createObjectStore('store', {autoIncrement: true, keyPath: 'a.b.id'});
37 },
38 (t, db) => {
39 const tx = db.transaction('store', 'readwrite');
40 t.onabort = t.unreached_func('transaction should not abort');
41
42 const store = tx.objectStore('store');
43
44 store.put({name: 'a'}).onsuccess = t.step_func(e => {
45 const key = e.target.result;
46 assert_equals(key, 1, 'Key generator initial value should be 1');
47 store.get(key).onsuccess = t.step_func(e => {
48 const value = e.target.result;
49 assert_equals(typeof value, 'object', 'Result should be object');
50 assert_equals(value.name, 'a', 'Result should have name property');
51 assert_equals(value.a.b.id, key, 'Key should be injected');
52 t.done();
53 });
54 });
55 },
56 'Key is injected into value - complex path');
57
pwnall 2017/03/07 19:42:41 Would it make sense to have a test with store.put(
jsbell 2017/03/07 20:27:57 Good idea. Done.
58 indexeddb_test(
59 (t, db) => {
60 db.createObjectStore('store', {autoIncrement: true, keyPath: 'id'});
61 },
62 (t, db) => {
63 const tx = db.transaction('store', 'readwrite');
64 const store = tx.objectStore('store');
65
66 assert_throws('DataError', () => {
67 store.put(123);
68 }, 'Key path should be checked against value');
69
70 t.done();
71 },
72 'put() throws if key cannot be injected - simple path');
73
74 indexeddb_test(
75 (t, db) => {
76 db.createObjectStore('store', {autoIncrement: true, keyPath: 'a.b.id'});
77 },
78 (t, db) => {
79 const tx = db.transaction('store', 'readwrite');
80 const store = tx.objectStore('store');
81
82 assert_throws('DataError', () => {
83 store.put({a: 123});
84 }, 'Key path should be checked against value');
85
86 assert_throws('DataError', () => {
87 store.put({a: {b: 123} });
88 }, 'Key path should be checked against value');
89
90 t.done();
91 },
92 'put() throws if key cannot be injected - complex path');
93
94 </script>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698