Chromium Code Reviews| Index: LayoutTests/inspector-protocol/cpu-profiler/enable-disable.html |
| diff --git a/LayoutTests/inspector-protocol/cpu-profiler/enable-disable.html b/LayoutTests/inspector-protocol/cpu-profiler/enable-disable.html |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..6314cf5a249598fc0b3146d8129b48b311e4397c |
| --- /dev/null |
| +++ b/LayoutTests/inspector-protocol/cpu-profiler/enable-disable.html |
| @@ -0,0 +1,89 @@ |
| +<html> |
| +<head> |
| +<script type="text/javascript" src="../../http/tests/inspector-protocol/resources/protocol-test.js"></script> |
| +<script> |
| +if (window.testRunner) { |
| + testRunner.dumpAsText(); |
| + testRunner.waitUntilDone(); |
| +} |
| + |
| +function test() |
| +{ |
| + InspectorTest.sendCommand("Profiler.start", {}, didFailToStartWhenDisabled); |
| + consoleProfilesDisallowed(); |
| + |
| + function consoleProfilesDisallowed() |
| + { |
| + InspectorTest.eventHandler["Profiler.consoleProfile"] = function(messageObject) |
| + { |
| + InspectorTest.log("FAIL: console profile started " + JSON.stringify(messageObject, null, 4)); |
| + } |
| + InspectorTest.eventHandler["Profiler.addProfileHeader"] = function(messageObject) |
| + { |
| + InspectorTest.log("FAIL: unexpected profile received " + JSON.stringify(messageObject, null, 4)); |
| + } |
| + } |
| + function consoleProfilesAllowed() |
| + { |
| + InspectorTest.eventHandler["Profiler.consoleProfile"] = function(messageObject) |
| + { |
| + InspectorTest.log("PASS: console initiated profile started"); |
| + } |
| + InspectorTest.eventHandler["Profiler.addProfileHeader"] = function(messageObject) |
| + { |
| + InspectorTest.log("PASS: console initiated profile received"); |
| + } |
| + } |
| + function didFailToStartWhenDisabled(messageObject) |
| + { |
| + if (!InspectorTest.expectedError("didFailToStartWhenDisabled", messageObject)) |
| + return; |
| + consoleProfilesAllowed(); |
| + InspectorTest.sendCommand("Profiler.enable", {}); |
| + InspectorTest.sendCommand("Profiler.start", {}, didStartFrontendProfile); |
| + } |
| + function didStartFrontendProfile(messageObject) |
| + { |
| + if (!InspectorTest.expectedSuccess("didStartFrontendProfile", messageObject)) |
| + return; |
| + InspectorTest.sendCommand("Runtime.evaluate", {expression: "console.profile('p1');"}, didStartConsoleProfile); |
| + } |
| + |
| + function didStartConsoleProfile(messageObject) |
| + { |
| + if (!InspectorTest.expectedSuccess("didStartConsoleProfile", messageObject)) |
| + return; |
| + InspectorTest.sendCommand("Profiler.disable", {}, didDisableProfiler); |
| + } |
| + |
| + function didDisableProfiler(messageObject) |
| + { |
| + if (!InspectorTest.expectedSuccess("didDisableProfiler", messageObject)) |
| + return; |
| + InspectorTest.sendCommand("Profiler.enable", {}); |
| + InspectorTest.sendCommand("Profiler.stop", {}, didStopFrontendProfile); |
| + } |
| + |
| + function didStopFrontendProfile(messageObject) |
| + { |
| + if (!InspectorTest.expectedError("no front-end initiated profiles found", messageObject)) |
| + return; |
| + consoleProfilesDisallowed(); |
| + InspectorTest.sendCommand("Runtime.evaluate", {expression: "console.profileEnd();"}, didStopConsoleProfile); |
| + } |
| + |
| + function didStopConsoleProfile(messageObject) |
| + { |
| + if (!InspectorTest.expectedSuccess("didStopConsoleProfile", messageObject)) |
| + return; |
| + InspectorTest.completeTest(); |
| + } |
| +} |
| +</script> |
| +</head> |
| +<body onload="runTest()"> |
| +<p> |
| +Test that profiling can only be started when Profiler was enabled and that |
| +Profiler.disable command will stop stop recording all profiles. |
|
aandrey
2013/12/16 13:05:28
stop stop
yurys
2013/12/16 14:35:08
Will fix in next change.
yurys
2013/12/16 14:48:27
Done.
|
| +</body> |
| +</html> |