OLD | NEW |
1 <!DOCTYPE html> | 1 <!DOCTYPE html> |
2 <html> | 2 <title>This tests that events don't continue to target a slider thumb if the med
ia element is deleted while scrubbing.</title> |
3 <head> | 3 <script src="media-file.js"></script> |
4 <script src=media-file.js></script> | 4 <script src="media-controls.js"></script> |
5 <!-- TODO(foolip): Convert test to testharness.js. crbug.com/588956 | 5 <script src="../resources/testharness.js"></script> |
6 (Please avoid writing new tests using video-test.js) --> | 6 <script src="../resources/testharnessreport.js"></script> |
7 <script src=video-test.js></script> | 7 <input type="button" value="Click Me!"> |
8 <script src=media-controls.js></script> | 8 <audio autoplay controls></audio> |
9 <script> | 9 <script> |
10 if (window.testRunner) { | 10 async_test(function(t) { |
11 testRunner.dumpAsText(); | 11 var audio = document.querySelector("audio"); |
12 testRunner.waitUntilDone(); | 12 audio.src = findMediaFile("audio", "content/test"); |
13 } | 13 audio.onplaying = t.step_func(function() { |
| 14 var seekCoords = mediaControlsButtonCoordinates(audio, "timeline"); |
| 15 var x = seekCoords[0]; |
| 16 var y = seekCoords[1]; |
14 | 17 |
15 function log(msg) | 18 // Click in the slider to get the thumb under the mouse. |
16 { | 19 // clicking in controller. |
17 var console = document.getElementById('console'); | 20 eventSender.mouseMoveTo(x, y); |
18 console.innerHTML = console.innerHTML + msg + "<br>"; | 21 eventSender.mouseDown(); |
19 } | 22 eventSender.mouseUp(); |
20 | 23 |
21 function forceGC() | 24 // Click slider to scrub, leave the mouse down. |
22 { | 25 // clicking on thumb. |
23 if (window.GCController) | 26 eventSender.mouseDown(); |
24 return GCController.collect(); | 27 eventSender.mouseMoveTo(x, y + 20); |
25 | 28 |
26 // Force garbage collection | 29 // Remove the element after seeking started |
27 for (var ndx = 0; ndx < 99000; ndx++) | 30 audio.onseeking = t.step_func(deleteAudio); |
28 var str = new String("1234"); | 31 }); |
29 } | |
30 | 32 |
31 function buttonClick() | 33 function deleteAudio() { |
32 { | 34 // deleting audio element. |
33 forceGC(); | 35 audio.parentNode.removeChild(audio); |
34 | 36 |
35 if (document.getElementById('audio')) | 37 setTimeout(t.step_func(buttonClick), 10); |
36 log("<br>FAIL: audio element not deleted!!"); | 38 } |
37 | 39 |
38 log("<br>clicking button"); | 40 function buttonClick() { |
| 41 gc(); |
39 | 42 |
40 // click the button | 43 assert_equals(document.querySelector("audio"), null); |
41 var button = document.getElementById('button'); | |
42 eventSender.mouseMoveTo(button.offsetLeft + 20, button.offsetTop
+ 7); | |
43 eventSender.mouseDown(); | |
44 eventSender.mouseUp(); | |
45 | 44 |
46 testRunner.notifyDone(); | 45 // click the button |
47 } | 46 var button = document.querySelector("input"); |
48 | 47 button.onmouseup = t.step_func_done(); |
49 function deleteAudio() | 48 eventSender.mouseMoveTo(button.offsetLeft + 20, button.offsetTop + 7); |
50 { | 49 eventSender.mouseDown(); |
51 var audio = document.getElementById('audio'); | 50 eventSender.mouseUp(); |
52 if (!audio) | 51 } |
53 return; | 52 }); |
54 | 53 </script> |
55 log("<br>deleting audio element"); | |
56 audio.parentNode.removeChild(audio); | |
57 | |
58 setTimeout(buttonClick, 10); | |
59 } | |
60 | |
61 function drag() | |
62 { | |
63 if (!window.testRunner) | |
64 return; | |
65 | |
66 testRunner.dumpAsText(); | |
67 testRunner.waitUntilDone(); | |
68 | |
69 var audio = document.getElementById('audio'); | |
70 var seekCoords; | |
71 try { | |
72 seekCoords = mediaControlsButtonCoordinates(audio, "timeline
"); | |
73 } catch (exception) { | |
74 failTest(exception.description); | |
75 return; | |
76 } | |
77 var x = seekCoords[0]; | |
78 var y = seekCoords[1]; | |
79 | |
80 // Click in the slider to get the thumb under the mouse. | |
81 log("clicking in controller"); | |
82 eventSender.mouseMoveTo(x, y); | |
83 eventSender.mouseDown(); | |
84 eventSender.mouseUp(); | |
85 | |
86 // Click slider to scrub, leave the mouse down. | |
87 log("clicking on thumb"); | |
88 eventSender.mouseDown(); | |
89 eventSender.mouseMoveTo(x, y + 20); | |
90 | |
91 // Remove the element after seeking started | |
92 audio.addEventListener("seeking", deleteAudio); | |
93 } | |
94 | |
95 | |
96 function start() | |
97 { | |
98 setSrcByTagName("audio", findMediaFile("audio", "content/test"))
; | |
99 } | |
100 | |
101 </script> | |
102 </head> | |
103 <body onload="start()"> | |
104 This tests that events don't continue to target a slider thumb if the me
dia element is deleted while scrubbing. | |
105 <br> | |
106 <input type="button" id="button" value="Click Me!" onmouseup="log('butto
n click!')"> | |
107 <br> | |
108 <audio id="audio" autoplay onplaying="drag()" controls></audio><br><br> | |
109 <div id="console"></div> | |
110 </body> | |
111 </html> | |
OLD | NEW |