-
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.
Extend Web platform test coverage to workers.
web_tests/external/wpt/IndexedDB/ tests are only testing behavior in window environment. Extend the tests to cover different workers (dedicated, serviceworker, sharedworker). Tests related to idbindex_get.htm have been extended. Bug: 41455766 Change-Id: Ib2ffb0715a5aa994a92cd22dfa36932cddb4e637
- Loading branch information
1 parent
eb8b11e
commit 13165cb
Showing
16 changed files
with
219 additions
and
255 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,32 @@ | ||
// META: global=window,worker | ||
// META: title=IDBIndex.get() - returns the record | ||
// META: script=resources/support.js | ||
// @author Microsoft <https://www.microsoft.com> | ||
|
||
'use_strict'; | ||
|
||
let db; | ||
let index; | ||
const t = async_test(), | ||
record = { key: 1, indexedProperty: "data" }; | ||
|
||
const open_rq = createdb(t); | ||
open_rq.onupgradeneeded = function(e) { | ||
db = e.target.result; | ||
const objStore = db.createObjectStore("store", { keyPath: "key" }); | ||
index = objStore.createIndex("index", "indexedProperty"); | ||
|
||
objStore.add(record); | ||
} | ||
|
||
open_rq.onsuccess = function(e) { | ||
const rq = db.transaction("store", "readonly", {durability: 'relaxed'}) | ||
.objectStore("store") | ||
.index("index") | ||
.get(record.indexedProperty); | ||
|
||
rq.onsuccess = t.step_func(function(e) { | ||
assert_equals(e.target.result.key, record.key); | ||
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,34 @@ | ||
// META: global=window,worker | ||
// META: title=IDBIndex.get() - returns the record where the index contains duplicate values | ||
// META: script=resources/support.js | ||
// @author Microsoft <https://www.microsoft.com> | ||
|
||
'use_strict'; | ||
|
||
let db; | ||
const t = async_test(); | ||
const records = [ { key:1, indexedProperty:"data" }, | ||
{ key:2, indexedProperty:"data" }, | ||
{ key:3, indexedProperty:"data" } ]; | ||
|
||
const open_rq = createdb(t); | ||
open_rq.onupgradeneeded = function(e) { | ||
db = e.target.result; | ||
const objStore = db.createObjectStore("test", { keyPath: "key" }); | ||
objStore.createIndex("index", "indexedProperty"); | ||
|
||
for (let i = 0; i < records.length; i++) | ||
objStore.add(records[i]); | ||
}; | ||
|
||
open_rq.onsuccess = function(e) { | ||
const rq = db.transaction("test", "readonly", {durability: 'relaxed'}) | ||
.objectStore("test") | ||
.index("index") | ||
.get("data"); | ||
|
||
rq.onsuccess = t.step_func(function(e) { | ||
assert_equals(e.target.result.key, records[0].key); | ||
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,22 @@ | ||
// META: global=window,worker | ||
// META: title=IDBIndex.get() - attempt to retrieve a record that doesn't exist | ||
// META: script=resources/support.js | ||
// @author Microsoft <https://www.microsoft.com> | ||
|
||
'use_strict'; | ||
|
||
let db; | ||
const t = async_test(); | ||
|
||
const open_rq = createdb(t); | ||
open_rq.onupgradeneeded = function(e) { | ||
db = e.target.result; | ||
const rq = db.createObjectStore("test", { keyPath: "key" }) | ||
.createIndex("index", "indexedProperty") | ||
.get(1); | ||
|
||
rq.onsuccess = t.step_func(function(e) { | ||
assert_equals(e.target.result, undefined); | ||
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,35 @@ | ||
// META: global=window,worker | ||
// META: title=IDBIndex.get() - returns the record with the first key in the range | ||
// META: script=resources/support.js | ||
// @author Microsoft <https://www.microsoft.com> | ||
|
||
'use_strict'; | ||
|
||
let db; | ||
const t = async_test(); | ||
|
||
const open_rq = createdb(t); | ||
|
||
open_rq.onupgradeneeded = function(e) { | ||
db = e.target.result; | ||
const store = db.createObjectStore("store", { keyPath: "key" }); | ||
store.createIndex("index", "indexedProperty"); | ||
|
||
for(let i = 0; i < 10; i++) { | ||
store.add({ key: i, indexedProperty: "data" + i }); | ||
} | ||
} | ||
|
||
open_rq.onsuccess = function(e) { | ||
const rq = db.transaction("store", "readonly", {durability: 'relaxed'}) | ||
.objectStore("store") | ||
.index("index") | ||
.get(IDBKeyRange.bound('data4', 'data7')); | ||
|
||
rq.onsuccess = t.step_func(function(e) { | ||
assert_equals(e.target.result.key, 4); | ||
assert_equals(e.target.result.indexedProperty, 'data4'); | ||
|
||
step_timeout(function() { t.done(); }, 4); | ||
}); | ||
} |
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,21 @@ | ||
// META: global=window,worker | ||
// META: title=IDBIndex.get() - throw DataError when using invalid key | ||
// META: script=resources/support.js | ||
// @author Intel <http://www.intel.com> | ||
|
||
'use_strict'; | ||
|
||
let db; | ||
const t = async_test(); | ||
|
||
const open_rq = createdb(t); | ||
open_rq.onupgradeneeded = function(e) { | ||
db = e.target.result; | ||
|
||
const index = db.createObjectStore("test", { keyPath: "key" }) | ||
.createIndex("index", "indexedProperty"); | ||
assert_throws_dom("DataError",function(){ | ||
index.get(NaN); | ||
}); | ||
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,24 @@ | ||
// META: global=window,worker | ||
// META: title=IDBIndex.get() - throw InvalidStateError when the index is deleted | ||
// META: script=resources/support.js | ||
// @author Intel <http://www.intel.com> | ||
|
||
'use_strict'; | ||
|
||
let db; | ||
const t = async_test(); | ||
|
||
const open_rq = createdb(t); | ||
open_rq.onupgradeneeded = function(e) { | ||
db = e.target.result; | ||
const store = db.createObjectStore("store", { keyPath: "key" }); | ||
const index = store.createIndex("index", "indexedProperty"); | ||
|
||
store.add({ key: 1, indexedProperty: "data" }); | ||
store.deleteIndex("index"); | ||
|
||
assert_throws_dom("InvalidStateError", function(){ | ||
index.get("data"); | ||
}); | ||
t.done(); | ||
} |
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.