4 <title>delay document 'load' event test
</title>
5 <style> video { border:
3px solid red; }
</style>
6 <script src=video-test.js
></script>
7 <script src=media-file.js
></script>
11 function testMovieWithNoSource(elem
)
13 video
= elem
; // Need it in a global for testExpected() to see it.
14 consoleWrite("<em>no 'src'.</em>");
15 testExpected("video.networkState", HTMLMediaElement
.prototype.NETWORK_EMPTY
, "==");
16 testExpected("video.readyState", HTMLMediaElement
.prototype.HAVE_NOTHING
, "==");
19 function testMovieWithSource(elem
, hasLoaded
, msg
)
21 video
= elem
; // Need it in a global for testExpected() to see it.
24 // The movie should have loaded at least to HAVE_CURRENT_DATA
25 testExpected("video.networkState", HTMLMediaElement
.prototype.NETWORK_NO_SOURCE
, "!=");
26 testExpected("video.networkState", HTMLMediaElement
.prototype.NETWORK_IDLE
, ">=");
27 testExpected("video.readyState", HTMLMediaElement
.prototype.HAVE_CURRENT_DATA
, ">=");
29 testExpected("video.networkState", HTMLMediaElement
.prototype.NETWORK_NO_SOURCE
, "==");
30 testExpected("video.readyState", HTMLMediaElement
.prototype.HAVE_NOTHING
, "==");
36 consoleWrite("<br><b>document <em>'load'<" + "/em> event handler</b>");
38 testMovieWithNoSource(document
.getElementById('video-1'));
39 testMovieWithSource(document
.getElementById('video-2'), true, "<br><em>with 'src' attribute.</em>");
40 testMovieWithSource(document
.getElementById('video-3'), true, "<br><em>with <source> element.</em>");
42 if (window
.testRunner
)
43 testRunner
.notifyDone();
47 <body onload=
"loaded()">
48 <video id=
"video-1"></video>
49 <video id=
"video-2"></video>
50 <video id=
"video-3"><source id=
"source-1"></video>
52 <p>Test the document's load event is delayed until a movie's meta data is available.
</p>
55 consoleWrite("<br><b>inline script</b>");
57 testMovieWithNoSource(document
.getElementById('video-1'));
59 video
= document
.getElementById('video-2');
60 video
.src
= findMediaFile("video", "content/test");
61 testMovieWithSource(video
, false, "<br><em>with 'src' attribute.</em>");
63 source
= document
.getElementById('source-1');
64 source
.src
= findMediaFile("video", "content/test");
65 testMovieWithSource(document
.getElementById('video-3'), false, "<br><em>with <source> element.</em>");
66 document
.getElementById('video-3').load();