OLD | NEW |
| (Empty) |
1 // Copyright 2016 the V8 project authors. All rights reserved. | |
2 // Use of this source code is governed by a BSD-style license that can be | |
3 // found in the LICENSE file. | |
4 | |
5 print("Test that profiling can only be started when Profiler was enabled and tha
t Profiler.disable command will stop recording all profiles."); | |
6 | |
7 InspectorTest.sendCommand("Profiler.start", {}, didFailToStartWhenDisabled); | |
8 disallowConsoleProfiles(); | |
9 | |
10 function disallowConsoleProfiles() | |
11 { | |
12 InspectorTest.eventHandler["Profiler.consoleProfileStarted"] = function(messag
eObject) | |
13 { | |
14 InspectorTest.log("FAIL: console profile started " + JSON.stringify(messageO
bject, null, 4)); | |
15 } | |
16 InspectorTest.eventHandler["Profiler.consoleProfileFinished"] = function(messa
geObject) | |
17 { | |
18 InspectorTest.log("FAIL: unexpected profile received " + JSON.stringify(mess
ageObject, null, 4)); | |
19 } | |
20 } | |
21 function allowConsoleProfiles() | |
22 { | |
23 InspectorTest.eventHandler["Profiler.consoleProfileStarted"] = function(messag
eObject) | |
24 { | |
25 InspectorTest.log("PASS: console initiated profile started"); | |
26 } | |
27 InspectorTest.eventHandler["Profiler.consoleProfileFinished"] = function(messa
geObject) | |
28 { | |
29 InspectorTest.log("PASS: console initiated profile received"); | |
30 } | |
31 } | |
32 function didFailToStartWhenDisabled(messageObject) | |
33 { | |
34 if (!InspectorTest.expectedError("didFailToStartWhenDisabled", messageObject)) | |
35 return; | |
36 allowConsoleProfiles(); | |
37 InspectorTest.sendCommand("Profiler.enable", {}); | |
38 InspectorTest.sendCommand("Profiler.start", {}, didStartFrontendProfile); | |
39 } | |
40 function didStartFrontendProfile(messageObject) | |
41 { | |
42 if (!InspectorTest.expectedSuccess("didStartFrontendProfile", messageObject)) | |
43 return; | |
44 InspectorTest.sendCommand("Runtime.evaluate", {expression: "console.profile('p
1');"}, didStartConsoleProfile); | |
45 } | |
46 | |
47 function didStartConsoleProfile(messageObject) | |
48 { | |
49 if (!InspectorTest.expectedSuccess("didStartConsoleProfile", messageObject)) | |
50 return; | |
51 InspectorTest.sendCommand("Profiler.disable", {}, didDisableProfiler); | |
52 } | |
53 | |
54 function didDisableProfiler(messageObject) | |
55 { | |
56 if (!InspectorTest.expectedSuccess("didDisableProfiler", messageObject)) | |
57 return; | |
58 InspectorTest.sendCommand("Profiler.enable", {}); | |
59 InspectorTest.sendCommand("Profiler.stop", {}, didStopFrontendProfile); | |
60 } | |
61 | |
62 function didStopFrontendProfile(messageObject) | |
63 { | |
64 if (!InspectorTest.expectedError("no front-end initiated profiles found", mess
ageObject)) | |
65 return; | |
66 disallowConsoleProfiles(); | |
67 InspectorTest.sendCommand("Runtime.evaluate", {expression: "console.profileEnd
();"}, didStopConsoleProfile); | |
68 } | |
69 | |
70 function didStopConsoleProfile(messageObject) | |
71 { | |
72 if (!InspectorTest.expectedSuccess("didStopConsoleProfile", messageObject)) | |
73 return; | |
74 InspectorTest.completeTest(); | |
75 } | |
OLD | NEW |