midi.https.html (1348B)
1 <!DOCTYPE html> 2 <script src="/resources/testharness.js"></script> 3 <script src="/resources/testharnessreport.js"></script> 4 <script src="/speculation-rules/prerender/resources/utils.js"></script> 5 <script src="/speculation-rules/prerender/resources/deferred-promise-utils.js"></script> 6 7 <script> 8 const params = new URLSearchParams(location.search); 9 10 // The main test page (restriction-midi.https.html) loads the initiator page, 11 // then the initiator page will prerender itself with the `prerendering` 12 // parameter. 13 const isPrerendering = params.has('prerendering'); 14 15 if (!isPrerendering) { 16 loadInitiatorPage(); 17 } else { 18 const prerenderEventCollector = new PrerenderEventCollector(); 19 const promise = new Promise((resolve, reject) => { 20 navigator.requestMIDIAccess({sysex: params.get("sysex") === "true"}).then( 21 _ => { resolve(); }, 22 e => { 23 // Chromium rejects the promise on trybots with an error like: 24 // ALSA lib seq_hw.c:457:(snd_seq_hw_open) open /dev/snd/seq failed: 25 // Permission denied 26 // 27 // See https://crbug.com/371230 for a similar bug. 28 // 29 // Just ignore any errors for now. The test passes if the promise 30 // settles after activation. 31 resolve(); 32 }); 33 }); 34 prerenderEventCollector.start(promise, 'navigator.requestMIDIAccess'); 35 } 36 37 </script>