diff --git a/experiments/WebScene.NativeEngine.Probe/native/webscene_indexeddb_compatibility.h b/experiments/WebScene.NativeEngine.Probe/native/webscene_indexeddb_compatibility.h index e7d0ec344..51b55eaf3 100644 --- a/experiments/WebScene.NativeEngine.Probe/native/webscene_indexeddb_compatibility.h +++ b/experiments/WebScene.NativeEngine.Probe/native/webscene_indexeddb_compatibility.h @@ -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; diff --git a/scripts/tests/test_v8_bootstrap_literals.py b/scripts/tests/test_v8_bootstrap_literals.py index f18c382d5..6815e49e2 100644 --- a/scripts/tests/test_v8_bootstrap_literals.py +++ b/scripts/tests/test_v8_bootstrap_literals.py @@ -3,6 +3,7 @@ from __future__ import annotations +import hashlib import importlib.util import pathlib import re @@ -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 @@ -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()