OLD | NEW |
(Empty) | |
| 1 <html> |
| 2 <head> |
| 3 <script type="text/javascript" src="../../http/tests/inspector-protocol/resource
s/protocol-test.js"></script> |
| 4 <script> |
| 5 if (window.testRunner) { |
| 6 testRunner.dumpAsText(); |
| 7 testRunner.waitUntilDone(); |
| 8 } |
| 9 |
| 10 function test() |
| 11 { |
| 12 InspectorTest.sendCommand("Profiler.start", {}, didFailToStartWhenDisabled); |
| 13 disallowConsoleProfiles(); |
| 14 |
| 15 function disallowConsoleProfiles() |
| 16 { |
| 17 InspectorTest.eventHandler["Profiler.consoleProfile"] = function(message
Object) |
| 18 { |
| 19 InspectorTest.log("FAIL: console profile started " + JSON.stringify(
messageObject, null, 4)); |
| 20 } |
| 21 InspectorTest.eventHandler["Profiler.addProfileHeader"] = function(messa
geObject) |
| 22 { |
| 23 InspectorTest.log("FAIL: unexpected profile received " + JSON.string
ify(messageObject, null, 4)); |
| 24 } |
| 25 } |
| 26 function allowConsoleProfiles() |
| 27 { |
| 28 InspectorTest.eventHandler["Profiler.consoleProfile"] = function(message
Object) |
| 29 { |
| 30 InspectorTest.log("PASS: console initiated profile started"); |
| 31 } |
| 32 InspectorTest.eventHandler["Profiler.addProfileHeader"] = function(messa
geObject) |
| 33 { |
| 34 InspectorTest.log("PASS: console initiated profile received"); |
| 35 } |
| 36 } |
| 37 function didFailToStartWhenDisabled(messageObject) |
| 38 { |
| 39 if (!InspectorTest.expectedError("didFailToStartWhenDisabled", messageOb
ject)) |
| 40 return; |
| 41 allowConsoleProfiles(); |
| 42 InspectorTest.sendCommand("Profiler.enable", {}); |
| 43 InspectorTest.sendCommand("Profiler.start", {}, didStartFrontendProfile)
; |
| 44 } |
| 45 function didStartFrontendProfile(messageObject) |
| 46 { |
| 47 if (!InspectorTest.expectedSuccess("didStartFrontendProfile", messageObj
ect)) |
| 48 return; |
| 49 InspectorTest.sendCommand("Runtime.evaluate", {expression: "console.prof
ile('p1');"}, didStartConsoleProfile); |
| 50 } |
| 51 |
| 52 function didStartConsoleProfile(messageObject) |
| 53 { |
| 54 if (!InspectorTest.expectedSuccess("didStartConsoleProfile", messageObje
ct)) |
| 55 return; |
| 56 InspectorTest.sendCommand("Profiler.disable", {}, didDisableProfiler); |
| 57 } |
| 58 |
| 59 function didDisableProfiler(messageObject) |
| 60 { |
| 61 if (!InspectorTest.expectedSuccess("didDisableProfiler", messageObject)) |
| 62 return; |
| 63 InspectorTest.sendCommand("Profiler.enable", {}); |
| 64 InspectorTest.sendCommand("Profiler.stop", {}, didStopFrontendProfile); |
| 65 } |
| 66 |
| 67 function didStopFrontendProfile(messageObject) |
| 68 { |
| 69 if (!InspectorTest.expectedError("no front-end initiated profiles found"
, messageObject)) |
| 70 return; |
| 71 disallowConsoleProfiles(); |
| 72 InspectorTest.sendCommand("Runtime.evaluate", {expression: "console.prof
ileEnd();"}, didStopConsoleProfile); |
| 73 } |
| 74 |
| 75 function didStopConsoleProfile(messageObject) |
| 76 { |
| 77 if (!InspectorTest.expectedSuccess("didStopConsoleProfile", messageObjec
t)) |
| 78 return; |
| 79 InspectorTest.completeTest(); |
| 80 } |
| 81 } |
| 82 </script> |
| 83 </head> |
| 84 <body onload="runTest()"> |
| 85 <p> |
| 86 Test that profiling can only be started when Profiler was enabled and that |
| 87 Profiler.disable command will stop recording all profiles. |
| 88 </body> |
| 89 </html> |
OLD | NEW |