-
Notifications
You must be signed in to change notification settings - Fork 3.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
IDB WPTs: Extend idbtransaction WPTs to run on workers
This set of IndexedDB WPTs currently only run in a window environment. This change extends them to also run in dedicated, shared, and service worker environments. Bug: 41455766 Change-Id: I8b7afb20cbc670091980c8bbb66a1246a0e260b0 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6217662 Reviewed-by: Steve Becker <[email protected]> Commit-Queue: Rahul Singh <[email protected]> Cr-Commit-Position: refs/heads/main@{#1413811}
- Loading branch information
1 parent
8839956
commit 34c4d1c
Showing
10 changed files
with
359 additions
and
346 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
// META: title=IndexedDB: Verify [SameObject] behavior of IDBTransaction's db attribute | ||
// META: global=window,worker | ||
// META: script=resources/support.js | ||
|
||
// Spec: https://w3c.github.io/IndexedDB/#dom-idbtransaction-db | ||
|
||
'use strict'; | ||
|
||
indexeddb_test( | ||
(t, db, tx) => { | ||
const store = db.createObjectStore('store'); | ||
assert_equals( | ||
tx.db, tx.db, 'Attribute should yield the same object each time'); | ||
}, | ||
(t, db) => { | ||
const tx = db.transaction('store', 'readonly'); | ||
assert_equals( | ||
tx.db, tx.db, 'Attribute should yield the same object each time'); | ||
t.done(); | ||
}, | ||
'IDBTransaction.db [SameObject]'); |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
// META: title=IDBTransaction - complete event | ||
// META: global=window,worker | ||
// META: script=resources/support.js | ||
|
||
'use strict'; | ||
|
||
async_test(t => { | ||
let db; | ||
let store; | ||
let open_rq = createdb(t); | ||
let stages = []; | ||
|
||
open_rq.onupgradeneeded = function(e) { | ||
stages.push('upgradeneeded'); | ||
|
||
db = e.target.result; | ||
store = db.createObjectStore('store'); | ||
|
||
e.target.transaction.oncomplete = function() { | ||
stages.push('complete'); | ||
}; | ||
}; | ||
|
||
open_rq.onsuccess = function(e) { | ||
stages.push('success'); | ||
|
||
let tx = db.transaction('store', 'readonly'); | ||
store = tx.objectStore('store'); | ||
store.openCursor().onsuccess = | ||
function(e) { | ||
stages.push('opencursor'); | ||
} | ||
|
||
db.transaction('store', 'readonly') | ||
.objectStore('store') | ||
.count() | ||
.onsuccess = t.step_func(function(e) { | ||
assert_array_equals(stages, [ | ||
'upgradeneeded', 'complete', 'success', 'opencursor' | ||
]); | ||
t.done(); | ||
}); | ||
} | ||
}); |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
// META: title=IDBTransaction | ||
// META: global=window,worker | ||
// META: script=resources/support.js | ||
|
||
'use strict'; | ||
|
||
async_test(function(t) { | ||
let dbname = 'idbtransaction-' + location + t.name; | ||
indexedDB.deleteDatabase(dbname); | ||
let open_rq = indexedDB.open(dbname); | ||
|
||
open_rq.onblocked = t.unreached_func('open_rq.onblocked'); | ||
open_rq.onerror = t.unreached_func('open_rq.onerror'); | ||
|
||
open_rq.onupgradeneeded = t.step_func(function(e) { | ||
t.add_cleanup(function() { | ||
open_rq.onerror = function(e) { | ||
e.preventDefault(); | ||
}; | ||
open_rq.result.close(); | ||
indexedDB.deleteDatabase(open_rq.result.name); | ||
}); | ||
|
||
assert_equals( | ||
e.target, open_rq, 'e.target is reusing the same IDBOpenDBRequest'); | ||
assert_equals( | ||
e.target.transaction, open_rq.transaction, | ||
'IDBOpenDBRequest.transaction'); | ||
|
||
assert_true( | ||
e.target.transaction instanceof IDBTransaction, | ||
'transaction instanceof IDBTransaction'); | ||
t.done(); | ||
}); | ||
}, 'IDBTransaction - request gotten by the handler'); | ||
|
||
async_test(function(t) { | ||
let dbname = 'idbtransaction-' + location + t.name; | ||
indexedDB.deleteDatabase(dbname); | ||
let open_rq = indexedDB.open(dbname); | ||
|
||
assert_equals(open_rq.transaction, null, 'IDBOpenDBRequest.transaction'); | ||
assert_equals(open_rq.source, null, 'IDBOpenDBRequest.source'); | ||
assert_equals(open_rq.readyState, 'pending', 'IDBOpenDBRequest.readyState'); | ||
|
||
assert_true( | ||
open_rq instanceof IDBOpenDBRequest, | ||
'open_rq instanceof IDBOpenDBRequest'); | ||
assert_equals( | ||
open_rq + '', '[object IDBOpenDBRequest]', 'IDBOpenDBRequest (open_rq)'); | ||
|
||
open_rq.onblocked = t.unreached_func('open_rq.onblocked'); | ||
open_rq.onerror = t.unreached_func('open_rq.onerror'); | ||
|
||
open_rq.onupgradeneeded = t.step_func(function() { | ||
t.add_cleanup(function() { | ||
open_rq.onerror = function(e) { | ||
e.preventDefault(); | ||
}; | ||
open_rq.result.close(); | ||
indexedDB.deleteDatabase(open_rq.result.name); | ||
}); | ||
t.done(); | ||
}); | ||
}, 'IDBTransaction - request returned by open()'); |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
// META: title=IDBTransaction - abort | ||
// META: global=window,worker | ||
// META: script=resources/support.js | ||
|
||
'use strict'; | ||
|
||
async_test(t => { | ||
let db; | ||
let aborted; | ||
const record = {indexedProperty: 'bar'}; | ||
|
||
let open_rq = createdb(t); | ||
open_rq.onupgradeneeded = function(e) { | ||
db = e.target.result; | ||
let txn = e.target.transaction; | ||
let objStore = db.createObjectStore('store'); | ||
|
||
objStore.add(record, 1); | ||
objStore.add(record, 2); | ||
let index = | ||
objStore.createIndex('index', 'indexedProperty', {unique: true}); | ||
|
||
assert_true(index instanceof IDBIndex, 'IDBIndex'); | ||
|
||
e.target.transaction.onabort = t.step_func(function(e) { | ||
aborted = true; | ||
assert_equals(e.type, 'abort', 'event type'); | ||
}); | ||
|
||
db.onabort = function(e) { | ||
assert_true(aborted, 'transaction.abort event has fired'); | ||
t.done(); | ||
}; | ||
|
||
e.target.transaction.oncomplete = fail(t, 'got complete, expected abort'); | ||
}; | ||
}); |
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.