Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / third_party / WebKit / LayoutTests / http / tests / media / media-source / mediasource-detach.html
blob3d612bcfd025e21d11cca7604ed7f7fb13f20489
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 <div id="log"></div>
11 <script>
12 function mediasource_detach_test(testFunction, description)
14 mediasource_test(function(test, mediaElement, mediaSource)
16 var segmentInfo = MediaSourceUtil.SEGMENT_INFO;
17 var sourceBuffer = mediaSource.addSourceBuffer(segmentInfo.type);
19 assert_equals(mediaElement.readyState, HTMLMediaElement.HAVE_NOTHING);
20 assert_equals(mediaSource.readyState, 'open');
22 mediaSource.addEventListener('sourceclose', test.step_func(function (event)
24 assert_equals(mediaSource.sourceBuffers.length, 0, 'sourceBuffers is empty');
25 assert_equals(mediaSource.activeSourceBuffers.length, 0, 'activeSourceBuffers is empty');
26 assert_equals(mediaSource.readyState, 'closed', 'readyState is "closed"');
27 assert_true(Number.isNaN(mediaSource.duration), 'duration is NaN');
28 test.done();
29 }));
31 MediaSourceUtil.loadBinaryData(test, segmentInfo.url, function(mediaData)
33 testFunction(test, mediaElement, mediaSource, sourceBuffer, mediaData);
34 });
35 }, description);
38 mediasource_detach_test(function(test, mediaElement, mediaSource, sourceBuffer, mediaData)
40 mediaElement.load();
41 }, 'Test media.load() before appending data will trigger MediaSource detaching from a media element.');
43 mediasource_detach_test(function(test, mediaElement, mediaSource, sourceBuffer, mediaData)
45 sourceBuffer.addEventListener('updateend', test.step_func(function (event)
47 // FIXME: MediaElement.readyState could be HAVE_NOTHING when running multiple times.
48 // assert_greater_than(mediaElement.readyState, HTMLMediaElement.HAVE_NOTHING, 'media readyState is greater than "HAVE_NOTHING"')
49 assert_false(sourceBuffer.updating, 'updating attribute is false');
50 mediaElement.load();
51 }));
53 sourceBuffer.appendBuffer(mediaData);
54 }, 'Test media.load() after appending data will trigger MediaSource detaching from a media element.');
55 </script>
56 </body>
57 </html>