Changeset 76111 in webkit


Ignore:
Timestamp:
Jan 19, 2011 4:23:42 AM (13 years ago)
Author:
mnaganov@chromium.org
Message:

works in safari

Location:
trunk/LayoutTests/inspector
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/inspector/cpu-profiler-profiling-expected.txt

    r76110 r76111  
    11Tests that CPU profiling works.
    22
    3 found fib
     3found pageFunction
    44
  • trunk/LayoutTests/inspector/cpu-profiler-profiling.html

    r76110 r76111  
    44<script>
    55
    6 function fib(n) {
    7     return n < 2 ? 1 : fib(n - 1) + fib(n - 2);
    8 }
    9 
    10 function eternal_fib() {
     6function pageFunction() {
    117    console.profile();  // Make sure we capture the current callstack.
    12     for (var i = 0; i < 50; ++i) {
    13         fib(20);
    14     }
    158    console.profileEnd();
    16 }
    17 
    18 function run()
    19 {
    20     eternal_fib();
    21     runTest();
    229}
    2310
    2411function initialize_ProfilerTests()
    2512{
    26     InspectorTest.findDisplayedNode = function() {
    27         var panel = WebInspector.panels.profiles;
    28         var tree = panel.visibleView.profileDataGridTree;
    29         if (!tree) {
    30             window.setTimeout(InspectorTest.findDisplayedNode, 100);
    31             return;
    32         }
     13    InspectorTest.findPageFunctionProfileNode = function() {
     14        var panel = WebInspector.panels.profiles;
     15        if (!panel)
     16             InspectorTest.addResult("no panel");
     17        var view = panel.visibleView;
     18        if (!view)
     19             InspectorTest.addResult("no view");
     20        var tree = view.profileDataGridTree;
     21        if (!tree)
     22             InspectorTest.addResult("no tree");
    3323        var node = tree.children[0];
    34         if (!node) {
    35             // Profile hadn't been queried yet, re-schedule.
    36             window.setTimeout(InspectorTest.findDisplayedNode, 100);
    37             return;
    38         }
    39 
    40         // Iterate over displayed functions and search for a function
    41         // that is called "fib" or "eternal_fib". If found, this will mean
    42         // that we actually have profiled page's code.
     24        if (!node)
     25             InspectorTest.addResult("no node");
    4326        while (node) {
    44             if (node.functionName.indexOf("fib") !== -1) {
    45                 InspectorTest.addResult("found fib");
     27            if (node.functionName.indexOf("pageFunction") !== -1) {
     28                InspectorTest.addResult("found pageFunction");
    4629                break;
    4730            }
    4831            node = node.traverseNextNode(true, null, true);
    4932        }
    50 
    5133        InspectorTest.completeTest();
    5234    }
    5335
    54     InspectorTest.findVisibleView = function() {
    55         var panel = WebInspector.panels.profiles;
    56         if (!panel.visibleView) {
    57             setTimeout(InspectorTest.findVisibleView, 0);
    58             return;
    59         }
    60         setTimeout(InspectorTest.findDisplayedNode, 0);
     36    var oldRefresh = WebInspector.CPUProfileView.prototype.refresh;
     37    WebInspector.CPUProfileView.prototype.refresh = function()
     38    {
     39        oldRefresh.call(this);
     40        InspectorTest.findPageFunctionProfileNode();       
    6141    }
    6242}
     
    6545{
    6646    WebInspector.showPanel("profiles");
    67     InspectorTest.findVisibleView();
     47    WebInspector.panels.profiles._enableProfiling();
     48    InspectorBackend.startProfiling();
     49    InspectorTest.evaluateInConsole("pageFunction()", function done()
     50    {
     51        InspectorBackend.stopProfiling();
     52    });
    6853}
    6954
    7055</script>
    7156</head>
    72 <body onload="run()">
     57<body onload="runTest()">
    7358<p>
    7459Tests that CPU profiling works.
Note: See TracChangeset for help on using the changeset viewer.