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

Unified 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 side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/LayoutTests/external/wpt/IndexedDB/keygenerator-inject.html
diff --git a/third_party/WebKit/LayoutTests/external/wpt/IndexedDB/keygenerator-inject.html b/third_party/WebKit/LayoutTests/external/wpt/IndexedDB/keygenerator-inject.html
new file mode 100644
index 0000000000000000000000000000000000000000..cb8c7f686aa6cd3fec80707162c7d71ffc5351f6
--- /dev/null
+++ b/third_party/WebKit/LayoutTests/external/wpt/IndexedDB/keygenerator-inject.html
@@ -0,0 +1,94 @@
+<!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
+<meta charset="utf-8">
+<title>Key Generator behavior with explicit keys and value injection</title>
+<link rel=help href="https://w3c.github.io/IndexedDB/#inject-key-into-value">
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<script src="support.js"></script>
+<script>
+
+indexeddb_test(
+ (t, db) => {
+ db.createObjectStore('store', {autoIncrement: true, keyPath: 'id'});
+ },
+ (t, db) => {
+ const tx = db.transaction('store', 'readwrite');
+ t.onabort = t.unreached_func('transaction should not abort');
+
+ const store = tx.objectStore('store');
+
+ store.put({name: 'a'}).onsuccess = t.step_func(e => {
+ const key = e.target.result;
+ assert_equals(key, 1, 'Key generator initial value should be 1');
+ store.get(key).onsuccess = t.step_func(e => {
+ const value = e.target.result;
+ assert_equals(typeof value, 'object', 'Result should be object');
+ assert_equals(value.name, 'a', 'Result should have name property');
+ assert_equals(value.id, key, 'Key should be injected');
+ t.done();
+ });
+ });
+ },
+ '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.
+
+indexeddb_test(
+ (t, db) => {
+ db.createObjectStore('store', {autoIncrement: true, keyPath: 'a.b.id'});
+ },
+ (t, db) => {
+ const tx = db.transaction('store', 'readwrite');
+ t.onabort = t.unreached_func('transaction should not abort');
+
+ const store = tx.objectStore('store');
+
+ store.put({name: 'a'}).onsuccess = t.step_func(e => {
+ const key = e.target.result;
+ assert_equals(key, 1, 'Key generator initial value should be 1');
+ store.get(key).onsuccess = t.step_func(e => {
+ const value = e.target.result;
+ assert_equals(typeof value, 'object', 'Result should be object');
+ assert_equals(value.name, 'a', 'Result should have name property');
+ assert_equals(value.a.b.id, key, 'Key should be injected');
+ t.done();
+ });
+ });
+ },
+ 'Key is injected into value - complex path');
+
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.
+indexeddb_test(
+ (t, db) => {
+ db.createObjectStore('store', {autoIncrement: true, keyPath: 'id'});
+ },
+ (t, db) => {
+ const tx = db.transaction('store', 'readwrite');
+ const store = tx.objectStore('store');
+
+ assert_throws('DataError', () => {
+ store.put(123);
+ }, 'Key path should be checked against value');
+
+ t.done();
+ },
+ 'put() throws if key cannot be injected - simple path');
+
+indexeddb_test(
+ (t, db) => {
+ db.createObjectStore('store', {autoIncrement: true, keyPath: 'a.b.id'});
+ },
+ (t, db) => {
+ const tx = db.transaction('store', 'readwrite');
+ const store = tx.objectStore('store');
+
+ assert_throws('DataError', () => {
+ store.put({a: 123});
+ }, 'Key path should be checked against value');
+
+ assert_throws('DataError', () => {
+ store.put({a: {b: 123} });
+ }, 'Key path should be checked against value');
+
+ t.done();
+ },
+ 'put() throws if key cannot be injected - complex path');
+
+</script>

Powered by Google App Engine
This is Rietveld 408576698