summaryrefslogtreecommitdiffstats
path: root/third_party/WebKit/LayoutTests/inspector-protocol/page/javascriptDialogEvents.html
blob: 6af69b3ba5d32bdf59815e34e8e91df4ef6f56aa (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
44
45
46
47
48
49
50
51
52
<html>
<head>
<script type="text/javascript" src="../../http/tests/inspector-protocol/resources/protocol-test.js"></script>
<script>

window.addEventListener("beforeunload", onBeforeUnload);

function onBeforeUnload()
{
    window.removeEventListener("beforeunload", onBeforeUnload);
    return "beforeunload in javascriptDialogEvents";
}

function test()
{
    InspectorTest.eventHandler["Page.javascriptDialogOpening"] = onOpening;
    InspectorTest.eventHandler["Page.javascriptDialogClosed"] = onClosed;
    InspectorTest.sendCommand("Page.enable", {});

    function onOpening(event)
    {
        InspectorTest.log("Opening with message: " + event.params.message);
    }
    function onClosed()
    {
        InspectorTest.log("Closed");
    }

    InspectorTest.sendCommand("Page.navigate", { "url": "nosuchurl" });
    InspectorTest.sendCommand("Runtime.evaluate", { "expression": "alert('alert')" }, onDoneAlert);

    function onDoneAlert()
    {
        InspectorTest.sendCommand("Runtime.evaluate", { "expression": "confirm('confirm')" }, onDoneConfirm);
    }

    function onDoneConfirm()
    {
        InspectorTest.sendCommand("Runtime.evaluate", { "expression": "prompt('prompt')" }, onDone);
    }

    function onDone()
    {
        InspectorTest.completeTest();
    }
}

</script>
</head>
<body onload="runTest()">
</body>
</html>