blob: 83d0bde8284fdcb08ea8bf66099e244bcf5e1951 [file] [log] [blame]
<!DOCTYPE html>
<html>
<head>
<script src="../../http/tests/inspector/resources/inspector-test.js"></script>
<script>
function triggerPause() {
TestPage.addResult("Before debugger");
debugger;
TestPage.addResult("After debugger");
}
function testProcessingUserGesture() {
if (window.internals)
TestPage.addResult(window.internals.isProcessingUserGesture() ? "In User Gesture" : "Not in User Gesture");
}
function test()
{
const expression = `testProcessingUserGesture()`;
const objectGroup = "test";
let suite = InspectorTest.createAsyncSuite("Debugger.evaluateOnCallFrame.emulateUserGesture");
suite.addTestCase({
name: "EvaluateWithoutEmulatingUserGesture",
description: "Evalute with the emulateUserGesture option set to false.",
async test() {
InspectorTest.assert(!WI.debuggerManager.paused, "Should not be paused.");
let pausedPromise = WI.debuggerManager.awaitEvent(WI.DebuggerManager.Event.Paused);
InspectorTest.evaluateInPage("triggerPause()");
await pausedPromise;
InspectorTest.assert(WI.debuggerManager.activeCallFrame, "Should have active call frame.");
DebuggerAgent.evaluateOnCallFrame.invoke({callFrameId: WI.debuggerManager.activeCallFrame.id, expression, objectGroup, emulateUserGesture: false}, (error, resultValue, wasThrown) => {
InspectorTest.assert(!error, "Should not be a protocol error.");
});
await Promise.all([
WI.debuggerManager.awaitEvent(WI.DebuggerManager.Event.Resumed),
WI.debuggerManager.resume(),
]);
}
});
suite.addTestCase({
name: "EvaluateWithEmulatingUserGesture",
description: "Evalute with the emulateUserGesture option set to true.",
async test() {
InspectorTest.assert(!WI.debuggerManager.paused, "Should not be paused.");
let pausedPromise = WI.debuggerManager.awaitEvent(WI.DebuggerManager.Event.Paused);
InspectorTest.evaluateInPage("triggerPause()");
await pausedPromise;
InspectorTest.assert(WI.debuggerManager.activeCallFrame, "Should have active call frame.");
DebuggerAgent.evaluateOnCallFrame.invoke({callFrameId: WI.debuggerManager.activeCallFrame.id, expression, objectGroup, emulateUserGesture: true}, (error, resultValue, wasThrown) => {
InspectorTest.assert(!error, "Should not be a protocol error.");
});
await Promise.all([
WI.debuggerManager.awaitEvent(WI.DebuggerManager.Event.Resumed),
WI.debuggerManager.resume(),
]);
}
});
suite.runTestCasesAndFinish();
}
</script>
</head>
<body onload="runTest()">
<p>Tests for Debugger.evaluateOnCallFrame emulateUserGesture option.</p>
</body>
</html>