File tree Expand file tree Collapse file tree
experiments/WebScene.NativeEngine.Probe/native/media Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -95,7 +95,8 @@ class MediaDevices extends EventTarget {
9595 async enumerateDevices(){
9696 const response=await native('enumerateDevices');
9797 const malformed=()=>new DOMException('The native media-device response is invalid','DataError');
98- if(!response||response.type!=='application/vnd.webscene.media-devices+json'||!(response.bytes instanceof Uint8Array)||response.bytes.byteLength>262144)throw malformed();
98+ )AUDIOJS"
99+ R" AUDIOJS( if(!response||response.type!=='application/vnd.webscene.media-devices+json'||!(response.bytes instanceof Uint8Array)||response.bytes.byteLength>262144)throw malformed();
99100 let payload;try{payload=JSON.parse(new TextDecoder('utf-8',{fatal:true}).decode(response.bytes));}catch{throw malformed();}
100101 if(!payload||payload.version!==1||!Array.isArray(payload.devices)||payload.devices.length>64)throw malformed();
101102 const ids=new Set(),records=[];
Original file line number Diff line number Diff line change 2222SERVICE_WORKER_PATH = RUNTIME_PATH .with_name (
2323 "webscene_v8_runtime_service_workers.inc"
2424)
25+ AUDIO_PLATFORM_PATH = (
26+ ROOT
27+ / "experiments"
28+ / "WebScene.NativeEngine.Probe"
29+ / "native"
30+ / "media"
31+ / "audio_platform.js.inc"
32+ )
2533INDEXEDDB_PATH = (
2634 ROOT
2735 / "experiments"
@@ -82,6 +90,23 @@ def test_service_worker_bootstrap_literals_are_portable(self) -> None:
8290 )
8391 )
8492
93+ def test_audio_platform_literals_are_portable_and_byte_exact (self ) -> None :
94+ source = AUDIO_PLATFORM_PATH .read_text (encoding = "utf-8" )
95+ parts = re .findall (r'R"AUDIOJS\((.*?)\)AUDIOJS"' , source , re .DOTALL )
96+ joined = "" .join (parts )
97+
98+ self .assertGreater (len (parts ), 1 )
99+ self .assertTrue (
100+ all (
101+ len (part .encode ("utf-8" )) <= EXTRACTOR .MAX_RAW_LITERAL_BYTES
102+ for part in parts
103+ )
104+ )
105+ self .assertEqual (
106+ hashlib .sha256 (joined .encode ("utf-8" )).hexdigest (),
107+ "3dd3dccc775d895fad213a3622ae8a678f6d5557af842a40060f66bcc9a3ce59" ,
108+ )
109+
85110 def test_indexeddb_bootstrap_is_portable_and_byte_exact (self ) -> None :
86111 source = INDEXEDDB_PATH .read_text (encoding = "utf-8" )
87112 parts = EXTRACTOR .extract_parts (
You can’t perform that action at this time.
0 commit comments