Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(528)

Side by Side Diff: chrome/test/data/prerender/prerender_html5_audio_jsplay.html

Issue 8095007: Defer loading of audio/video tags while prerendering. (Closed) Base URL: http://git.chromium.org/git/chromium.git@trunk
Patch Set: Adding more tests and addressing all comments. Created 9 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
1 <html>
2 <!--
3 This test checks that:
4 - Audio tags are deferred during prerendering.
5 - The audio starts playing on page swap in when it has been played by js.
6 -->
7 <head>
8 <title>Prerender for HTML5 audio.</title>
9 </head>
10
11 <body>
12 <audio id="audioEl" controls>
13 <source src="bear.wav" type="audio/wav" />
14 </audio>
15
16 <script>
17 var canPlaySeen = false;
18 var playingSeen = false;
19 var canPlayThroughSeen = false;
20 var hasError = false;
21
22 var audioEl = document.getElementById("audioEl");
23 audioEl.play();
24
25 function audioEventHandler(e) {
26 console.log(e.type);
27
28 if (e.type == 'canplay') {
scherkus (not reviewing) 2011/10/24 18:30:44 nit: I'd use a switch/case statement here instead
Shishir 2011/10/31 21:16:31 Done.
29 canPlaySeen = true;
30 } else if (e.type == 'playing') {
31 playingSeen = true;
32 if (canPlayThroughSeen)
33 document.title = "PASS";
34 } else if (e.type == 'error') {
35 hasError = true;
36 } else if (e.type == 'canplaythrough') {
37 canPlayThroughSeen = true;
38 if (playingSeen)
39 document.title = "PASS";
40 }
41 }
42
43 audioEl.addEventListener('playing', audioEventHandler, false);
scherkus (not reviewing) 2011/10/24 18:30:44 is it possible to move some of this code inside a
Shishir 2011/10/31 21:16:31 Done.
44 audioEl.addEventListener('canplay', audioEventHandler, false);
45 audioEl.addEventListener('canplaythrough', audioEventHandler, false);
46 audioEl.addEventListener('error', audioEventHandler, false);
47
48 function DidPrerenderPass() {
49 // The audio should not have started at this point.
50 return !canPlaySeen && !playingSeen && !hasError &&
51 audioEl.currentTime == 0 &&
52 audioEl.readyState == audioEl.HAVE_NOTHING;
53 }
54
55 function DidDisplayPass() {
56 // The actual test is done via the TitleWatcher.
57 return true;
58 }
59
60 </script>
61 </body>
62 </html>
OLDNEW
« no previous file with comments | « chrome/test/data/prerender/prerender_html5_audio_autoplay.html ('k') | chrome/test/data/prerender/prerender_html5_video.html » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698