1 var initialize_ProfilerTest = function() {
3 InspectorTest.startProfilerTest = function(callback)
5 Runtime.experiments.enableForTest("disableAgentsWhenProfile");
6 WebInspector.inspectorView.showPanel("profiles");
8 InspectorTest.addResult("Profiler was enabled.");
9 InspectorTest.addSniffer(WebInspector.panels.profiles, "_addProfileHeader", InspectorTest._profileHeaderAdded, true);
10 InspectorTest.addSniffer(WebInspector.CPUProfileView.prototype, "refresh", InspectorTest._profileViewRefresh, true);
11 InspectorTest.safeWrap(callback)();
14 InspectorTest.completeProfilerTest = function()
16 InspectorTest.addResult("");
17 InspectorTest.addResult("Profiler was disabled.");
18 InspectorTest.completeTest();
21 InspectorTest.runProfilerTestSuite = function(testSuite)
23 var testSuiteTests = testSuite.slice();
27 if (!testSuiteTests.length) {
28 InspectorTest.completeProfilerTest();
32 var nextTest = testSuiteTests.shift();
33 InspectorTest.addResult("");
34 InspectorTest.addResult("Running: " + /function\s([^(]*)/.exec(nextTest)[1]);
35 InspectorTest.safeWrap(nextTest)(runner, runner);
38 InspectorTest.startProfilerTest(runner);
41 InspectorTest.showProfileWhenAdded = function(title)
43 InspectorTest._showProfileWhenAdded = title;
46 InspectorTest._profileHeaderAdded = function(profile)
48 if (InspectorTest._showProfileWhenAdded === profile.title)
49 WebInspector.panels.profiles.showProfile(profile);
52 InspectorTest.waitUntilProfileViewIsShown = function(title, callback)
54 callback = InspectorTest.safeWrap(callback);
56 var profilesPanel = WebInspector.panels.profiles;
57 if (profilesPanel.visibleView && profilesPanel.visibleView.profile && profilesPanel.visibleView._profileHeader.title === title)
58 callback(profilesPanel.visibleView);
60 InspectorTest._waitUntilProfileViewIsShownCallback = { title: title, callback: callback };
63 InspectorTest._profileViewRefresh = function()
65 // Called in the context of ProfileView.
66 if (InspectorTest._waitUntilProfileViewIsShownCallback && InspectorTest._waitUntilProfileViewIsShownCallback.title === this._profileHeader.title) {
67 var callback = InspectorTest._waitUntilProfileViewIsShownCallback;
68 delete InspectorTest._waitUntilProfileViewIsShownCallback;
69 callback.callback(this);