blob: 048abddcf12ac38109494186fb05d7b64273e856 [file] [log] [blame]
jer.noble@apple.com57ab0f42017-05-20 16:55:01 +00001<!DOCTYPE html>
2<html>
3<head>
4 <title>media-source-stalled-holds-sleep-assertion</title>
5 <script src="media-source-loader.js"></script>
6 <script src="../video-test.js"></script>
7 <script>
8
9 var canvas;
10 var loader;
11 var source;
12 var sourceBuffer;
13
14 function runTest() {
15 mediaElement = video = document.createElement('video');
16
17 loader = new MediaSourceLoader('content/test-fragmented-manifest.json');
18 loader.onload = mediaDataLoaded;
19 loader.onerror = mediaDataLoadingFailed;
20 }
21
22 function mediaDataLoadingFailed() {
23 failTest('Media data loading failed');
24 }
25
26 function mediaDataLoaded() {
27 source = new MediaSource();
28 waitForEvent('sourceopen', sourceOpen, false, false, source);
29 video.src = URL.createObjectURL(source);
30 }
31
32 function sourceOpen() {
33 source.duration = loader.duration();
34 sourceBuffer = source.addSourceBuffer(loader.type());
35 waitForEventOn(sourceBuffer, 'update', sourceInitialized, false, true);
36 sourceBuffer.appendBuffer(loader.initSegment());
37 }
38
39 function sourceInitialized() {
40 waitForEvent('canplay', canPlay, false, true);
41 sourceBuffer.appendBuffer(loader.mediaSegment(0));
42 }
43
44 function paint() {
45 canvas = document.createElement('canvas');
46 canvas.width = video.videoWidth / 2;
47 canvas.height = video.videoHeight / 2;
48 canvas.getContext('2d').drawImage(video, 0, 0, canvas.width, canvas.height);
49 document.getElementById('canvases').appendChild(canvas);
50 testExpected('canvas.getContext("2d").getImageData(250, 130, 1, 1).data[0]', '0', '!=');
51 }
52
53 function canPlay() {
54 waitForEvent('seeked', seeked1, false, true);
55 run('video.currentTime += 1.001 / 24');
56 }
57
58 function seeked1() {
59 paint();
60 waitForEvent('seeked', seeked2, false, true);
61 run('video.currentTime += 1.001 / 24');
62 }
63
64 function seeked2() {
65 paint();
66 waitForEvent('seeked', seeked3, false, true);
67 run('video.currentTime += 1.001 / 24');
68 }
69
70 function seeked3() {
71 paint();
72 endTest();
73 }
74 </script>
75</head>
76<body onload="runTest()">
77 <div id="canvases"></canvas>
78</body>
79</html>