зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1561211 [wpt PR 17480] - Indexed DB: store/index keyPath property should return same instance, a=testonly
Automatic update from web-platform-tests Indexed DB: store/index keyPath property should return same instance On IDBObjectStore and IDBIndex instances, the keyPath property says is defined in the spec with: "if this attribute returns an object (specifically an Array), it returns the same object instance every time it is inspected". Web platform tests for this were missing. Since the property is 'any' in Web IDL (since it could be a string or Array) it can't use the [SameObject] extended attribute. And in the Blink IDL, it can't use the [SaveSameObject] hint since that requires [SameObject]. Instead, use the [CachedAttribute] hint and never dirty the cache. Bug: 977048 Change-Id: Ic4ede31a3a01e7a8a90c4f54eb8a989a673fcf22 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1674495 Commit-Queue: Daniel Murphy <dmurph@chromium.org> Reviewed-by: Daniel Murphy <dmurph@chromium.org> Cr-Commit-Position: refs/heads/master@{#672137} -- wpt-commits: 1fd5380edd2390b2584c2c51754749d68916a525 wpt-pr: 17480
This commit is contained in:
Родитель
1585e9332e
Коммит
9166f441fd
|
@ -0,0 +1,30 @@
|
|||
// META: title=IndexedDB: IDBIndex keyPath attribute - same object
|
||||
// META: script=support.js
|
||||
|
||||
indexeddb_test(
|
||||
(t, db) => {
|
||||
const store = db.createObjectStore('store', {keyPath: ['a', 'b']});
|
||||
store.createIndex('index', ['a', 'b']);
|
||||
},
|
||||
(t, db) => {
|
||||
const tx = db.transaction('store');
|
||||
const store = tx.objectStore('store');
|
||||
const index = store.index('index');
|
||||
assert_equals(typeof index.keyPath, 'object', 'keyPath is an object');
|
||||
assert_true(Array.isArray(index.keyPath), 'keyPath is an array');
|
||||
|
||||
assert_equals(
|
||||
index.keyPath, index.keyPath,
|
||||
'Same object instance is returned each time keyPath is inspected');
|
||||
|
||||
const tx2 = db.transaction('store');
|
||||
const store2 = tx2.objectStore('store');
|
||||
const index2 = store2.index('index');
|
||||
|
||||
assert_not_equals(
|
||||
index.keyPath, index2.keyPath,
|
||||
'Different instances are returned from different index instances.');
|
||||
|
||||
t.done();
|
||||
},
|
||||
`IDBIndex's keyPath attribute returns the same object.`);
|
|
@ -0,0 +1,27 @@
|
|||
// META: title=IndexedDB: IDBObjectStore keyPath attribute - same object
|
||||
// META: script=support.js
|
||||
|
||||
indexeddb_test(
|
||||
(t, db) => {
|
||||
db.createObjectStore('store', {keyPath: ['a', 'b']});
|
||||
},
|
||||
(t, db) => {
|
||||
const tx = db.transaction('store');
|
||||
const store = tx.objectStore('store');
|
||||
assert_equals(typeof store.keyPath, 'object', 'keyPath is an object');
|
||||
assert_true(Array.isArray(store.keyPath), 'keyPath is an array');
|
||||
|
||||
assert_equals(
|
||||
store.keyPath, store.keyPath,
|
||||
'Same object instance is returned each time keyPath is inspected');
|
||||
|
||||
const tx2 = db.transaction('store');
|
||||
const store2 = tx2.objectStore('store');
|
||||
|
||||
assert_not_equals(
|
||||
store.keyPath, store2.keyPath,
|
||||
'Different instances are returned from different store instances.');
|
||||
|
||||
t.done();
|
||||
},
|
||||
`IDBObjectStore's keyPath attribute returns the same object.`);
|
Загрузка…
Ссылка в новой задаче