blob: 13461c6d959cea9ed61e954bab09c14ddf8f0e49 [file] [log] [blame]
<!doctype html>
<html>
<head>
<script src="../../http/tests/inspector/resources/protocol-test.js"></script>
<script>
function triggerAPIScript() {
testRunner.evaluateScriptInIsolatedWorld(0, "console.log('Log from API Evaluated Script')");
}
function test()
{
let suite = ProtocolTest.createAsyncSuite("ScriptProfiler.EventType.API");
suite.addTestCase({
name: "TrackingSession",
description: "Start a tracking session that includes an API event type.",
test(resolve, reject) {
InspectorProtocol.awaitEvent({event: "ScriptProfiler.trackingStart"}).then((messageObject) => {
ProtocolTest.log("ScriptProfiler.trackingStart");
});
InspectorProtocol.addEventListener("ScriptProfiler.trackingUpdate", (messageObject) => {
ProtocolTest.log("ScriptProfiler.trackingUpdate");
ProtocolTest.expectThat(messageObject.params.event.type === "API", "Event type should be API.");
});
InspectorProtocol.awaitEvent({event: "ScriptProfiler.trackingComplete"}).then((messageObject) => {
ProtocolTest.log("ScriptProfiler.trackingComplete");
resolve();
});
InspectorProtocol.sendCommand("ScriptProfiler.startTracking", {});
ProtocolTest.evaluateInPage("triggerAPIScript();"); // This ultimately uses the JSEvaluateScript API on the Page's context.
InspectorProtocol.sendCommand("ScriptProfiler.stopTracking", {});
}
});
// FIXME: <https://webkit.org/b/155851> Web Inspector: We should separate out attaching the debugger from the Debugger.enable event
// Debugger should not need to be enabled for profiling to work.
InspectorProtocol.sendCommand("Debugger.enable", {});
suite.runTestCasesAndFinish();
}
</script>
</head>
<body onload="runTest()">
<p>Tests for generating a ScriptProfiler.Event with ScriptProfiler.EventType.API type.</p>
</body>
</html>