73 lines
2.7 KiB
HTML
73 lines
2.7 KiB
HTML
<!doctype html>
|
|
<html>
|
|
<head>
|
|
<script src="../../http/tests/inspector/resources/protocol-test.js"></script>
|
|
<script>
|
|
function triggerScriptEvaluation() {
|
|
let script = document.createElement("script");
|
|
script.textContent = "console.log('<script> script evaluation')";
|
|
document.body.appendChild(script);
|
|
}
|
|
|
|
function triggerEventDispatchEvaluation() {
|
|
let button = document.createElement("button");
|
|
button.addEventListener("click", () => { console.log("'click' event dispatched"); });
|
|
button.click();
|
|
}
|
|
|
|
function triggerTimerEvaluation() {
|
|
setTimeout(() => {
|
|
console.log("timer fired");
|
|
TestPage.dispatchEventToFrontend("TestPageTimerEvaluated");
|
|
}, 0);
|
|
}
|
|
|
|
function test()
|
|
{
|
|
let suite = ProtocolTest.createAsyncSuite("ScriptProfiler.EventType.Microtask");
|
|
|
|
suite.addTestCase({
|
|
name: "TrackingSession",
|
|
description: "Start a tracking session that includes multiple web script evaluations classified as an Other 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 === "Other", "Event type should be Other.");
|
|
});
|
|
|
|
InspectorProtocol.awaitEvent({event: "ScriptProfiler.trackingComplete"})
|
|
.then((messageObject) => {
|
|
ProtocolTest.log("ScriptProfiler.trackingComplete");
|
|
})
|
|
.then(resolve, reject);
|
|
|
|
ProtocolTest.awaitEvent("TestPageTimerEvaluated")
|
|
.then((event) => {
|
|
InspectorProtocol.sendCommand("ScriptProfiler.stopTracking", {});
|
|
});
|
|
|
|
InspectorProtocol.sendCommand("ScriptProfiler.startTracking", {});
|
|
ProtocolTest.evaluateInPage("triggerScriptEvaluation()");
|
|
ProtocolTest.evaluateInPage("triggerEventDispatchEvaluation()");
|
|
ProtocolTest.evaluateInPage("triggerTimerEvaluation()");
|
|
}
|
|
});
|
|
|
|
// 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.Other type. Web script evaluations are classified as "Other".</p>
|
|
</body>
|
|
</html>
|