commit-queue@webkit.org | e8f13d7 | 2015-01-24 00:52:42 +0000 | [diff] [blame] | 1 | <!DOCTYPE html> |
| 2 | <html> |
| 3 | <head> |
| 4 | <title>mock-media-source</title> |
| 5 | <script src="mock-media-source.js"></script> |
| 6 | <script src="../video-test.js"></script> |
| 7 | <script> |
| 8 | var source; |
| 9 | var sourceBuffer; |
| 10 | var mediaSegment; |
| 11 | |
| 12 | if (window.internals) |
| 13 | internals.initializeMockMediaSource(); |
| 14 | |
| 15 | function runTest() { |
| 16 | findMediaElement(); |
| 17 | |
| 18 | source = new MediaSource(); |
| 19 | waitForEventOn(source, 'sourceopen', sourceOpen, false, true); |
| 20 | run('video.src = URL.createObjectURL(source)'); |
| 21 | } |
| 22 | |
| 23 | function sourceOpen() { |
| 24 | run('sourceBuffer = source.addSourceBuffer("video/mock; codecs=mock")'); |
| 25 | waitForEventOn(sourceBuffer, 'updateend', updateEnd1, false, true); |
| 26 | mediaSegment = concatenateSamples([ |
| 27 | makeAInit(10, [makeATrack(1, 'mock', TRACK_KIND.VIDEO)]), |
aboya@igalia.com | ace4003 | 2018-10-31 21:04:07 +0000 | [diff] [blame] | 28 | makeASample(0, 0, 5, 1, 1, SAMPLE_FLAG.SYNC, 0), |
commit-queue@webkit.org | e8f13d7 | 2015-01-24 00:52:42 +0000 | [diff] [blame] | 29 | ]); |
| 30 | run('sourceBuffer.appendBuffer(mediaSegment)'); |
| 31 | |
| 32 | } |
| 33 | |
| 34 | function updateEnd1() { |
| 35 | testExpected('source.duration.toFixed(3)', 10); |
| 36 | testExpected('sourceBuffer.buffered.end(0).toFixed(3)', 5); |
| 37 | |
| 38 | waitForEventOn(source, 'sourceopen', function() { failTest("Should not transit to 'open' state during endOfStream().") }, false, true); |
commit-queue@webkit.org | e8f13d7 | 2015-01-24 00:52:42 +0000 | [diff] [blame] | 39 | run('source.endOfStream()'); |
| 40 | testExpected('source.duration.toFixed(3)', 5); |
jer.noble@apple.com | aae356e | 2016-09-12 21:09:15 +0000 | [diff] [blame] | 41 | testExpected('sourceBuffer.updating', false); |
| 42 | endTest(); |
commit-queue@webkit.org | e8f13d7 | 2015-01-24 00:52:42 +0000 | [diff] [blame] | 43 | } |
| 44 | |
| 45 | </script> |
| 46 | </head> |
| 47 | <body onload="runTest()"> |
| 48 | <video></video> |
| 49 | </body> |
| 50 | </html> |