mediasource-worker-objecturl.html (2319B)
1 <!DOCTYPE html> 2 <html> 3 <title>Test MediaSource object and objectUrl creation and load via that url should fail, with MediaSource in dedicated worker</title> 4 <script src="/resources/testharness.js"></script> 5 <script src="/resources/testharnessreport.js"></script> 6 <script src="mediasource-message-util.js"></script> 7 <script> 8 9 async_test(t => { 10 // Fail fast if MSE-in-Workers is not supported. 11 assert_true(MediaSource.hasOwnProperty("canConstructInDedicatedWorker"), "MediaSource hasOwnProperty 'canConstructInDedicatedWorker'"); 12 assert_true(MediaSource.canConstructInDedicatedWorker, "MediaSource.canConstructInDedicatedWorker"); 13 14 let worker = new Worker("mediasource-worker-get-objecturl.js"); 15 worker.onmessage = t.step_func(e => { 16 let subject = e.data.subject; 17 assert_true(subject != undefined, "message must have a subject field"); 18 switch (subject) { 19 case messageSubject.ERROR: 20 assert_unreached("Worker error: " + e.data.info); 21 break; 22 case messageSubject.OBJECT_URL: 23 const url = e.data.info; 24 const video = document.createElement("video"); 25 document.body.appendChild(video); 26 video.onerror = t.step_func((target) => { 27 assert_true(video.error != null); 28 assert_equals(video.error.code, MediaError.MEDIA_ERR_SRC_NOT_SUPPORTED); 29 t.done(); 30 }); 31 video.onended = t.unreached_func("video should not have successfully loaded and played to end"); 32 video.src = url; 33 break; 34 default: 35 assert_unreached("Unexpected message subject: " + subject); 36 } 37 }); 38 }, "Test main context load of a DedicatedWorker MediaSource object URL should fail"); 39 40 if (MediaSource.hasOwnProperty("canConstructInDedicatedWorker") && MediaSource.canConstructInDedicatedWorker === true) { 41 // If implementation claims support for MSE-in-Workers, then fetch and run 42 // some tests directly in another dedicated worker and get their results 43 // merged into those from this page. 44 fetch_tests_from_worker(new Worker("mediasource-worker-objecturl.js")); 45 } else { 46 // Otherwise, fetch and run a test that verifies lack of support of 47 // MediaSource construction in another dedicated worker. 48 fetch_tests_from_worker(new Worker("mediasource-worker-must-fail-if-unsupported.js")); 49 } 50 51 </script> 52 </html>