Best headless browser for AI agents. Lite, Fast, High-Compatibility. Built in Rust
Rust ai-agentsai-toolsbrowserbrowser-automationcloud-browserheadlessheadless-browserkitesurfplaywrightpuppeteerrustservoweb-crawlerweb-crawlingweb-scraperweb-scraping
<!doctype html>
<meta charset="utf-8">
<script src="/wpt/resources/testharness.js"></script>
<script src="/wpt/resources/testharnessreport.js"></script>
<script src="/wpt/resources/moli-wpt-adapter.js"></script>
<script>
function wait_request(request) {
return new Promise((resolve, reject) => {
request.onsuccess = () => resolve(request.result);
request.onerror = () => reject(request.error);
});
}
function assert_throws_name(expectedName, callback, description) {
try {
callback();
} catch (error) {
assert_equals(
error && error.name,
expectedName,
description || "unexpected exception name"
);
return;
}
assert_unreached(
(description || "assert_throws_name") + ": expected an exception"
);
}
function assert_id_array(actual, expected, description) {
assert_array_equals(
actual.map((value) => value.id),
expected,
description
);
}
promise_test(async () => {
const dbname = "idb-collection-query-conversion-" + Math.random();
const storeName = "store";
const indexName = "byGroup";
const openRequest = indexedDB.open(dbname, 1);
openRequest.onupgradeneeded = () => {
const store = openRequest.result.createObjectStore(storeName);
store.createIndex(indexName, "group");
store.add({ id: 1, group: "a" }, 1);
store.add({ id: 2, group: "a" }, 2);
store.add({ id: 3, group: "b" }, 3);
};
const db = await wait_request(openRequest);
const tx = db.transaction(storeName);
const store = tx.objectStore(storeName);
const index = store.index(indexName);
assert_id_array(
await wait_request(store.getAll()),
[1, 2, 3],
"objectStore.getAll() missing query returns every record"
);
assert_id_array(
await wait_request(store.getAll(undefined)),
[1, 2, 3],
"objectStore.getAll(undefined) returns every record"
);
assert_id_array(
await wait_request(store.getAll(IDBKeyRange.bound(2, 3))),
[2, 3],
"objectStore.getAll() accepts IDBKeyRange queries"
);
assert_array_equals(
await wait_request(store.getAllKeys(2)),
[2],
"objectStore.getAllKeys() accepts key queries"
);
assert_id_array(
await wait_request(index.getAll("a")),
[1, 2],
"index.getAll() accepts key queries"
);
assert_id_array(
await wait_request(index.getAll(undefined)),
[1, 2, 3],
"index.getAll(undefined) returns every indexed record"
);
assert_array_equals(
await wait_request(index.getAllKeys("a")),
[1, 2],
"index.getAllKeys() accepts key queries"
);
assert_id_array(
await wait_request(store.getAll({})),
[1, 2, 3],
"objectStore.getAll() accepts empty IDBGetAllOptions"
);
assert_id_array(
await wait_request(store.getAll({
query: IDBKeyRange.bound(1, 2),
count: 1,
direction: "prev",
})),
[2],
"objectStore.getAll() applies options query, count, and prev direction"
);
assert_array_equals(
await wait_request(store.getAllKeys({ direction: "prev", count: 2 })),
[3, 2],
"objectStore.getAllKeys() applies options count and prev direction"
);
assert_id_array(
await wait_request(index.getAll({ query: "a", direction: "prev" })),
[2, 1],
"index.getAll() applies options query and prev direction"
);
assert_array_equals(
await wait_request(index.getAllKeys({ direction: "nextunique" })),
[1, 3],
"index.getAllKeys() applies options nextunique direction"
);
assert_array_equals(
await wait_request(index.getAllKeys({ direction: "prevunique" })),
[3, 1],
"index.getAllKeys() applies options prevunique direction"
);
assert_throws_name(
"DataError",
() => store.getAll({ query: {} }),
"objectStore.getAll() keeps invalid query validation in IndexedDB runtime"
);
assert_throws_name(
"DataError",
() => store.getAllKeys({ query: {} }),
"objectStore.getAllKeys() keeps invalid query validation in IndexedDB runtime"
);
assert_throws_name(
"DataError",
() => index.getAll({ query: {} }),
"index.getAll() keeps invalid query validation in IndexedDB runtime"
);
assert_throws_name(
"DataError",
() => index.getAllKeys({ query: {} }),
"index.getAllKeys() keeps invalid query validation in IndexedDB runtime"
);
assert_throws_name(
"TypeError",
() => store.getAll({ direction: "sideways" }),
"objectStore.getAll() validates options direction through WebIDL enum conversion"
);
assert_throws_name(
"TypeError",
() => store.getAll({}, Symbol("count")),
"objectStore.getAll() converts count before validating the raw query"
);
assert_throws_name(
"TypeError",
() => index.getAllKeys({}, Symbol("count")),
"index.getAllKeys() converts count before validating the raw query"
);
assert_throws_name(
"TypeError",
() => store.getAll({ query: {}, count: Symbol("count") }),
"objectStore.getAll() converts options count before validating options query"
);
db.close();
await wait_request(indexedDB.deleteDatabase(dbname));
}, "IndexedDB getAll/getAllKeys query arguments use WebIDL optional raw any boundaries");
</script>