OLD | NEW |
1 <html> | 1 <html> |
2 <head> | 2 <head> |
3 <script src="../../http/tests/inspector/inspector-test.js"></script> | 3 <script src="../../http/tests/inspector/inspector-test.js"></script> |
4 <script src="profiler-test.js"></script> | 4 <script src="profiler-test.js"></script> |
5 <script> | 5 <script> |
6 | 6 |
7 function pageFunction() { | 7 function pageFunction() { |
8 console.profile("profile"); | 8 (function () { |
9 console.profileEnd("profile"); | 9 console.profile("profile"); |
| 10 console.profileEnd("profile"); |
| 11 })(); |
10 } | 12 } |
11 | 13 |
12 function test() | 14 function test() |
13 { | 15 { |
| 16 function checkFunction(name, tree) |
| 17 { |
| 18 var node = tree.children[0]; |
| 19 if (!node) |
| 20 InspectorTest.addResult("no node"); |
| 21 while (node) { |
| 22 if (node.functionName === name) { |
| 23 InspectorTest.addResult("found " + name); |
| 24 return; |
| 25 } |
| 26 node = node.traverseNextNode(true, null, true); |
| 27 } |
| 28 InspectorTest.addResult(name + " not found"); |
| 29 } |
| 30 |
14 InspectorTest.runProfilerTestSuite([ | 31 InspectorTest.runProfilerTestSuite([ |
15 function testProfiling(next) | 32 function testProfiling(next) |
16 { | 33 { |
17 function findPageFunctionInProfileView(view) | 34 function findPageFunctionInProfileView(view) |
18 { | 35 { |
19 var tree = view.profileDataGridTree; | 36 var tree = view.profileDataGridTree; |
20 if (!tree) | 37 if (!tree) |
21 InspectorTest.addResult("no tree"); | 38 InspectorTest.addResult("no tree"); |
22 var node = tree.children[0]; | 39 checkFunction("pageFunction", tree); |
23 if (!node) | 40 checkFunction("(anonymous function)", tree); |
24 InspectorTest.addResult("no node"); | |
25 while (node) { | |
26 if (node.functionName.indexOf("pageFunction") !== -1) { | |
27 InspectorTest.addResult("found pageFunction"); | |
28 break; | |
29 } | |
30 node = node.traverseNextNode(true, null, true); | |
31 } | |
32 next(); | 41 next(); |
33 } | 42 } |
34 InspectorTest.showProfileWhenAdded("profile"); | 43 InspectorTest.showProfileWhenAdded("profile"); |
35 InspectorTest.waitUntilProfileViewIsShown("profile", findPageFunctio
nInProfileView); | 44 InspectorTest.waitUntilProfileViewIsShown("profile", findPageFunctio
nInProfileView); |
36 InspectorTest.evaluateInConsole("pageFunction()", function done() {}
); | 45 InspectorTest.evaluateInConsole("pageFunction()", function done() {}
); |
37 } | 46 } |
38 ]); | 47 ]); |
39 } | 48 } |
40 | 49 |
41 </script> | 50 </script> |
42 </head> | 51 </head> |
43 <body onload="runTest()"> | 52 <body onload="runTest()"> |
44 <p> | 53 <p> |
45 Tests that CPU profiling works. | 54 Tests that CPU profiling works. |
46 | 55 |
47 <a href="https://bugs.webkit.org/show_bug.cgi?id=52634">Bug 52634.</a> | 56 <a href="https://bugs.webkit.org/show_bug.cgi?id=52634">Bug 52634.</a> |
48 </p> | 57 </p> |
49 </body> | 58 </body> |
50 </html> | 59 </html> |
OLD | NEW |