import"../test_runner/test_runner.js";import"../coverage/coverage-legacy.js";import"../sources_test_runner/sources_test_runner.js";self.CoverageTestRunner=self.CoverageTestRunner||{},CoverageTestRunner.startCoverage=async function(e){self.UI.viewManager.showView("coverage");const r=self.runtime.sharedInstance(Coverage.CoverageView);await r._startRecording({reload:!1,jsCoveragePerBlock:e})},CoverageTestRunner.stopCoverage=function(){return self.runtime.sharedInstance(Coverage.CoverageView).stopRecording()},CoverageTestRunner.suspendCoverageModel=async function(){const e=self.runtime.sharedInstance(Coverage.CoverageView);await e._model.preSuspendModel(),await e._model.suspendModel()},CoverageTestRunner.resumeCoverageModel=async function(){const e=self.runtime.sharedInstance(Coverage.CoverageView);await e._model.resumeModel(),await e._model.postResumeModel()},CoverageTestRunner.pollCoverage=async function(){const e=self.runtime.sharedInstance(Coverage.CoverageView);return await e._model._currentPollPromise,e._model._pollAndCallback()},CoverageTestRunner.getCoverageModel=function(){return self.runtime.sharedInstance(Coverage.CoverageView)._model},CoverageTestRunner.exportReport=async function(){const e=self.runtime.sharedInstance(Coverage.CoverageView);let r;return await e._model.exportReport({write:e=>{r=e},close:e=>0}),r},CoverageTestRunner.sourceDecorated=async function(e){await self.UI.inspectorView.showPanel("sources");const r=TestRunner.addSnifferPromise(Coverage.CoverageView.LineDecorator.prototype,"_innerDecorate"),n=await SourcesTestRunner.showScriptSourcePromise(e);return await r,n},CoverageTestRunner.dumpDecorations=async function(e){const r=await CoverageTestRunner.sourceDecorated(e);CoverageTestRunner.dumpDecorationsInSourceFrame(r)},CoverageTestRunner.findCoverageNodeForURL=function(e){const r=self.runtime.sharedInstance(Coverage.CoverageView)._listView._dataGrid.rootNode();for(const n of r.children)if(n._coverageInfo.url().endsWith(e))return n;return null},CoverageTestRunner.dumpDecorationsInSourceFrame=function(e){const r=new Map([["used","+"],["unused","-"]]),n=e.textEditor.codeMirror();for(let o=0;o<n.lineCount();++o){const e=n.getLine(o);let t=" ";const s=n.lineInfo(o);if(!s)continue;const a=s.gutterMarkers&&s.gutterMarkers["CodeMirror-gutter-coverage"];if(a){const e=/^text-editor-coverage-(\w*)-marker$/.exec(a.classList)[1];t=r.get(e)||a.classList}TestRunner.addResult(`${o}: ${t} ${e}`)}},CoverageTestRunner.dumpCoverageListView=function(){const e=self.runtime.sharedInstance(Coverage.CoverageView)._listView._dataGrid;e.updateInstantly();for(const r of e.rootNode().children){const e=r._coverageInfo,n=TestRunner.formatters.formatAsURL(e.url());if(n.startsWith("test://"))continue;const o=Coverage.coverageTypeToString(e.type());TestRunner.addResult(`${n} ${o} used: ${e.usedSize()} unused: ${e.unusedSize()} total: ${e.size()}`)}};