summaryrefslogtreecommitdiff
path: root/deps/v8/test/inspector/cpu-profiler/record-cpu-profile.js
blob: c87d600124717de46b33115e68366fd4a2e4b10d (plain)
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
// Copyright 2016 the V8 project authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

InspectorTest.log("Test that profiler is able to record a profile. Also it tests that profiler returns an error when it unable to find the profile.");

Protocol.Profiler.enable();
Protocol.Profiler.start().then(didStartFrontendProfile);
function didStartFrontendProfile(messageObject)
{
  if (!InspectorTest.expectedSuccess("startFrontendProfile", messageObject))
    return;
  Protocol.Runtime.evaluate({expression: "console.profile('Profile 1');"}).then(didStartConsoleProfile);
}

function didStartConsoleProfile(messageObject)
{
  if (!InspectorTest.expectedSuccess("startConsoleProfile", messageObject))
    return;
  Protocol.Runtime.evaluate({expression: "console.profileEnd('Profile 1');"}).then(didStopConsoleProfile);
}

function didStopConsoleProfile(messageObject)
{
  if (!InspectorTest.expectedSuccess("stopConsoleProfile", messageObject))
    return;
  Protocol.Profiler.stop().then(didStopFrontendProfile);
}

function didStopFrontendProfile(messageObject)
{
  if (!InspectorTest.expectedSuccess("stoppedFrontendProfile", messageObject))
    return;
  Protocol.Profiler.start().then(didStartFrontendProfile2);
}

function didStartFrontendProfile2(messageObject)
{
  if (!InspectorTest.expectedSuccess("startFrontendProfileSecondTime", messageObject))
    return;
  Protocol.Profiler.stop().then(didStopFrontendProfile2);
}

function didStopFrontendProfile2(messageObject)
{
  InspectorTest.expectedSuccess("stopFrontendProfileSecondTime", messageObject)
  InspectorTest.completeTest();
}