Index: third_party/WebKit/LayoutTests/media/invalid-media-url-crash.html |
diff --git a/third_party/WebKit/LayoutTests/media/invalid-media-url-crash.html b/third_party/WebKit/LayoutTests/media/invalid-media-url-crash.html |
index 7931f70091d9284e196303cb4e384ccca1c4abfb..12a2ae24c5570d9dc83d9328bf15c70fa101b8c7 100644 |
--- a/third_party/WebKit/LayoutTests/media/invalid-media-url-crash.html |
+++ b/third_party/WebKit/LayoutTests/media/invalid-media-url-crash.html |
@@ -1,34 +1,20 @@ |
-<html> |
- <body> |
- <p>Tests that invalid media src url does not result in crash.</p> |
- <!-- TODO(foolip): Convert test to testharness.js. crbug.com/588956 |
- (Please avoid writing new tests using video-test.js) --> |
- <script src=video-test.js></script> |
- <script> |
- var invalid_url = "!:/" + String.fromCharCode(0) + "%aa#aa"; |
- var error_count = 0; |
+<!DOCTYPE html> |
+<title>Tests that invalid media src url does not result in crash.</title> |
+<script src="../resources/testharness.js"></script> |
+<script src="../resources/testharnessreport.js"></script> |
+<script> |
+function check_invalid_media_src(elementName) { |
+ async_test(function(t) { |
+ var mediaElement = document.createElement(elementName); |
+ mediaElement.src = "!:/" + String.fromCharCode(0) + "%aa#aa"; |
- function errorEvent() |
- { |
- error_count++; |
- if (error_count == 2) |
- { |
- testExpected("audio.error.code", MediaError.MEDIA_ERR_SRC_NOT_SUPPORTED); |
- testExpected("video.error.code", MediaError.MEDIA_ERR_SRC_NOT_SUPPORTED); |
- testExpected("audio.networkState", HTMLMediaElement.NETWORK_NO_SOURCE); |
- testExpected("video.networkState", HTMLMediaElement.NETWORK_NO_SOURCE); |
- endTest(); |
- } |
- } |
+ mediaElement.onerror = t.step_func_done(function() { |
+ assert_equals(mediaElement.error.code, MediaError.MEDIA_ERR_SRC_NOT_SUPPORTED); |
+ assert_equals(mediaElement.networkState, HTMLMediaElement.NETWORK_NO_SOURCE); |
+ }); |
+ }); |
+} |
- var audio = document.createElement('audio'); |
- var video = document.createElement('video'); |
- audio.src = invalid_url; |
- video.src = invalid_url; |
- audio.onerror = errorEvent; |
- video.onerror = errorEvent; |
- document.body.appendChild(audio); |
- document.body.appendChild(video); |
- </script> |
- </body> |
-</html> |
+check_invalid_media_src("audio"); |
+check_invalid_media_src("video"); |
+</script> |