2016-10-02 21:22:49 +00:00
|
|
|
// 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.
|
|
|
|
|
2017-02-28 20:22:24 +00:00
|
|
|
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.");
|
2016-10-02 21:22:49 +00:00
|
|
|
|
2016-10-03 23:32:52 +00:00
|
|
|
Protocol.Profiler.enable();
|
|
|
|
Protocol.Profiler.start().then(didStartFrontendProfile);
|
2016-10-02 21:22:49 +00:00
|
|
|
function didStartFrontendProfile(messageObject)
|
|
|
|
{
|
|
|
|
if (!InspectorTest.expectedSuccess("startFrontendProfile", messageObject))
|
|
|
|
return;
|
2016-10-03 23:32:52 +00:00
|
|
|
Protocol.Runtime.evaluate({expression: "console.profile('Profile 1');"}).then(didStartConsoleProfile);
|
2016-10-02 21:22:49 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
function didStartConsoleProfile(messageObject)
|
|
|
|
{
|
|
|
|
if (!InspectorTest.expectedSuccess("startConsoleProfile", messageObject))
|
|
|
|
return;
|
2016-10-03 23:32:52 +00:00
|
|
|
Protocol.Runtime.evaluate({expression: "console.profileEnd('Profile 1');"}).then(didStopConsoleProfile);
|
2016-10-02 21:22:49 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
function didStopConsoleProfile(messageObject)
|
|
|
|
{
|
|
|
|
if (!InspectorTest.expectedSuccess("stopConsoleProfile", messageObject))
|
|
|
|
return;
|
2016-10-03 23:32:52 +00:00
|
|
|
Protocol.Profiler.stop().then(didStopFrontendProfile);
|
2016-10-02 21:22:49 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
function didStopFrontendProfile(messageObject)
|
|
|
|
{
|
|
|
|
if (!InspectorTest.expectedSuccess("stoppedFrontendProfile", messageObject))
|
|
|
|
return;
|
2016-10-03 23:32:52 +00:00
|
|
|
Protocol.Profiler.start().then(didStartFrontendProfile2);
|
2016-10-02 21:22:49 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
function didStartFrontendProfile2(messageObject)
|
|
|
|
{
|
|
|
|
if (!InspectorTest.expectedSuccess("startFrontendProfileSecondTime", messageObject))
|
|
|
|
return;
|
2016-10-03 23:32:52 +00:00
|
|
|
Protocol.Profiler.stop().then(didStopFrontendProfile2);
|
2016-10-02 21:22:49 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
function didStopFrontendProfile2(messageObject)
|
|
|
|
{
|
|
|
|
InspectorTest.expectedSuccess("stopFrontendProfileSecondTime", messageObject)
|
|
|
|
InspectorTest.completeTest();
|
|
|
|
}
|