summaryrefslogtreecommitdiffstats
path: root/third_party/WebKit/LayoutTests/fast/loader/navigation-scheduler-user-gesture.html
blob: c709df4b0d8269a43f03e28887fc18587b3225c3 (plain)
1
2
3
4
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
35
36
37
38
39
40
41
42
43
<!DOCTYPE html>
<html>
<body>
<p>
    Check that the NavigationScheduler correctly tracks user gestures.
</p>
<div id='log'></div>
<a href='about:blank' target='_blank'></a>
<button>click me</button>
<script>
    if (window.testRunner) {
        testRunner.dumpAsText();
        testRunner.waitUntilDone();
        testRunner.setCanOpenWindows();
        testRunner.setPopupBlockingEnabled(true);
    }

    function popup() {
        // Previously, this made the NavigationController create an additional
        // user gesture.
        window.open('javascript:', '_self', '');
        // Consume one gesture.
        window.open('about:blank').close();
        var w = window.open('about:blank');
        if (w == undefined)
            document.querySelector('#log').innerText = 'PASS: only one window opened';
        else
            document.querySelector('#log').innerText = 'FAIL: could open two windows';
        if (window.testRunner)
            testRunner.notifyDone();
    }

    var button = document.querySelector('button');
    button.onclick = popup;

    if (window.testRunner) {
        eventSender.mouseMoveTo(button.offsetLeft + 2, button.offsetTop + 2);
        eventSender.mouseDown();
        eventSender.mouseUp();
    }
</script>
</body>
</html>