Skip to content
This repository was archived by the owner on Jul 9, 2025. It is now read-only.

Commit b9d8edd

Browse files
Garima Chadhamoz-wptsync-bot
authored andcommitted
Bug 1944480 [wpt PR 50361] - IDB WPTs: Extend idbcursor-direction related tests to workers, a=testonly
Automatic update from web-platform-tests IDB WPTs: Extend idbcursor-direction related tests to workers The update modifies idbcursor-direction related WPTs to run not only in window environments but also on dedicated, service, and shared workers. Change-Id: I7bbb5a656eca9239a02644a96cdbb2b9540cccf2 Bug: 41455766 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6197324 Auto-Submit: Garima Chadha <[email protected]> Reviewed-by: Steve Becker <[email protected]> Reviewed-by: Rahul Singh <[email protected]> Commit-Queue: Rahul Singh <[email protected]> Cr-Commit-Position: refs/heads/main@{#1412726} -- wpt-commits: 318f66d1f4192b36f634cd39a8f7b5bbd44a7c15 wpt-pr: 50361
1 parent a646765 commit b9d8edd

10 files changed

+276
-303
lines changed
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
// META: global=window,worker
2+
// META: title=IDBCursor direction - index with keyrange
3+
// META: script=resources/support.js
4+
5+
// Spec: https://w3c.github.io/IndexedDB/#cursor-iteration-operation
6+
7+
'use strict';
8+
9+
let records = [1337, 'Alice', 'Bob', 'Bob', 'Greg', 'Åke', ['Anne']];
10+
let cases = [
11+
{dir: 'next', expect: ['Alice:1', 'Bob:2', 'Bob:3', 'Greg:4']},
12+
{dir: 'prev', expect: ['Greg:4', 'Bob:3', 'Bob:2', 'Alice:1']},
13+
{dir: 'nextunique', expect: ['Alice:1', 'Bob:2', 'Greg:4']},
14+
{dir: 'prevunique', expect: ['Greg:4', 'Bob:2', 'Alice:1']}
15+
];
16+
17+
cases.forEach(function(testcase) {
18+
let dir = testcase.dir;
19+
let expect = testcase.expect;
20+
indexeddb_test(
21+
function(t, db, tx) {
22+
let objStore = db.createObjectStore('test');
23+
objStore.createIndex('idx', 'name');
24+
25+
for (let i = 0; i < records.length; i++) {
26+
objStore.add({name: records[i]}, i);
27+
}
28+
},
29+
function(t, db) {
30+
let count = 0;
31+
let rq = db.transaction('test', 'readonly')
32+
.objectStore('test')
33+
.index('idx')
34+
.openCursor(IDBKeyRange.bound('AA', 'ZZ'), dir);
35+
rq.onsuccess = t.step_func(function(e) {
36+
let cursor = e.target.result;
37+
if (!cursor) {
38+
assert_equals(count, expect.length, 'cursor runs');
39+
t.done();
40+
return;
41+
}
42+
assert_equals(
43+
cursor.value.name + ':' + cursor.primaryKey, expect[count],
44+
'cursor.value');
45+
count++;
46+
cursor.continue();
47+
});
48+
rq.onerror = t.step_func(function(e) {
49+
e.preventDefault();
50+
e.stopPropagation();
51+
assert_unreached('rq.onerror - ' + e.message);
52+
});
53+
},
54+
'IDBCursor direction - index with keyrange - ' + dir);
55+
});

testing/web-platform/tests/IndexedDB/idbcursor-direction-index-keyrange.htm

Lines changed: 0 additions & 60 deletions
This file was deleted.
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
// META: global=window,worker
2+
// META: title=IDBCursor direction - index
3+
// META: script=resources/support.js
4+
5+
// Spec: https://w3c.github.io/IndexedDB/#cursor-iteration-operation
6+
7+
'use strict';
8+
9+
let records = ['Alice', 'Bob', 'Bob', 'Greg'];
10+
let cases = [
11+
{dir: 'next', expect: ['Alice:0', 'Bob:1', 'Bob:2', 'Greg:3']},
12+
{dir: 'prev', expect: ['Greg:3', 'Bob:2', 'Bob:1', 'Alice:0']},
13+
{dir: 'nextunique', expect: ['Alice:0', 'Bob:1', 'Greg:3']},
14+
{dir: 'prevunique', expect: ['Greg:3', 'Bob:1', 'Alice:0']},
15+
];
16+
17+
cases.forEach(function(testcase) {
18+
let dir = testcase.dir;
19+
let expect = testcase.expect;
20+
indexeddb_test(
21+
function(t, db, tx) {
22+
let objStore = db.createObjectStore('test');
23+
objStore.createIndex('idx', 'name');
24+
25+
for (let i = 0; i < records.length; i++)
26+
objStore.add({name: records[i]}, i);
27+
},
28+
function(t, db) {
29+
let count = 0;
30+
let rq = db.transaction('test', 'readonly')
31+
.objectStore('test')
32+
.index('idx')
33+
.openCursor(undefined, dir);
34+
rq.onsuccess = t.step_func(function(e) {
35+
let cursor = e.target.result;
36+
if (!cursor) {
37+
assert_equals(count, expect.length, 'cursor runs');
38+
t.done();
39+
}
40+
assert_equals(
41+
cursor.value.name + ':' + cursor.primaryKey, expect[count],
42+
'cursor.value');
43+
count++;
44+
cursor.continue();
45+
});
46+
rq.onerror = t.step_func(function(e) {
47+
e.preventDefault();
48+
e.stopPropagation();
49+
assert_unreached('rq.onerror - ' + e.message);
50+
});
51+
},
52+
'IDBCursor direction - index - ' + dir);
53+
});

testing/web-platform/tests/IndexedDB/idbcursor-direction-index.htm

Lines changed: 0 additions & 57 deletions
This file was deleted.
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
// META: global=window,worker
2+
// META: title=IDBCursor direction - object store with keyrange
3+
// META: script=resources/support.js
4+
5+
// Spec: https://w3c.github.io/IndexedDB/#cursor-iteration-operation
6+
7+
'use strict';
8+
9+
let records = [1337, 'Alice', 'Bob', 'Greg', 'Åke', ['Anne']];
10+
let directions = ['next', 'prev', 'nextunique', 'prevunique'];
11+
let cases = [
12+
{dir: 'next', expect: ['Alice', 'Bob', 'Greg']},
13+
{dir: 'prev', expect: ['Greg', 'Bob', 'Alice']},
14+
{dir: 'nextunique', expect: ['Alice', 'Bob', 'Greg']},
15+
{dir: 'prevunique', expect: ['Greg', 'Bob', 'Alice']},
16+
];
17+
18+
cases.forEach(function(testcase) {
19+
let dir = testcase.dir;
20+
let expect = testcase.expect;
21+
indexeddb_test(
22+
function(t, db, tx) {
23+
let objStore = db.createObjectStore('test');
24+
for (let i = 0; i < records.length; i++)
25+
objStore.add(records[i], records[i]);
26+
},
27+
function(t, db) {
28+
let count = 0;
29+
let rq = db.transaction('test', 'readonly')
30+
.objectStore('test')
31+
.openCursor(IDBKeyRange.bound('AA', 'ZZ'), dir);
32+
rq.onsuccess = t.step_func(function(e) {
33+
let cursor = e.target.result;
34+
if (!cursor) {
35+
assert_equals(count, expect.length, 'cursor runs');
36+
t.done();
37+
}
38+
assert_equals(cursor.value, expect[count], 'cursor.value');
39+
count++;
40+
cursor.continue();
41+
});
42+
rq.onerror = t.step_func(function(e) {
43+
e.preventDefault();
44+
e.stopPropagation();
45+
assert_unreached('rq.onerror - ' + e.message);
46+
});
47+
},
48+
'IDBCursor direction - object store with keyrange - ' + dir);
49+
});

testing/web-platform/tests/IndexedDB/idbcursor-direction-objectstore-keyrange.htm

Lines changed: 0 additions & 54 deletions
This file was deleted.
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
// META: global=window,worker
2+
// META: title=IDBCursor direction - object store
3+
// META: script=resources/support.js
4+
5+
// Spec: https://w3c.github.io/IndexedDB/#cursor-iteration-operation
6+
7+
'use strict';
8+
9+
let records = ['Alice', 'Bob', 'Greg'];
10+
let directions = ['next', 'prev', 'nextunique', 'prevunique'];
11+
let cases = [
12+
{dir: 'next', expect: ['Alice', 'Bob', 'Greg']},
13+
{dir: 'prev', expect: ['Greg', 'Bob', 'Alice']},
14+
{dir: 'nextunique', expect: ['Alice', 'Bob', 'Greg']},
15+
{dir: 'prevunique', expect: ['Greg', 'Bob', 'Alice']},
16+
];
17+
18+
cases.forEach(function(testcase) {
19+
let dir = testcase.dir;
20+
let expect = testcase.expect;
21+
indexeddb_test(
22+
function(t, db, tx) {
23+
let objStore = db.createObjectStore('test');
24+
for (let i = 0; i < records.length; i++)
25+
objStore.add(records[i], records[i]);
26+
},
27+
function(t, db) {
28+
let count = 0;
29+
let rq = db.transaction('test', 'readonly')
30+
.objectStore('test')
31+
.openCursor(undefined, dir);
32+
rq.onsuccess = t.step_func(function(e) {
33+
let cursor = e.target.result;
34+
if (!cursor) {
35+
assert_equals(count, expect.length, 'cursor runs');
36+
t.done();
37+
}
38+
assert_equals(cursor.value, expect[count], 'cursor.value');
39+
count++;
40+
cursor.continue();
41+
});
42+
rq.onerror = t.step_func(function(e) {
43+
e.preventDefault();
44+
e.stopPropagation();
45+
assert_unreached('rq.onerror - ' + e.message);
46+
});
47+
},
48+
'IDBCursor direction - object store - ' + dir);
49+
});

0 commit comments

Comments
 (0)