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

Unified Diff: chrome/test/data/prerender/prerender_html5_video.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 side-by-side diff with in-line comments
Download patch
Index: chrome/test/data/prerender/prerender_html5_video.html
diff --git a/chrome/test/data/prerender/prerender_html5_video.html b/chrome/test/data/prerender/prerender_html5_video.html
index d945d19ad9d9bd7538c05daa5da66e0d9178b173..167ecdfd02fc77d9281ee7f7f5505617e60d69e3 100644
--- a/chrome/test/data/prerender/prerender_html5_video.html
+++ b/chrome/test/data/prerender/prerender_html5_video.html
@@ -1,13 +1,55 @@
<html>
<!--
- This test checks that prerender is cancelled when an video tag is
- encountered.
+ This test checks that video tags are deferred during prerendering.
-->
- <head>
- <title>Prerender cancellation for HTML5 video.</title>
- </head>
- <body>
- <video src="nonexistant.mp4" width="320" height="240" controls="controls">
- </video>
- </body>
+<head>
+<title>Prerender for HTML5 video.</title>
+</head>
+
+<body>
+<video id="videoEl" controls>
+ <source src="bear.ogv" type="video/ogg" />
+</video>
+
+<script>
+var canPlaySeen = false;
+var playingSeen = false;
+var hasError = false;
+
+var videoEl = document.getElementById("videoEl");
+
+function videoEventHandler(e) {
+ console.log(e.type);
+
+ if (e.type == 'canplay') {
+ canPlaySeen = true;
+ } else if (e.type == 'playing') {
+ playingSeen = true;
+ } else if (e.type == 'error') {
+ hasError = true;
+ } else if (e.type == 'canplaythrough') {
+ if (!playingSeen && canPlaySeen)
+ document.title = "PASS";
+ }
+}
+
+videoEl.addEventListener('playing', videoEventHandler, false);
+videoEl.addEventListener('canplay', videoEventHandler, false);
+videoEl.addEventListener('canplaythrough', videoEventHandler, false);
+videoEl.addEventListener('error', videoEventHandler, false);
+
+function DidPrerenderPass() {
+ // The video should not have started at this point.
+ return !canPlaySeen && !playingSeen && !hasError &&
+ videoEl.currentTime == 0 &&
+ videoEl.readyState == videoEl.HAVE_NOTHING;
+}
+
+function DidDisplayPass() {
+ // The actual test is done via the TitleWatcher.
+ return true;
+}
+
+</script>
+</body>
</html>

Powered by Google App Engine
This is Rietveld 408576698