jer.noble@apple.com | a74247b | 2013-11-07 17:58:57 +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 initSegment; |
| 11 | |
| 12 | if (window.internals) |
| 13 | internals.initializeMockMediaSource(); |
| 14 | |
| 15 | function runTest() { |
| 16 | findMediaElement(); |
| 17 | |
| 18 | source = new MediaSource(); |
| 19 | waitForEventOn(source, 'sourceopen', sourceOpen); |
| 20 | run('video.src = URL.createObjectURL(source)'); |
| 21 | } |
| 22 | |
| 23 | function sourceOpen() { |
| 24 | run('sourceBuffer = source.addSourceBuffer("video/mock; codecs=mock")'); |
| 25 | |
| 26 | waitForEventOn(sourceBuffer, 'updatestart'); |
| 27 | waitForEventOn(sourceBuffer, 'update'); |
| 28 | waitForEventOn(sourceBuffer, 'updateend', updateEnd); |
| 29 | initSegment = makeAInit(100, [ |
| 30 | makeATrack(1, 'mock', TRACK_KIND.VIDEO), |
| 31 | ]); |
| 32 | run('sourceBuffer.appendBuffer(initSegment)'); |
| 33 | testExpected('sourceBuffer.updating', true); |
| 34 | } |
| 35 | |
| 36 | function updateEnd() { |
| 37 | testExpected('sourceBuffer.updating', false); |
| 38 | testExpected('sourceBuffer.videoTracks.length', 1); |
| 39 | testExpected('sourceBuffer.videoTracks[0].selected', true); |
| 40 | testExpected('source.activeSourceBuffers.length', 1); |
| 41 | endTest(); |
| 42 | } |
| 43 | |
| 44 | </script> |
| 45 | </head> |
| 46 | <body onload="runTest()"> |
| 47 | <video></video> |
| 48 | </body> |
| 49 | </html> |