blob: c5e18d4fd5854998988be91665d6895773287e5b [file] [log] [blame]
hitoshi9dcf2232014-04-01 04:29:481<!doctype html>
2<html>
3<head>
4 <meta charset='utf-8'>
hitoshia4fd5842014-04-11 18:40:125 <title>Revoking a created URL with URL.revokeObjectURL(url)</title>
hitoshi9dcf2232014-04-01 04:29:486 <script src="/resources/testharness.js"></script>
7 <script src="/resources/testharnessreport.js"></script>
8</head>
9<body>
hitoshi9dcf2232014-04-01 04:29:4810<div id="log"></div>
hitoshi9dcf2232014-04-01 04:29:4811<script>
Karl Tomlinsonb6ac93b2015-06-29 20:11:4912async_test(function(t) {
hitoshi9dcf2232014-04-01 04:29:4813 var mediaSource = new MediaSource();
14 var url = window.URL.createObjectURL(mediaSource);
15 window.URL.revokeObjectURL(url);
Karl Tomlinsonb6ac93b2015-06-29 20:11:4916 mediaSource.addEventListener('sourceopen',
17 t.unreached_func("url should not reference MediaSource."));
18 var video = document.createElement('video');
hitoshi9dcf2232014-04-01 04:29:4819 video.src = url;
Karl Tomlinsonb6ac93b2015-06-29 20:11:4920 video.addEventListener('error', t.step_func_done(function(e) {
21 assert_equals(e.target.error.code,
22 MediaError.MEDIA_ERR_SRC_NOT_SUPPORTED,
23 'Expected error code');
24 assert_equals(mediaSource.readyState, 'closed');
25 }));
hitoshia4fd5842014-04-11 18:40:1226}, "Check revoking behavior of URL.revokeObjectURL(url).");
Karl Tomlinsonc74cc592015-06-29 20:11:4927async_test(function(t) {
28 var mediaSource = new MediaSource();
29 var url = window.URL.createObjectURL(mediaSource);
30 var video = document.createElement('video');
31 var unexpectedErrorHandler = t.unreached_func("Unexpected error.")
32 video.addEventListener('error', unexpectedErrorHandler);
33 video.src = url;
34 window.URL.revokeObjectURL(url);
35 mediaSource.addEventListener('sourceopen', t.step_func_done(function(e) {
36 assert_equals(mediaSource.readyState, 'open');
37 mediaSource.endOfStream();
38 video.removeEventListener('error', unexpectedErrorHandler);
39 }));
40}, "Check referenced MediaSource can open after URL.revokeObjectURL(url).");
Karl Tomlinson7ca2c252015-06-29 20:11:5041async_test(function(t) {
42 var mediaSource = new MediaSource();
43 var url = window.URL.createObjectURL(mediaSource);
44 setTimeout(function() {
45 mediaSource.addEventListener('sourceopen',
46 t.unreached_func("url should not reference MediaSource."));
47 var video = document.createElement('video');
48 video.src = url;
49 video.addEventListener('error', t.step_func_done(function(e) {
50 assert_equals(e.target.error.code,
51 MediaError.MEDIA_ERR_SRC_NOT_SUPPORTED,
52 'Expected error code');
53 assert_equals(mediaSource.readyState, 'closed');
54 }));
55 }, 0);
56}, "Check auto-revoking behavior with URL.createObjectURL(MediaSource).");
hitoshi9dcf2232014-04-01 04:29:4857</script>
58</body>
59</html>