Index: third_party/WebKit/LayoutTests/http/tests/media/media-source/mediasource-gc-after-decode-error-crash.html |
diff --git a/third_party/WebKit/LayoutTests/http/tests/media/media-source/mediasource-gc-after-decode-error-crash.html b/third_party/WebKit/LayoutTests/http/tests/media/media-source/mediasource-gc-after-decode-error-crash.html |
index 6e8732b535bd416a877a1b8bde21fc1611ddd34b..4e3f915a8f5a41ca34df3d65aa7e22a2da699dee 100644 |
--- a/third_party/WebKit/LayoutTests/http/tests/media/media-source/mediasource-gc-after-decode-error-crash.html |
+++ b/third_party/WebKit/LayoutTests/http/tests/media/media-source/mediasource-gc-after-decode-error-crash.html |
@@ -1,62 +1,42 @@ |
-<!doctype html> |
-<html> |
- <head> |
- <!-- 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> |
- </head> |
- <body> |
- <p>Verifies that a MediaSource decode error followed by a gc() and page reload does not trigger a crash.</p> |
- <video></video> |
- <script> |
- function onSourceOpen(e) |
- { |
- consoleWrite("onSourceOpen"); |
- var ms = e.target; |
- ms.removeEventListener("sourceopen", onSourceOpen); |
- |
- var v = document.querySelector("video"); |
- URL.revokeObjectURL(v.src); |
- |
- // Create a SourceBuffer and append garbage so a decode error will occur |
- // and the MediaSource will get closed. |
- ms.addEventListener("sourceclose", onSourceClose); |
- var sb = ms.addSourceBuffer("video/webm;codecs=\"vp8\""); |
- var buf = new Uint8Array(10); |
- sb.appendBuffer(buf); |
- } |
- |
- function onSourceClose(e) |
- { |
- consoleWrite("onSourceClose"); |
- e.target.removeEventListener("sourceclose", onSourceClose); |
+<!DOCTYPE html> |
+<title>Verifies that a MediaSource decode error followed by a gc() and page reload does not trigger a crash.</title> |
+<script src="/w3c/resources/testharness.js"></script> |
+<script src="/w3c/resources/testharnessreport.js"></script> |
+<video></video> |
+<script> |
+async_test(function(t) { |
+ var video = document.querySelector('video'); |
+ var mediaSource = new MediaSource(); |
+ |
+ mediaSource.onsourceopen = t.step_func(function() { |
+ mediaSource.onsourceopen = null; |
+ URL.revokeObjectURL(video.src); |
+ |
+ // Create a SourceBuffer and append garbage so a decode error will occur |
+ // and the MediaSource will get closed. |
+ mediaSource.onsourceclose = t.step_func(function() { |
+ mediaSource.onsourceclose = null; |
// Schedule a GC and page reload. We need a timeout here so that |
// the MediaSource reference used by this event is cleared before |
// we try to GC & reload. |
- setTimeout(gcAndReloadPage, 0); |
- } |
+ setTimeout(t.step_func(function() { |
+ gc(); |
- function gcAndReloadPage() |
- { |
- consoleWrite("Running gc()."); |
- gc(); |
- |
- var suffix = "?2"; |
- if (document.location.href.indexOf(suffix) != -1) { |
- endTest(); |
+ var suffix = "?2"; |
+ if (document.location.href.indexOf(suffix) != -1) { |
+ t.done(); |
return; |
- } |
- |
- document.location.href += suffix; |
- } |
- |
- (function() |
- { |
- var ms = new MediaSource(); |
- ms.addEventListener("sourceopen", onSourceOpen); |
- document.querySelector("video").src = URL.createObjectURL(ms); |
- })(); |
- </script> |
- </body> |
-</html> |
+ } |
+ |
+ document.location.href += suffix; |
+ }), 0); |
+ }); |
+ var sourceBuffer = mediaSource.addSourceBuffer("video/webm;codecs=\"vp8\""); |
+ var buffer = new Uint8Array(10); |
+ sourceBuffer.appendBuffer(buffer); |
+ }); |
+ |
+ video.src = URL.createObjectURL(mediaSource); |
+}); |
+</script> |