| Index: third_party/WebKit/LayoutTests/inspector-protocol/cpu-profiler/enable-disable.js
|
| diff --git a/third_party/WebKit/LayoutTests/inspector-protocol/cpu-profiler/enable-disable.js b/third_party/WebKit/LayoutTests/inspector-protocol/cpu-profiler/enable-disable.js
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..da47798853e29c875a354e55d42da94e1af32bc4
|
| --- /dev/null
|
| +++ b/third_party/WebKit/LayoutTests/inspector-protocol/cpu-profiler/enable-disable.js
|
| @@ -0,0 +1,48 @@
|
| +(async function() {
|
| + let {page, session, Protocol} = await InspectorTest.startBlank(
|
| + 'Test that profiling can only be started when Profiler was enabled and that ' +
|
| + 'Profiler.disable command will stop recording all profiles.');
|
| +
|
| + var allowConsoleProfiles = false;
|
| + Protocol.Profiler.onConsoleProfileStarted(messageObject => {
|
| + if (allowConsoleProfiles)
|
| + InspectorTest.log('PASS: console initiated profile started')
|
| + else
|
| + InspectorTest.log('FAIL: console profile started ' + JSON.stringify(messageObject, null, 4));
|
| + });
|
| + Protocol.Profiler.onConsoleProfileFinished(messageObject => {
|
| + if (allowConsoleProfiles)
|
| + InspectorTest.log('PASS: console initiated profile received')
|
| + else
|
| + InspectorTest.log('FAIL: unexpected profile received ' + JSON.stringify(messageObject, null, 4));
|
| + });
|
| +
|
| + var messageObject = await Protocol.Profiler.start();
|
| + if (!InspectorTest.expectedError('didFailToStartWhenDisabled', messageObject))
|
| + return;
|
| +
|
| + allowConsoleProfiles = true;
|
| + Protocol.Profiler.enable();
|
| + messageObject = await Protocol.Profiler.start();
|
| + if (!InspectorTest.expectedSuccess('didStartFrontendProfile', messageObject))
|
| + return;
|
| +
|
| + messageObject = await Protocol.Runtime.evaluate({expression: 'console.profile("p1");'});
|
| + if (!InspectorTest.expectedSuccess('didStartConsoleProfile', messageObject))
|
| + return;
|
| +
|
| + messageObject = await Protocol.Profiler.disable();
|
| + if (!InspectorTest.expectedSuccess('didDisableProfiler', messageObject))
|
| + return;
|
| +
|
| + Protocol.Profiler.enable();
|
| + messageObject = await Protocol.Profiler.stop();
|
| + if (!InspectorTest.expectedError('no front-end initiated profiles found', messageObject))
|
| + return;
|
| + allowConsoleProfiles = false;
|
| +
|
| + messageObject = await Protocol.Runtime.evaluate({expression: 'console.profileEnd();'});
|
| + if (!InspectorTest.expectedSuccess('didStopConsoleProfile', messageObject))
|
| + return;
|
| + InspectorTest.completeTest();
|
| +})();
|
|
|