import"../profiler/profiler-legacy.js";import"../test_runner/test_runner.js";self.CPUProfilerTestRunner=self.CPUProfilerTestRunner||{},CPUProfilerTestRunner.startProfilerTest=function(e){TestRunner.addResult("Profiler was enabled."),TestRunner.addSniffer(UI.panels.js_profiler,"_addProfileHeader",CPUProfilerTestRunner._profileHeaderAdded,!0),TestRunner.addSniffer(Profiler.ProfileView.prototype,"refresh",CPUProfilerTestRunner._profileViewRefresh,!0),TestRunner.safeWrap(e)()},CPUProfilerTestRunner.completeProfilerTest=function(){TestRunner.addResult(""),TestRunner.addResult("Profiler was disabled."),TestRunner.completeTest()},CPUProfilerTestRunner.runProfilerTestSuite=function(e){const r=e.slice();CPUProfilerTestRunner.startProfilerTest((function e(){if(!r.length)return void CPUProfilerTestRunner.completeProfilerTest();const n=r.shift();TestRunner.addResult(""),TestRunner.addResult("Running: "+/function\s([^(]*)/.exec(n)[1]),TestRunner.safeWrap(n)(e,e)}))},CPUProfilerTestRunner.showProfileWhenAdded=function(e){CPUProfilerTestRunner._showProfileWhenAdded=e},CPUProfilerTestRunner._profileHeaderAdded=function(e){CPUProfilerTestRunner._showProfileWhenAdded===e.title&&UI.panels.js_profiler.showProfile(e)},CPUProfilerTestRunner.waitUntilProfileViewIsShown=function(e,r){r=TestRunner.safeWrap(r);const n=UI.panels.js_profiler;n.visibleView&&n.visibleView.profile&&n.visibleView.profileHeader.title===e?r(n.visibleView):CPUProfilerTestRunner._waitUntilProfileViewIsShownCallback={title:e,callback:r}},CPUProfilerTestRunner._profileViewRefresh=function(){if(CPUProfilerTestRunner._waitUntilProfileViewIsShownCallback&&CPUProfilerTestRunner._waitUntilProfileViewIsShownCallback.title===this.profileHeader.title){const e=CPUProfilerTestRunner._waitUntilProfileViewIsShownCallback;delete CPUProfilerTestRunner._waitUntilProfileViewIsShownCallback,e.callback(this)}};