blob: ffd8eeaf7557fc683119dc82c08e34e569752332 [file] [log] [blame]
<html>
<head>
<script src="../../http/tests/inspector/inspector-test.js"></script>
<script src="../../http/tests/inspector/debugger-test.js"></script>
<script>
function testFunction()
{
var div = document.getElementById("myDiv");
function fooEventHandler1() {
div.textContent += "Recieved foo event(1)!\n";
}
div.addEventListener("foo", fooEventHandler1);
function fooEventHandler2() {
div.textContent += "Recieved foo event(2)!\n";
}
div.addEventListener("foo", fooEventHandler2);
var e = new CustomEvent('foo');
debugger;
div.dispatchEvent(e);
}
var test = function()
{
InspectorTest.startDebuggerTest(step1, true);
function step1()
{
InspectorTest.runTestFunctionAndWaitUntilPaused(step2);
}
function checkTopFrameFunction(callFrames, expectedName)
{
var topFunctionName = callFrames[0].functionName;
if (expectedName === topFunctionName)
InspectorTest.addResult("SUCCESS: Did step into event listener(" + expectedName + ").");
else
InspectorTest.addResult("FAIL: Unexpected top function: expected " + expectedName + ", found " + topFunctionName);
}
var stepCount = 0;
function step2(callFrames)
{
if (stepCount === 2)
checkTopFrameFunction(callFrames, "fooEventHandler1");
else if (stepCount === 5)
checkTopFrameFunction(callFrames, "fooEventHandler2");
if (stepCount < 5) {
InspectorTest.addResult("Stepping into...");
document.getElementById("scripts-step-into").click();
InspectorTest.waitUntilResumed(InspectorTest.waitUntilPaused.bind(InspectorTest, step2));
} else
InspectorTest.completeDebuggerTest();
stepCount++;
}
}
</script>
</head>
<body onload="runTest()">
<p>
Tests that stepping into dispatchEvent() method will lead to a pause in the first event listener.
</p>
<div id="myDiv"></div>
</body>
</html>