forked from web-platform-tests/wpt
-
Notifications
You must be signed in to change notification settings - Fork 0
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 idbdatabase transaction tests to worker environments.
The change updates IDBDatabase transaction() related WPTs to also run on dedicated, service, and shared workers. Currently, these only run in window environments. Bug: 41455766 Change-Id: I1e21af2c3402e58747848c19bfcf85c2e528b284 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5671037 Commit-Queue: Rahul Singh <rahsin@microsoft.com> Auto-Submit: Garima Chadha <garimachadha@microsoft.com> Reviewed-by: Evan Stade <estade@chromium.org> Reviewed-by: Rahul Singh <rahsin@microsoft.com> Cr-Commit-Position: refs/heads/main@{#1323082}
- Loading branch information
1 parent
8607a1d
commit 61a0206
Showing
6 changed files
with
82 additions
and
127 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,82 @@ | ||
// META: title=IDBDatabase.transaction() | ||
// META: global=window,worker | ||
// META: script=resources/support.js | ||
|
||
'use strict'; | ||
|
||
async_test(t => { | ||
let db; | ||
const open_rq = createdb(t); | ||
|
||
open_rq.onupgradeneeded = function () { }; | ||
open_rq.onsuccess = function (e) { | ||
db = e.target.result; | ||
|
||
assert_throws_dom('NotFoundError', function () { db.transaction('non-existing'); }); | ||
t.done(); | ||
}; | ||
}, "Attempt to open a transaction with invalid scope"); | ||
|
||
async_test(t => { | ||
let db; | ||
const open_rq = createdb(t); | ||
|
||
open_rq.onupgradeneeded = function (e) { | ||
db = e.target.result; | ||
db.createObjectStore('readonly'); | ||
}; | ||
open_rq.onsuccess = function (e) { | ||
var txn = db.transaction('readonly', 'readonly', { durability: 'relaxed' }); | ||
assert_equals(txn.mode, "readonly", 'txn.mode'); | ||
|
||
t.done(); | ||
}; | ||
}, "Opening a transaction defaults to a read-only mode"); | ||
|
||
async_test(t => { | ||
let db; | ||
const open_rq = createdb(t); | ||
|
||
open_rq.onupgradeneeded = function (e) { | ||
db = e.target.result; | ||
db.createObjectStore('test'); | ||
}; | ||
|
||
open_rq.onsuccess = function (e) { | ||
db.close(); | ||
|
||
assert_throws_dom('InvalidStateError', | ||
function () { db.transaction('test', 'readonly', { durability: 'relaxed' }); }); | ||
|
||
t.done(); | ||
}; | ||
}, "Attempt to open a transaction from closed database connection"); | ||
|
||
async_test(t => { | ||
let db; | ||
const open_rq = createdb(t); | ||
|
||
open_rq.onupgradeneeded = function (e) { | ||
db = e.target.result; | ||
db.createObjectStore('test'); | ||
}; | ||
|
||
open_rq.onsuccess = function (e) { | ||
assert_throws_js(TypeError, | ||
function () { db.transaction('test', 'whatever'); }); | ||
|
||
t.done(); | ||
}; | ||
}, "Attempt to open a transaction with invalid mode"); | ||
|
||
async_test(t => { | ||
let db; | ||
const open_rq = createdb(t); | ||
|
||
open_rq.onupgradeneeded = function () { }; | ||
open_rq.onsuccess = function (e) { | ||
db = e.target.result; | ||
assert_throws_dom('InvalidAccessError', function () { db.transaction([]); }); | ||
t.done(); | ||
}; | ||
}, "If storeNames is an empty list, the implementation must throw a DOMException of type InvalidAccessError"); |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.