OLD | NEW |
(Empty) | |
| 1 <!DOCTYPE html> |
| 2 <html> |
| 3 <head> |
| 4 <script src="/w3c/resources/testharness.js"></script> |
| 5 <script src="/w3c/resources/testharnessreport.js"></script> |
| 6 <script src="mediasource-util.js"></script> |
| 7 <link rel="stylesheet" href="/w3c/resources/testharness.css"> |
| 8 </head> |
| 9 <body> |
| 10 <script> |
| 11 function attachWithPreloadTest(preload) |
| 12 { |
| 13 async_test(function(test) |
| 14 { |
| 15 var video = document.createElement("video"); |
| 16 var mediaSource = new MediaSource(); |
| 17 var mediaSourceURL = URL.createObjectURL(mediaSource); |
| 18 |
| 19 video.preload = preload; |
| 20 document.body.appendChild(video); |
| 21 test.add_cleanup(function() { |
| 22 document.body.removeChild(video); |
| 23 URL.revokeObjectURL(mediaSourceURL); |
| 24 }); |
| 25 |
| 26 var listener = test.step_func(function(event) { test.done();
}); |
| 27 mediaSource.addEventListener("sourceopen", listener); |
| 28 video.src = mediaSourceURL; |
| 29 }, "sourceopen occurs with element preload=" + preload); |
| 30 } |
| 31 |
| 32 attachWithPreloadTest("auto"); |
| 33 attachWithPreloadTest("metadata"); |
| 34 attachWithPreloadTest("none"); |
| 35 |
| 36 function errorWithPreloadTest(preload, bogusURLStyle) |
| 37 { |
| 38 var testURLdescription; |
| 39 var mediaSource = new MediaSource(); |
| 40 var bogusURL; |
| 41 |
| 42 if (bogusURLStyle == "revoked") { |
| 43 testURLdescription = "revoked MediaSource object URL"; |
| 44 bogusURL = URL.createObjectURL(mediaSource); |
| 45 URL.revokeObjectURL(bogusURL); |
| 46 } else if (bogusURLStyle == "corrupted") { |
| 47 testURLdescription = "corrupted MediaSource object URL"; |
| 48 bogusURL = URL.createObjectURL(mediaSource); |
| 49 bogusURL += "0"; |
| 50 } else { |
| 51 testURLdescription = bogusURL = bogusURLStyle; |
| 52 } |
| 53 |
| 54 async_test(function(test) |
| 55 { |
| 56 var video = document.createElement("video"); |
| 57 |
| 58 video.preload = preload; |
| 59 document.body.appendChild(video); |
| 60 test.add_cleanup(function() { document.body.removeChild(vide
o); }); |
| 61 |
| 62 var listener = test.step_func(function(event) { test.fail();
}); |
| 63 mediaSource.addEventListener("sourceopen", listener); |
| 64 |
| 65 video.onerror = test.step_func(function(event) { test.done()
; }); |
| 66 video.src = bogusURL; |
| 67 }, "error occurs with bogus blob URL (" + testURLdescription + "
) and element preload=" + preload); |
| 68 } |
| 69 |
| 70 errorWithPreloadTest("auto", "revoked"); |
| 71 errorWithPreloadTest("metadata", "revoked"); |
| 72 errorWithPreloadTest("none", "revoked"); |
| 73 |
| 74 errorWithPreloadTest("auto", "blob:a"); |
| 75 errorWithPreloadTest("metadata", "blob:a"); |
| 76 errorWithPreloadTest("none", "blob:a"); |
| 77 |
| 78 errorWithPreloadTest("auto", "corrupted"); |
| 79 errorWithPreloadTest("metadata", "corrupted"); |
| 80 errorWithPreloadTest("none", "corrupted"); |
| 81 </script> |
| 82 </body> |
| 83 </html> |
OLD | NEW |