Chromium Code Reviews| Index: third_party/WebKit/LayoutTests/http/tests/media/media-source/mediasource-preload.html |
| diff --git a/third_party/WebKit/LayoutTests/http/tests/media/media-source/mediasource-preload.html b/third_party/WebKit/LayoutTests/http/tests/media/media-source/mediasource-preload.html |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..aac25baf038eae44ba8507028b67fb72d5fe618d |
| --- /dev/null |
| +++ b/third_party/WebKit/LayoutTests/http/tests/media/media-source/mediasource-preload.html |
| @@ -0,0 +1,72 @@ |
| +<!DOCTYPE html> |
| +<html> |
| + <head> |
| + <script src="/w3c/resources/testharness.js"></script> |
| + <script src="/w3c/resources/testharnessreport.js"></script> |
| + <script src="mediasource-util.js"></script> |
| + <link rel="stylesheet" href="/w3c/resources/testharness.css"> |
| + </head> |
| + <body> |
| + <script> |
| + function attachWithPreloadTest(preload) |
| + { |
| + async_test(function(test) |
| + { |
| + var videoTag = document.createElement('video'); |
|
philipj_slow
2016/04/22 09:22:15
I was thinking just "video", I take "tag" to mean
wolenetz
2016/04/25 19:43:21
Done.
|
| + var mediaSource = new MediaSource(); |
| + var mediaSourceURL = URL.createObjectURL(mediaSource); |
| + |
| + videoTag.preload = preload; |
| + document.body.appendChild(videoTag); |
| + test.add_cleanup(function() { |
| + document.body.removeChild(videoTag); |
| + URL.revokeObjectURL(mediaSourceURL); |
| + }); |
| + |
| + var listener = test.step_func(function(event) |
| + { |
| + mediaSource.removeEventListener("sourceopen", listener); |
|
philipj_slow
2016/04/22 09:22:15
Do you need to remove the event listener, can the
wolenetz
2016/04/25 19:43:21
Done.
|
| + test.done(); |
| + }); |
| + |
| + mediaSource.addEventListener("sourceopen", listener); |
| + videoTag.src = mediaSourceURL; |
| + }, "sourceopen occurs with element preload=" + preload); |
| + } |
| + |
| + attachWithPreloadTest('auto'); |
| + attachWithPreloadTest('metadata'); |
| + attachWithPreloadTest('none'); |
| + |
| + function errorWithPreloadTest(preload) |
| + { |
| + async_test(function(test) |
| + { |
| + var videoTag = document.createElement('video'); |
| + var mediaSource = new MediaSource(); |
| + var mediaSourceURL = URL.createObjectURL(mediaSource); |
| + URL.revokeObjectURL(mediaSourceURL); |
| + |
| + videoTag.preload = preload; |
| + document.body.appendChild(videoTag); |
| + test.add_cleanup(function() { document.body.removeChild(videoTag); }); |
| + |
| + var listener = test.step_func(function(event) |
| + { |
| + mediaSource.removeEventListener("sourceopen", listener); |
| + test.fail(); |
| + }); |
| + |
| + mediaSource.addEventListener("sourceopen", listener); |
| + |
| + videoTag.onerror = test.step_func(function(event) { test.done(); }); |
| + videoTag.src = mediaSourceURL; |
| + }, "error occurs with bogus (revoked) object URL and element preload=" + preload); |
|
philipj_slow
2016/04/22 09:22:15
This is good, I didn't think to test revoked URLs.
wolenetz
2016/04/25 19:43:21
Done. (blob:a and real unrevoked MediaSource objec
|
| + } |
| + |
| + errorWithPreloadTest('auto'); |
| + errorWithPreloadTest('metadata'); |
| + errorWithPreloadTest('none'); |
| + </script> |
| + </body> |
| +</html> |