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

Unified Diff: third_party/WebKit/LayoutTests/http/tests/appcache/video.html

Issue 2252663002: Convert appcache http tests to testharness.js (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: modify manifest and handle appcache "noupdate" event Created 4 years, 4 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: third_party/WebKit/LayoutTests/http/tests/appcache/video.html
diff --git a/third_party/WebKit/LayoutTests/http/tests/appcache/video.html b/third_party/WebKit/LayoutTests/http/tests/appcache/video.html
index 5e9c3414188858d805dee69ebf3d2071f78dcf02..106b6247b119e38f8bcbd6bd338c6e1393c2e38a 100644
--- a/third_party/WebKit/LayoutTests/http/tests/appcache/video.html
+++ b/third_party/WebKit/LayoutTests/http/tests/appcache/video.html
@@ -1,104 +1,38 @@
<!DOCTYPE html>
<html manifest="resources/video.manifest">
- <head>
- <title>test media in the app cache</title>
- <style>
- video { background-color: yellow; width: 320px; height: 240px; }
- </style>
- <script src=/media-resources/media-file.js></script>
- <!-- TODO(foolip): Convert test to testharness.js. crbug.com/588956
- (Please avoid writing new tests using video-test.js) -->
- <script src=/media-resources/video-test.js></script>
- <script>
- var test;
-
- function unexpectedEvent(event)
- {
- failTest(false, '<br>Unexpected "' + event.type + '" event!!');
- }
-
- function errorEvent()
- {
- consoleWrite("");
- switch(test)
- {
- case 1:
- failTest(false, "Failed loading file included in manifest!");
- break;
- case 2:
- test3()
- break;
- case 3:
- endTest();
- break;
- }
- }
-
- function durationchangeEvent()
- {
- switch(test)
- {
- case 1:
- test2();
- break;
- case 2:
- failTest("<br>Loaded file NOT included in manifest!");
- break;
- case 3:
- failTest("<br>Loaded JavaScript file as media!");
- break;
- }
- }
-
- function test3()
- {
- consoleWrite("*** Setting 'src' to non-media file that is in manifest. This file should fail to load.<br>");
-
- test = 3;
- video = document.getElementsByTagName('video')[0];
- video.src = "/media-resources/media-file.js";
- }
-
- function test2()
- {
- consoleWrite("<br>*** Setting 'src' to valid media file not in manifest. This file should fail to load.<br>");
-
- test = 2;
- video = document.getElementsByTagName('video')[0];
- video.src = "/media-resources/content/" + findMediaFile("audio", "silence");
- }
-
- function test1()
- {
- consoleWrite("*** Setting 'src' to file specified in manifest. This file should load.<br>");
- test = 1;
-
- waitForEvent('durationchange', durationchangeEvent);
- waitForEvent('error', errorEvent);
-
- video = document.getElementsByTagName('video')[0];
- video.src = "/media-resources/content/" + findMediaFile("video", "test");
- }
-
- function updateready(event)
- {
- applicationCache.swapCache();
- test1();
- }
-
- applicationCache.addEventListener("updateready", updateready, false);
- applicationCache.addEventListener("noupdate", test1, false);
- applicationCache.addEventListener("cached", test1, false);
-
- applicationCache.addEventListener("obsolete", unexpectedEvent, false);
- applicationCache.addEventListener("error", unexpectedEvent, false);
- </script>
-
- </head>
- <body>
-
- <video controls ></video>
-
- <p>Test that &lt;video&gt; can be loaded from the application cache.</p>
- </body>
-</html>
+<title>Test that "video" can be loaded from the application cache.</title>
+<script src="../resources/testharness.js"></script>
+<script src="../resources/testharnessreport.js"></script>
+<script src="/media-resources/media-file.js"></script>
+<video></video>
+<script>
+async_test(function(t) {
+ applicationCache.onupdateready = t.unreached_func();
+ applicationCache.onobsolete = t.unreached_func();
+ applicationCache.onerror = t.unreached_func();
+ applicationCache.oncached = t.step_func(test1);
+ applicationCache.onnoupdate = t.step_func(test1);
+
+ video = document.querySelector("video");
+
+ function test1() {
+ // Setting "src" to file specified in manifest. This file should load.
+ video.ondurationchange = t.step_func(test2);
+ video.onerror = t.unreached_func();
+ video.src = "/media-resources/content/" + findMediaFile("video", "test");
+ }
+
+ function test2() {
+ // Setting "src" to valid media file not in manifest. This file should fail to load.
+ video.ondurationchange = t.unreached_func();
+ video.onerror = t.step_func(test3);
+ video.src = "/media-resources/content/" + findMediaFile("audio", "silence");
+ }
+
+ function test3() {
+ // Setting "src" to non-media file that is in manifest. This file should fail to load.
+ video.src = "/media-resources/media-file.js";
+ video.onerror = t.step_func_done();
+ }
+});
+</script>

Powered by Google App Engine
This is Rietveld 408576698