Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,8 @@ inline constexpr std::string_view indexeddb_compatibility_source = R"JS(
deleteIndex() { throw failure('Indexes are not implemented', 'NotSupportedError'); }
}

class IDBTransaction extends EventTarget {
)JS"
R"JS( class IDBTransaction extends EventTarget {
constructor(database, storeNames, mode, state, revision, versionchange = false) {
super();
this.db = database;
Expand Down
27 changes: 27 additions & 0 deletions scripts/tests/test_v8_bootstrap_literals.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

from __future__ import annotations

import hashlib
import importlib.util
import pathlib
import re
Expand All @@ -21,6 +22,13 @@
SERVICE_WORKER_PATH = RUNTIME_PATH.with_name(
"webscene_v8_runtime_service_workers.inc"
)
INDEXEDDB_PATH = (
ROOT
/ "experiments"
/ "WebScene.NativeEngine.Probe"
/ "native"
/ "webscene_indexeddb_compatibility.h"
)

SPEC = importlib.util.spec_from_file_location("extract_bootstraps", EXTRACTOR_PATH)
assert SPEC is not None and SPEC.loader is not None
Expand Down Expand Up @@ -57,6 +65,25 @@ def test_service_worker_bootstrap_literals_are_portable(self) -> None:
)
)

def test_indexeddb_bootstrap_is_portable_and_byte_exact(self) -> None:
source = INDEXEDDB_PATH.read_text(encoding="utf-8")
parts = EXTRACTOR.extract_parts(
source, "indexeddb_compatibility_source"
)
joined = "".join(parts)

self.assertGreater(len(parts), 1)
self.assertTrue(
all(
len(part.encode("utf-8")) <= EXTRACTOR.MAX_RAW_LITERAL_BYTES
for part in parts
)
)
self.assertEqual(
hashlib.sha256(joined.encode("utf-8")).hexdigest(),
"a3c907644e9b6c9d63eddfbd6a591802e99bbd3249a3b1437788ce4eb1c73b64",
)


if __name__ == "__main__":
unittest.main()
Loading