audio-delete-while-slider-thumb-clicked.html 2.95 KB
Newer Older
1
<!DOCTYPE html>
2
3
<html>
    <head>
4
        <script src=media-file.js></script>
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
        <script>
            if (window.layoutTestController) {
                layoutTestController.dumpAsText();
                layoutTestController.waitUntilDone();
            }

            function log(msg)
            {
                var console = document.getElementById('console');
                console.innerHTML = console.innerHTML + msg + "<br>";
            }
            
            function buttonClick()
            {
                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();

                layoutTestController.notifyDone();
            }
            
            function deleteAudio()
            {
35
36
37
38
                var audio = document.getElementById('audio');
                if (!audio)
                    return;

39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
                // delete the search
                log("<br>deleting audio element");
                audio.parentNode.removeChild(audio);

                setTimeout(buttonClick, 10);
            }
            
            function drag()
            {
                if (!window.layoutTestController)
                    return;

                layoutTestController.dumpAsText();
                layoutTestController.waitUntilDone();

                var audio = document.getElementById('audio');

56
57
                var center = audio.offsetLeft + (audio.offsetWidth / 2);
                var middle = audio.offsetTop + (audio.offsetHeight / 2);
58
                
59
60
                var x = center + 16 + 16 + 8;
                var y = middle;
61
62
63
64
65
66
67
68
69
70
71

                // drag slider, leave the mouse down
                log("clicking in controller");
                eventSender.mouseMoveTo(x, y);
                eventSender.mouseDown();
                eventSender.mouseUp();

                log("clicking on thumb");
                eventSender.mouseDown();
                eventSender.mouseMoveTo(x, y + 20);

72
73
                // Remove the element after seeking started
                audio.addEventListener("seeking", deleteAudio);
74
75
            }

76

77
78
79
80
81
            function start()
            {
                setSrcByTagName("audio", findMediaFile("audio", "content/test"));
            }

82
83
        </script>
    </head>
84
    <body onload="start()">
85
86
87
88
        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>
89
        <audio id="audio" oncanplaythrough="drag()" controls></audio><br><br>
90
91
92
        <div id="console"></div>
    </body>
</html>