OLD | NEW |
(Empty) | |
| 1 (async function(testRunner) { |
| 2 let {page, session, dp} = await testRunner.startBlank( |
| 3 'Test that profiling can only be started when Profiler was enabled and tha
t ' + |
| 4 'Profiler.disable command will stop recording all profiles.'); |
| 5 |
| 6 var allowConsoleProfiles = false; |
| 7 dp.Profiler.onConsoleProfileStarted(messageObject => { |
| 8 if (allowConsoleProfiles) |
| 9 testRunner.log('PASS: console initiated profile started') |
| 10 else |
| 11 testRunner.log('FAIL: console profile started ' + JSON.stringify(messageOb
ject, null, 4)); |
| 12 }); |
| 13 dp.Profiler.onConsoleProfileFinished(messageObject => { |
| 14 if (allowConsoleProfiles) |
| 15 testRunner.log('PASS: console initiated profile received') |
| 16 else |
| 17 testRunner.log('FAIL: unexpected profile received ' + JSON.stringify(messa
geObject, null, 4)); |
| 18 }); |
| 19 |
| 20 var messageObject = await dp.Profiler.start(); |
| 21 if (!testRunner.expectedError('didFailToStartWhenDisabled', messageObject)) |
| 22 return; |
| 23 |
| 24 allowConsoleProfiles = true; |
| 25 dp.Profiler.enable(); |
| 26 messageObject = await dp.Profiler.start(); |
| 27 if (!testRunner.expectedSuccess('didStartFrontendProfile', messageObject)) |
| 28 return; |
| 29 |
| 30 messageObject = await dp.Runtime.evaluate({expression: 'console.profile("p1");
'}); |
| 31 if (!testRunner.expectedSuccess('didStartConsoleProfile', messageObject)) |
| 32 return; |
| 33 |
| 34 messageObject = await dp.Profiler.disable(); |
| 35 if (!testRunner.expectedSuccess('didDisableProfiler', messageObject)) |
| 36 return; |
| 37 |
| 38 dp.Profiler.enable(); |
| 39 messageObject = await dp.Profiler.stop(); |
| 40 if (!testRunner.expectedError('no front-end initiated profiles found', message
Object)) |
| 41 return; |
| 42 allowConsoleProfiles = false; |
| 43 |
| 44 messageObject = await dp.Runtime.evaluate({expression: 'console.profileEnd();'
}); |
| 45 if (!testRunner.expectedSuccess('didStopConsoleProfile', messageObject)) |
| 46 return; |
| 47 testRunner.completeTest(); |
| 48 }) |
OLD | NEW |