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

Unified Diff: third_party/WebKit/LayoutTests/inspector-protocol/cpu-profiler/enable-disable.js

Issue 2942573003: [DevTools] New harness for inspector-protocol layout tests (Closed)
Patch Set: Protocol -> dp Created 3 years, 6 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 side-by-side diff with in-line comments
Download patch
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..3e590260cfd1895e75e4c3d4d4885437c508bbc5
--- /dev/null
+++ b/third_party/WebKit/LayoutTests/inspector-protocol/cpu-profiler/enable-disable.js
@@ -0,0 +1,48 @@
+(async function(testRunner) {
+ let {page, session, dp} = await testRunner.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;
+ dp.Profiler.onConsoleProfileStarted(messageObject => {
+ if (allowConsoleProfiles)
+ testRunner.log('PASS: console initiated profile started')
+ else
+ testRunner.log('FAIL: console profile started ' + JSON.stringify(messageObject, null, 4));
+ });
+ dp.Profiler.onConsoleProfileFinished(messageObject => {
+ if (allowConsoleProfiles)
+ testRunner.log('PASS: console initiated profile received')
+ else
+ testRunner.log('FAIL: unexpected profile received ' + JSON.stringify(messageObject, null, 4));
+ });
+
+ var messageObject = await dp.Profiler.start();
+ if (!testRunner.expectedError('didFailToStartWhenDisabled', messageObject))
+ return;
+
+ allowConsoleProfiles = true;
+ dp.Profiler.enable();
+ messageObject = await dp.Profiler.start();
+ if (!testRunner.expectedSuccess('didStartFrontendProfile', messageObject))
+ return;
+
+ messageObject = await dp.Runtime.evaluate({expression: 'console.profile("p1");'});
+ if (!testRunner.expectedSuccess('didStartConsoleProfile', messageObject))
+ return;
+
+ messageObject = await dp.Profiler.disable();
+ if (!testRunner.expectedSuccess('didDisableProfiler', messageObject))
+ return;
+
+ dp.Profiler.enable();
+ messageObject = await dp.Profiler.stop();
+ if (!testRunner.expectedError('no front-end initiated profiles found', messageObject))
+ return;
+ allowConsoleProfiles = false;
+
+ messageObject = await dp.Runtime.evaluate({expression: 'console.profileEnd();'});
+ if (!testRunner.expectedSuccess('didStopConsoleProfile', messageObject))
+ return;
+ testRunner.completeTest();
+})

Powered by Google App Engine
This is Rietveld 408576698