[Modern Media Controls] Turn media/modern-media-controls/ios-inline-media-controls...
[WebKit-https.git] / LayoutTests / media / audio-delete-while-step-button-clicked.html
1 <!DOCTYPE html>
2 <html>
3     <head>
4         <script src=media-file.js></script>
5         <script src=video-test.js></script>
6         <script src=media-controls.js></script>
7
8         <script>
9             if (window.testRunner) {
10                 testRunner.dumpAsText();
11                 testRunner.waitUntilDone();
12             }
13
14             function log(msg)
15             {
16                 var console = document.getElementById('console');
17                 console.innerHTML = console.innerHTML + msg + "<br>";
18             }
19             
20             function buttonClick()
21             {
22                 if (document.getElementById('audio'))
23                     log("<br>FAIL: audio element not deleted!!");
24
25                 log("<br>clicking button");
26
27                 // click the button
28                 var button = document.getElementById('button');
29                 eventSender.mouseMoveTo(button.offsetLeft + 20, button.offsetTop + 7);
30                 eventSender.mouseDown();
31                 eventSender.mouseUp();
32
33                 testRunner.notifyDone();
34             }
35             
36             function deleteAudio()
37             {
38                 // delete the search
39                 log("<br>deleting audio element");
40                 var audio = document.getElementById('audio');
41                 audio.parentNode.removeChild(audio);
42
43                 setTimeout(buttonClick, 10);
44             }
45             
46             function step()
47             {
48                 if (!window.testRunner)
49                     return;
50
51                 testRunner.dumpAsText();
52                 testRunner.waitUntilDone();
53
54                 var audio = document.getElementById('audio');
55
56                 var seekCoords;
57                 try {
58                     seekCoords = mediaControlsButtonCoordinates(audio, "seek-forward-button");
59                 } catch (exception) {
60                     failTest(exception.description);
61                     return;
62                 }
63                 var x = seekCoords[0];
64                 var y = seekCoords[1];
65
66                 // step forward, should generate a timeupdate event
67                 log("clicking step forward");
68                 eventSender.mouseMoveTo(x, y);
69                 eventSender.mouseDown();
70                 eventSender.mouseUp();
71
72                 // click step forward button but don't release
73                 log("clicking step forward");
74                 eventSender.mouseDown();
75
76                 setTimeout(deleteAudio, 10);
77             }
78
79             function start()
80             {
81                 setSrcByTagName("audio", findMediaFile("audio", "content/test"));
82             }
83
84         </script>
85     </head>
86     <body onload="start()">
87         This tests that events don't continue to target a step button if the media element is deleted while mouse down on button.
88         <br>
89         <input type="button" id="button" value="Click Me!" onmouseup="log('button click!')"> 
90         <br>
91         <audio id="audio" ontimeupdate="log('timeupdate')" oncanplaythrough="step()" controls></audio><br><br>
92         <div id="console"></div>
93     </body>
94 </html>