Index: third_party/WebKit/LayoutTests/media/audio-delete-while-slider-thumb-clicked.html |
diff --git a/third_party/WebKit/LayoutTests/media/audio-delete-while-slider-thumb-clicked.html b/third_party/WebKit/LayoutTests/media/audio-delete-while-slider-thumb-clicked.html |
index 9a343b9b8cfa97a696b44f5713f7e2c85140b257..3f8a1f8d7f9c0abcfde09dfcc09bcc1aed0a04ff 100644 |
--- a/third_party/WebKit/LayoutTests/media/audio-delete-while-slider-thumb-clicked.html |
+++ b/third_party/WebKit/LayoutTests/media/audio-delete-while-slider-thumb-clicked.html |
@@ -1,111 +1,53 @@ |
<!DOCTYPE html> |
-<html> |
- <head> |
- <script src=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=video-test.js></script> |
- <script src=media-controls.js></script> |
- <script> |
- if (window.testRunner) { |
- testRunner.dumpAsText(); |
- testRunner.waitUntilDone(); |
- } |
- |
- function log(msg) |
- { |
- var console = document.getElementById('console'); |
- console.innerHTML = console.innerHTML + msg + "<br>"; |
- } |
- |
- function forceGC() |
- { |
- if (window.GCController) |
- return GCController.collect(); |
- |
- // Force garbage collection |
- for (var ndx = 0; ndx < 99000; ndx++) |
- var str = new String("1234"); |
- } |
- |
- function buttonClick() |
- { |
- forceGC(); |
- |
- if (document.getElementById('audio')) |
- log("<br>FAIL: audio element not deleted!!"); |
- |
- log("<br>clicking button"); |
- |
- // click the button |
- var button = document.getElementById('button'); |
- eventSender.mouseMoveTo(button.offsetLeft + 20, button.offsetTop + 7); |
- eventSender.mouseDown(); |
- eventSender.mouseUp(); |
- |
- testRunner.notifyDone(); |
- } |
- |
- function deleteAudio() |
- { |
- var audio = document.getElementById('audio'); |
- if (!audio) |
- return; |
- |
- log("<br>deleting audio element"); |
- audio.parentNode.removeChild(audio); |
- |
- setTimeout(buttonClick, 10); |
- } |
- |
- function drag() |
- { |
- if (!window.testRunner) |
- return; |
- |
- testRunner.dumpAsText(); |
- testRunner.waitUntilDone(); |
- |
- var audio = document.getElementById('audio'); |
- var seekCoords; |
- try { |
- seekCoords = mediaControlsButtonCoordinates(audio, "timeline"); |
- } catch (exception) { |
- failTest(exception.description); |
- return; |
- } |
- var x = seekCoords[0]; |
- var y = seekCoords[1]; |
- |
- // Click in the slider to get the thumb under the mouse. |
- log("clicking in controller"); |
- eventSender.mouseMoveTo(x, y); |
- eventSender.mouseDown(); |
- eventSender.mouseUp(); |
- |
- // Click slider to scrub, leave the mouse down. |
- log("clicking on thumb"); |
- eventSender.mouseDown(); |
- eventSender.mouseMoveTo(x, y + 20); |
- |
- // Remove the element after seeking started |
- audio.addEventListener("seeking", deleteAudio); |
- } |
- |
- |
- function start() |
- { |
- setSrcByTagName("audio", findMediaFile("audio", "content/test")); |
- } |
- |
- </script> |
- </head> |
- <body onload="start()"> |
- This tests that events don't continue to target a slider thumb if the media element is deleted while scrubbing. |
- <br> |
- <input type="button" id="button" value="Click Me!" onmouseup="log('button click!')"> |
- <br> |
- <audio id="audio" autoplay onplaying="drag()" controls></audio><br><br> |
- <div id="console"></div> |
- </body> |
-</html> |
+<title>This tests that events don't continue to target a slider thumb if the media element is deleted while scrubbing.</title> |
+<script src="media-file.js"></script> |
+<script src="media-controls.js"></script> |
+<script src="../resources/testharness.js"></script> |
+<script src="../resources/testharnessreport.js"></script> |
+<input type="button" value="Click Me!"> |
+<audio autoplay controls></audio> |
+<script> |
+async_test(function(t) { |
+ var audio = document.querySelector("audio"); |
+ audio.src = findMediaFile("audio", "content/test"); |
+ audio.onplaying = t.step_func(function() { |
+ var seekCoords = mediaControlsButtonCoordinates(audio, "timeline"); |
+ var x = seekCoords[0]; |
+ var y = seekCoords[1]; |
+ |
+ // Click in the slider to get the thumb under the mouse. |
+ // clicking in controller. |
+ eventSender.mouseMoveTo(x, y); |
+ eventSender.mouseDown(); |
+ eventSender.mouseUp(); |
+ |
+ // Click slider to scrub, leave the mouse down. |
+ // clicking on thumb. |
+ eventSender.mouseDown(); |
+ eventSender.mouseMoveTo(x, y + 20); |
+ |
+ // Remove the element after seeking started |
+ audio.onseeking = t.step_func(deleteAudio); |
+ }); |
+ |
+ function deleteAudio() { |
+ // deleting audio element. |
+ audio.parentNode.removeChild(audio); |
+ |
+ setTimeout(t.step_func(buttonClick), 10); |
+ } |
+ |
+ function buttonClick() { |
+ gc(); |
+ |
+ assert_equals(document.querySelector("audio"), null); |
+ |
+ // click the button |
+ var button = document.querySelector("input"); |
+ button.onmouseup = t.step_func_done(); |
+ eventSender.mouseMoveTo(button.offsetLeft + 20, button.offsetTop + 7); |
+ eventSender.mouseDown(); |
+ eventSender.mouseUp(); |
+ } |
+}); |
+</script> |