1 var initialize_ProfilerTest = function() {
3 InspectorTest.startProfilerTest = function(callback)
5 WebInspector.showPanel("profiles");
7 InspectorTest.addResult("Profiler was enabled.");
8 InspectorTest.addSniffer(WebInspector.panels.profiles, "_addProfileHeader", InspectorTest._profileHeaderAdded, true);
9 InspectorTest.addSniffer(WebInspector.CPUProfileView.prototype, "refresh", InspectorTest._profileViewRefresh, true);
10 InspectorTest.safeWrap(callback)();
13 InspectorTest.completeProfilerTest = function()
15 InspectorTest.addResult("");
16 InspectorTest.addResult("Profiler was disabled.");
17 InspectorTest.completeTest();
20 InspectorTest.runProfilerTestSuite = function(testSuite)
22 var testSuiteTests = testSuite.slice();
26 if (!testSuiteTests.length) {
27 InspectorTest.completeProfilerTest();
31 var nextTest = testSuiteTests.shift();
32 InspectorTest.addResult("");
33 InspectorTest.addResult("Running: " + /function\s([^(]*)/.exec(nextTest)[1]);
34 InspectorTest.safeWrap(nextTest)(runner, runner);
37 InspectorTest.startProfilerTest(runner);
40 InspectorTest.showProfileWhenAdded = function(title)
42 InspectorTest._showProfileWhenAdded = title;
45 InspectorTest._profileHeaderAdded = function(profile)
47 if (InspectorTest._showProfileWhenAdded === profile.title)
48 WebInspector.panels.profiles.showProfile(profile);
51 InspectorTest.waitUntilProfileViewIsShown = function(title, callback)
53 callback = InspectorTest.safeWrap(callback);
55 var profilesPanel = WebInspector.panels.profiles;
56 if (profilesPanel.visibleView && profilesPanel.visibleView.profile && profilesPanel.visibleView.profile.title === title)
57 callback(profilesPanel.visibleView);
59 InspectorTest._waitUntilProfileViewIsShownCallback = { title: title, callback: callback };
62 InspectorTest._profileViewRefresh = function()
64 // Called in the context of ProfileView.
65 if (InspectorTest._waitUntilProfileViewIsShownCallback && InspectorTest._waitUntilProfileViewIsShownCallback.title === this.profile.title) {
66 var callback = InspectorTest._waitUntilProfileViewIsShownCallback;
67 delete InspectorTest._waitUntilProfileViewIsShownCallback;
68 callback.callback(this);