Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(71)

Side by Side Diff: test/inspector/cpu-profiler/enable-disable.js

Issue 2369753004: [inspector] added inspector test runner [part 5] (Closed)
Patch Set: addressed comments Created 4 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(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 }
OLDNEW
« no previous file with comments | « test/inspector/cpu-profiler/console-profile-expected.txt ('k') | test/inspector/cpu-profiler/enable-disable-expected.txt » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698