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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
|
<html>
<head>
<script type="text/javascript" src="../../http/tests/inspector-protocol/resources/protocol-test.js"></script>
<script>
if (window.testRunner) {
testRunner.dumpAsText();
testRunner.waitUntilDone();
}
function test()
{
InspectorTest.sendCommand("Profiler.start", {}, didFailToStartWhenDisabled);
disallowConsoleProfiles();
function disallowConsoleProfiles()
{
InspectorTest.eventHandler["Profiler.consoleProfileStarted"] = function(messageObject)
{
InspectorTest.log("FAIL: console profile started " + JSON.stringify(messageObject, null, 4));
}
InspectorTest.eventHandler["Profiler.consoleProfileFinished"] = function(messageObject)
{
InspectorTest.log("FAIL: unexpected profile received " + JSON.stringify(messageObject, null, 4));
}
}
function allowConsoleProfiles()
{
InspectorTest.eventHandler["Profiler.consoleProfileStarted"] = function(messageObject)
{
InspectorTest.log("PASS: console initiated profile started");
}
InspectorTest.eventHandler["Profiler.consoleProfileFinished"] = function(messageObject)
{
InspectorTest.log("PASS: console initiated profile received");
}
}
function didFailToStartWhenDisabled(messageObject)
{
if (!InspectorTest.expectedError("didFailToStartWhenDisabled", messageObject))
return;
allowConsoleProfiles();
InspectorTest.sendCommand("Profiler.enable", {});
InspectorTest.sendCommand("Profiler.start", {}, didStartFrontendProfile);
}
function didStartFrontendProfile(messageObject)
{
if (!InspectorTest.expectedSuccess("didStartFrontendProfile", messageObject))
return;
InspectorTest.sendCommand("Runtime.evaluate", {expression: "console.profile('p1');"}, didStartConsoleProfile);
}
function didStartConsoleProfile(messageObject)
{
if (!InspectorTest.expectedSuccess("didStartConsoleProfile", messageObject))
return;
InspectorTest.sendCommand("Profiler.disable", {}, didDisableProfiler);
}
function didDisableProfiler(messageObject)
{
if (!InspectorTest.expectedSuccess("didDisableProfiler", messageObject))
return;
InspectorTest.sendCommand("Profiler.enable", {});
InspectorTest.sendCommand("Profiler.stop", {}, didStopFrontendProfile);
}
function didStopFrontendProfile(messageObject)
{
if (!InspectorTest.expectedError("no front-end initiated profiles found", messageObject))
return;
disallowConsoleProfiles();
InspectorTest.sendCommand("Runtime.evaluate", {expression: "console.profileEnd();"}, didStopConsoleProfile);
}
function didStopConsoleProfile(messageObject)
{
if (!InspectorTest.expectedSuccess("didStopConsoleProfile", messageObject))
return;
InspectorTest.completeTest();
}
}
</script>
</head>
<body onload="runTest()">
<p>
Test that profiling can only be started when Profiler was enabled and that
Profiler.disable command will stop recording all profiles.
</body>
</html>
|