function testSourceMapping(e,n,t,r){const o=e.indexOf(r);TestRunner.assertTrue(-1!==o);const s=TestRunner.findLineEndingIndexes(e),i=TestRunner.findLineEndingIndexes(n),u=Formatter.Formatter.positionToLocation(s,o),a=t.originalToFormatted(u[0],u[1]),l=Formatter.Formatter.locationToPosition(i,a[0],a[1]);n.indexOf(r)===l?TestRunner.addResult(String.sprintf("Correct mapping for <%s>",r)):TestRunner.addResult(String.sprintf("ERROR: Wrong mapping for <%s>",r))}self.SourcesTestRunner=self.SourcesTestRunner||{},SourcesTestRunner.dumpNavigatorView=function(e,n){function t(e,r){let o="";if(r._leadingIconsElement&&n){let e=r._leadingIconsElement.querySelectorAll("[is=ui-icon]");e=Array.prototype.slice.call(e);const n=e.map((e=>e._iconType));n.length&&(o=o+"["+n.join(", ")+"] ")}if(o+=r.title,r._nodeType===Sources.NavigatorView.Types.FileSystem||r._nodeType===Sources.NavigatorView.Types.FileSystemFolder){r.listItemElement.classList.contains("has-mapped-files")||(o+=" [dimmed]")}TestRunner.addResult(e+o),r.expand();const s=r.children();for(let n=0;n<s.length;++n)t(e+"  ",s[n])}!function(e){const n=e.rootElement().children();for(let r=0;r<n.length;++r)t("",n[r])}(e._scriptsTree)},SourcesTestRunner.dumpNavigatorViewInAllModes=function(e){["frame","frame/domain","frame/domain/folder","domain","domain/folder"].forEach(SourcesTestRunner.dumpNavigatorViewInMode.bind(TestRunner,e))},SourcesTestRunner.dumpNavigatorViewInMode=function(e,n){TestRunner.addResult(e instanceof Sources.NetworkNavigatorView?"Sources:":"Content Scripts:"),e._groupByFrame=n.includes("frame"),e._groupByDomain=n.includes("domain"),e._groupByFolder=n.includes("folder"),e._resetForTest(),TestRunner.addResult("-------- Setting mode: ["+n+"]"),SourcesTestRunner.dumpNavigatorView(e)},SourcesTestRunner.addScriptUISourceCode=function(e,n,t,r){return n+="\n//# sourceURL="+e,t&&(n=`testRunner.evaluateScriptInIsolatedWorld(${r}, \`${n}\`)`),TestRunner.evaluateInPageAnonymously(n),TestRunner.waitForUISourceCode(e)},SourcesTestRunner.testPrettyPrint=function(e,n,t,r){new Formatter.ScriptFormatter(e,n,(function(e,o){TestRunner.addResult("====== 8< ------"),TestRunner.addResult(e),TestRunner.addResult("------ >8 ======");for(;t&&t.length;)testSourceMapping(n,e,o,t.shift());r()}))},SourcesTestRunner.testJavascriptOutline=function(e){let n;const t=new Promise((e=>{n=e}));Formatter.formatterWorkerPool().javaScriptOutline(e,(function(t,o){if(r.push(...o),!t)return;TestRunner.addResult("Text:"),TestRunner.addResult(e.split("\n").map((e=>"    "+e)).join("\n")),TestRunner.addResult("Outline:");for(const e of r)TestRunner.addResult("    "+e.name+(e.arguments||"")+":"+e.line+":"+e.column);n()}));const r=[];return t},SourcesTestRunner.dumpSwatchPositions=function(e,n){const t=e.textEditor,r=t.bookmarks(t.fullRange(),n);for(let o=0;o<r.length;o++){const e=r[o].position(),n=r[o]._marker.widgetNode.firstChild;let t=n.textContent;"devtools-color-swatch"===n.localName&&(t=n.color.asString(n.format)),TestRunner.addResult("Line "+e.startLine+", Column "+e.startColumn+": "+t)}};