<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[199602] trunk</title>
</head>
<body>

<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt;  }
#msg dl a { font-weight: bold}
#msg dl a:link    { color:#fc3; }
#msg dl a:active  { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff  {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta">
<dt>Revision</dt> <dd><a href="http://trac.webkit.org/projects/webkit/changeset/199602">199602</a></dd>
<dt>Author</dt> <dd>commit-queue@webkit.org</dd>
<dt>Date</dt> <dd>2016-04-15 12:01:39 -0700 (Fri, 15 Apr 2016)</dd>
</dl>

<h3>Log Message</h3>
<pre>Web Inspector: sourceMappingURL not used when sourceURL is set
https://bugs.webkit.org/show_bug.cgi?id=156021
&lt;rdar://problem/25438417&gt;

Patch by Joseph Pecoraro &lt;pecoraro@apple.com&gt; on 2016-04-15
Reviewed by Timothy Hatcher.

Source/JavaScriptCore:

Clean up Debugger.sourceParsed to separately include:

    - url (&quot;resource URL&quot;, &quot;source url&quot; in JSC APIs)
    - sourceURL - //# sourceURL directive

By always having the resource URL the Web Inspector frontend
can better match this Script to a Resource of the same URL,
and decide to use the sourceURL if it is available when
appropriate.

* inspector/protocol/Debugger.json:
* inspector/agents/InspectorDebuggerAgent.cpp:
(Inspector::InspectorDebuggerAgent::setBreakpointByUrl):
(Inspector::InspectorDebuggerAgent::didParseSource):
Send the new sourceParsed parameters.

Source/WebInspectorUI:

Previously Debugger.sourceParsed only providing the sourceURL, and
wiping out the resourceURL, meant that a Script from a Resource that
set a sourceURL directive would fail to be associated with its Resource.

This would result in duplicated tree elements in the Resources Sidebar,
one for the Resource, and one for the Script. With the Script getting
ultimately getting the SourceMap resources. However, since the frontend
prefers Resources over Scripts when possible, an error that generated
from the script would point to a location in the Resource, not following
source maps.

By always providing the resource URL in Debugger.sourceParsed, a Script
can better be associated with its Resource. The result is now a single
shared tree element in the Resources Sidebar, and the Resource getting
the SourceMap resources. Now the script error goes through the Resource
to its SourceMap resources as we would expect.

* UserInterface/Protocol/DebuggerObserver.js:
(WebInspector.DebuggerObserver):
(WebInspector.DebuggerObserver.prototype.scriptParsed):
We now have to handle two different signatures of scriptParsed. One
for legacy, and one for non-legacy. Cache that value early on, since
scriptParsed happens a lot.

* UserInterface/Protocol/InspectorBackend.js:
(InspectorBackend.Agent.prototype.hasEventParameter):
Runtime check a protocol event to see if it has a parameter. This
is used to check if Debugger.sourceParsed is legacy or not based
on if it has the legacy &quot;hasSourceURL&quot; parameter.

* UserInterface/Models/Script.js:
(WebInspector.Script):
(WebInspector.Script.prototype.get sourceURL):
Treat sourceURL and url separately.

(WebInspector.Script.prototype.get displayName):
Handle both the url and sourceURL in displayName.

* UserInterface/Controllers/DebuggerManager.js:
(WebInspector.DebuggerManager.prototype.get knownNonResourceScripts):
(WebInspector.DebuggerManager.prototype.debuggerDidPause):
(WebInspector.DebuggerManager.prototype.scriptDidParse):
* UserInterface/Protocol/RemoteObject.js:
(WebInspector.RemoteObject.prototype.findFunctionSourceCodeLocation):
Update code that checks the sourceURL to explicitly use sourceURL.

* UserInterface/Controllers/SourceMapManager.js:
(WebInspector.SourceMapManager.prototype.downloadSourceMap):
For legacy backends, or in case we get a resource that has an incomplete
baseURL, attempt to get an absolute URL based on the main resource.

* UserInterface/Views/DebuggerSidebarPanel.js:
(WebInspector.DebuggerSidebarPanel.prototype._addScript):
* UserInterface/Views/ResourceSidebarPanel.js:
(WebInspector.ResourceSidebarPanel.prototype._scriptWasAdded):
Ignore scripts without a url or sourceURL.

LayoutTests:

* inspector/debugger/scriptParsed.html:
* inspector/debugger/search-scripts.html:
* inspector/debugger/setBreakpointByUrl-sourceURL.html:
* inspector/debugger/sourceURLs.html:
Update tests that need to handle sourceURL separately.

* inspector/model/resources/relationship-named.js: Added.
* inspector/model/resources/relationship-normal.js: Added.
* inspector/model/script-resource-relationship-expected.txt: Added.
* inspector/model/script-resource-relationship.html: Added.
Tests for Script and Resource relationships.</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkLayoutTestsChangeLog">trunk/LayoutTests/ChangeLog</a></li>
<li><a href="#trunkLayoutTestsinspectordebuggerscriptParsedhtml">trunk/LayoutTests/inspector/debugger/scriptParsed.html</a></li>
<li><a href="#trunkLayoutTestsinspectordebuggersearchscriptshtml">trunk/LayoutTests/inspector/debugger/search-scripts.html</a></li>
<li><a href="#trunkLayoutTestsinspectordebuggersetBreakpointByUrlsourceURLhtml">trunk/LayoutTests/inspector/debugger/setBreakpointByUrl-sourceURL.html</a></li>
<li><a href="#trunkLayoutTestsinspectordebuggersourceURLshtml">trunk/LayoutTests/inspector/debugger/sourceURLs.html</a></li>
<li><a href="#trunkSourceJavaScriptCoreChangeLog">trunk/Source/JavaScriptCore/ChangeLog</a></li>
<li><a href="#trunkSourceJavaScriptCoreinspectoragentsInspectorDebuggerAgentcpp">trunk/Source/JavaScriptCore/inspector/agents/InspectorDebuggerAgent.cpp</a></li>
<li><a href="#trunkSourceJavaScriptCoreinspectorprotocolDebuggerjson">trunk/Source/JavaScriptCore/inspector/protocol/Debugger.json</a></li>
<li><a href="#trunkSourceWebInspectorUIChangeLog">trunk/Source/WebInspectorUI/ChangeLog</a></li>
<li><a href="#trunkSourceWebInspectorUIUserInterfaceControllersDebuggerManagerjs">trunk/Source/WebInspectorUI/UserInterface/Controllers/DebuggerManager.js</a></li>
<li><a href="#trunkSourceWebInspectorUIUserInterfaceControllersSourceMapManagerjs">trunk/Source/WebInspectorUI/UserInterface/Controllers/SourceMapManager.js</a></li>
<li><a href="#trunkSourceWebInspectorUIUserInterfaceModelsScriptjs">trunk/Source/WebInspectorUI/UserInterface/Models/Script.js</a></li>
<li><a href="#trunkSourceWebInspectorUIUserInterfaceProtocolDebuggerObserverjs">trunk/Source/WebInspectorUI/UserInterface/Protocol/DebuggerObserver.js</a></li>
<li><a href="#trunkSourceWebInspectorUIUserInterfaceProtocolInspectorBackendjs">trunk/Source/WebInspectorUI/UserInterface/Protocol/InspectorBackend.js</a></li>
<li><a href="#trunkSourceWebInspectorUIUserInterfaceProtocolRemoteObjectjs">trunk/Source/WebInspectorUI/UserInterface/Protocol/RemoteObject.js</a></li>
<li><a href="#trunkSourceWebInspectorUIUserInterfaceViewsDebuggerSidebarPaneljs">trunk/Source/WebInspectorUI/UserInterface/Views/DebuggerSidebarPanel.js</a></li>
<li><a href="#trunkSourceWebInspectorUIUserInterfaceViewsResourceSidebarPaneljs">trunk/Source/WebInspectorUI/UserInterface/Views/ResourceSidebarPanel.js</a></li>
</ul>

<h3>Added Paths</h3>
<ul>
<li><a href="#trunkLayoutTestsinspectormodelresourcesrelationshipnamedjs">trunk/LayoutTests/inspector/model/resources/relationship-named.js</a></li>
<li><a href="#trunkLayoutTestsinspectormodelresourcesrelationshipnormaljs">trunk/LayoutTests/inspector/model/resources/relationship-normal.js</a></li>
<li><a href="#trunkLayoutTestsinspectormodelscriptresourcerelationshipexpectedtxt">trunk/LayoutTests/inspector/model/script-resource-relationship-expected.txt</a></li>
<li><a href="#trunkLayoutTestsinspectormodelscriptresourcerelationshiphtml">trunk/LayoutTests/inspector/model/script-resource-relationship.html</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkLayoutTestsChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/ChangeLog (199601 => 199602)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/ChangeLog        2016-04-15 18:56:53 UTC (rev 199601)
+++ trunk/LayoutTests/ChangeLog        2016-04-15 19:01:39 UTC (rev 199602)
</span><span class="lines">@@ -1,3 +1,23 @@
</span><ins>+2016-04-15  Joseph Pecoraro  &lt;pecoraro@apple.com&gt;
+
+        Web Inspector: sourceMappingURL not used when sourceURL is set
+        https://bugs.webkit.org/show_bug.cgi?id=156021
+        &lt;rdar://problem/25438417&gt;
+
+        Reviewed by Timothy Hatcher.
+
+        * inspector/debugger/scriptParsed.html:
+        * inspector/debugger/search-scripts.html:
+        * inspector/debugger/setBreakpointByUrl-sourceURL.html:
+        * inspector/debugger/sourceURLs.html:
+        Update tests that need to handle sourceURL separately.
+        
+        * inspector/model/resources/relationship-named.js: Added.
+        * inspector/model/resources/relationship-normal.js: Added.
+        * inspector/model/script-resource-relationship-expected.txt: Added.
+        * inspector/model/script-resource-relationship.html: Added.
+        Tests for Script and Resource relationships.
+
</ins><span class="cx"> 2016-04-15  Jiewen Tan  &lt;jiewen_tan@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         Mark fast/text/font-face-javascript.html as flaky
</span></span></pre></div>
<a id="trunkLayoutTestsinspectordebuggerscriptParsedhtml"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/inspector/debugger/scriptParsed.html (199601 => 199602)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/inspector/debugger/scriptParsed.html        2016-04-15 18:56:53 UTC (rev 199601)
+++ trunk/LayoutTests/inspector/debugger/scriptParsed.html        2016-04-15 19:01:39 UTC (rev 199602)
</span><span class="lines">@@ -46,15 +46,15 @@
</span><span class="cx">     }
</span><span class="cx"> 
</span><span class="cx">     function isEvalScript(params) {
</span><del>-        return params.hasSourceURL &amp;&amp; params.url === &quot;eval.js&quot;;
</del><ins>+        return params.sourceURL === &quot;eval.js&quot;;
</ins><span class="cx">     }
</span><span class="cx"> 
</span><span class="cx">     function isInjectedScriptSourceScript(params) {
</span><del>-        return params.hasSourceURL &amp;&amp; params.url === &quot;__WebInspectorInjectedScript__&quot;;
</del><ins>+        return params.sourceURL === &quot;__WebInspectorInjectedScript__&quot;;
</ins><span class="cx">     }
</span><span class="cx"> 
</span><span class="cx">     function isCommandLineAPISourceScript(params) {
</span><del>-        return params.hasSourceURL &amp;&amp; params.url === &quot;__WebInspectorCommandLineAPIModuleSource__&quot;;
</del><ins>+        return params.sourceURL === &quot;__WebInspectorCommandLineAPIModuleSource__&quot;;
</ins><span class="cx">     }
</span><span class="cx"> 
</span><span class="cx">     suite.addTestCase({
</span></span></pre></div>
<a id="trunkLayoutTestsinspectordebuggersearchscriptshtml"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/inspector/debugger/search-scripts.html (199601 => 199602)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/inspector/debugger/search-scripts.html        2016-04-15 18:56:53 UTC (rev 199601)
+++ trunk/LayoutTests/inspector/debugger/search-scripts.html        2016-04-15 19:01:39 UTC (rev 199602)
</span><span class="lines">@@ -27,12 +27,12 @@
</span><span class="cx"> 
</span><span class="cx">     WebInspector.debuggerManager.addEventListener(WebInspector.DebuggerManager.Event.ScriptAdded, function(event) {
</span><span class="cx">         var script = event.data.script;
</span><del>-        if (!/LayoutTests/.test(script.url) &amp;&amp; !/eval\d\.js/.test(script.url))
</del><ins>+        if (!/LayoutTests/.test(script.url) &amp;&amp; !/eval\d\.js/.test(script.sourceURL))
</ins><span class="cx">             return;
</span><span class="cx"> 
</span><span class="cx">         DebuggerAgent.searchInContent(script.id, &quot;SEARCHTEST&quot;, false, false, function(error, results) {
</span><span class="cx">             InspectorTest.log(&quot;&quot;);
</span><del>-            InspectorTest.log(&quot;SCRIPT: &quot; + sanitizeScriptURL(script.url));
</del><ins>+            InspectorTest.log(&quot;SCRIPT: &quot; + sanitizeScriptURL(script.sourceURL || script.url));
</ins><span class="cx">             InspectorTest.log(&quot;RESULTS: &quot; + results.length);
</span><span class="cx">             for (var result of results) {
</span><span class="cx">                 InspectorTest.log(&quot;  LINE: &quot; + result.lineNumber);
</span></span></pre></div>
<a id="trunkLayoutTestsinspectordebuggersetBreakpointByUrlsourceURLhtml"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/inspector/debugger/setBreakpointByUrl-sourceURL.html (199601 => 199602)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/inspector/debugger/setBreakpointByUrl-sourceURL.html        2016-04-15 18:56:53 UTC (rev 199601)
+++ trunk/LayoutTests/inspector/debugger/setBreakpointByUrl-sourceURL.html        2016-04-15 19:01:39 UTC (rev 199602)
</span><span class="lines">@@ -13,9 +13,9 @@
</span><span class="cx"> 
</span><span class="cx">     InspectorProtocol.eventHandler[&quot;Debugger.scriptParsed&quot;] = function(messageObject)
</span><span class="cx">     {
</span><del>-        if (/sourceURL-test\.js$/.test(messageObject.params.url)) {
</del><ins>+        if (/sourceURL-test\.js$/.test(messageObject.params.sourceURL)) {
</ins><span class="cx">             ProtocolTest.log(&quot;Found sourceURL-test.js&quot;);
</span><del>-            var params = {url: messageObject.params.url, lineNumber: 3, columnNumber: 0};
</del><ins>+            var params = {url: messageObject.params.sourceURL, lineNumber: 3, columnNumber: 0};
</ins><span class="cx">             InspectorProtocol.sendCommand(&quot;Debugger.setBreakpointByUrl&quot;, params, function(responseObject) {
</span><span class="cx">                 InspectorProtocol.checkForError(responseObject);
</span><span class="cx">                 ProtocolTest.log(&quot;Running sourceURLFunction&quot;);
</span></span></pre></div>
<a id="trunkLayoutTestsinspectordebuggersourceURLshtml"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/inspector/debugger/sourceURLs.html (199601 => 199602)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/inspector/debugger/sourceURLs.html        2016-04-15 18:56:53 UTC (rev 199601)
+++ trunk/LayoutTests/inspector/debugger/sourceURLs.html        2016-04-15 19:01:39 UTC (rev 199602)
</span><span class="lines">@@ -36,12 +36,12 @@
</span><span class="cx"> 
</span><span class="cx">             InspectorProtocol.eventHandler[&quot;Debugger.scriptParsed&quot;] = function(messageObject) {
</span><span class="cx">                 // Ignore named inspector internal scripts.
</span><del>-                if (messageObject.params.url.startsWith(&quot;__WebInspector&quot;))
</del><ins>+                if (messageObject.params.sourceURL &amp;&amp; messageObject.params.sourceURL.startsWith(&quot;__WebInspector&quot;))
</ins><span class="cx">                     return;
</span><span class="cx"> 
</span><span class="cx">                 // Has a sourceURL, must be one of the valid ones.
</span><del>-                if (messageObject.params.hasSourceURL) {
-                    let sourceURL = messageObject.params.url;
</del><ins>+                if (messageObject.params.sourceURL) {
+                    let sourceURL = messageObject.params.sourceURL;
</ins><span class="cx">                     ProtocolTest.log(`Found Script with sourceURL '${sourceURL}'`);
</span><span class="cx">                     ProtocolTest.assert(sourceURLExpectations[0] === sourceURL, &quot;Did not expect to see sourceURL: &quot; + sourceURL);
</span><span class="cx">                     sourceURLExpectations.shift();
</span></span></pre></div>
<a id="trunkLayoutTestsinspectormodelresourcesrelationshipnamedjs"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/inspector/model/resources/relationship-named.js (0 => 199602)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/inspector/model/resources/relationship-named.js                                (rev 0)
+++ trunk/LayoutTests/inspector/model/resources/relationship-named.js        2016-04-15 19:01:39 UTC (rev 199602)
</span><span class="lines">@@ -0,0 +1,5 @@
</span><ins>+//# sourceURL=foo.js
+
+function foo() {
+    return 142;
+}
</ins></span></pre></div>
<a id="trunkLayoutTestsinspectormodelresourcesrelationshipnormaljs"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/inspector/model/resources/relationship-normal.js (0 => 199602)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/inspector/model/resources/relationship-normal.js                                (rev 0)
+++ trunk/LayoutTests/inspector/model/resources/relationship-normal.js        2016-04-15 19:01:39 UTC (rev 199602)
</span><span class="lines">@@ -0,0 +1,3 @@
</span><ins>+function foo() {
+    return 42;
+}
</ins></span></pre></div>
<a id="trunkLayoutTestsinspectormodelscriptresourcerelationshipexpectedtxt"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/inspector/model/script-resource-relationship-expected.txt (0 => 199602)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/inspector/model/script-resource-relationship-expected.txt                                (rev 0)
+++ trunk/LayoutTests/inspector/model/script-resource-relationship-expected.txt        2016-04-15 19:01:39 UTC (rev 199602)
</span><span class="lines">@@ -0,0 +1,38 @@
</span><ins>+WebInspector.Script and WebInspector.Resource relationship.
+
+
+== Running test suite: WebInspector.Script and WebInspector.Resource relationship
+-- Running test case: ScriptWithResource
+PASS: Resource was added.
+PASS: Script was added.
+PASS: Resource and Script have the same URL.
+PASS: Resource should be related to one script.
+PASS: Resource should be related to the newly added script.
+PASS: Script should be related to the resource.
+PASS: Script should not have a sourceURL.
+
+-- Running test case: NamedScriptWithResource
+PASS: Resource was added.
+PASS: Script was added.
+PASS: Resource and Script have the same URL.
+PASS: Resource should be related to one script.
+PASS: Resource should be related to the newly added script.
+PASS: Script should be related to the resource.
+PASS: Script should have a sourceURL.
+
+-- Running test case: ScriptWithoutResource
+PASS: Script was added.
+PASS: Script should not be associated with a Resource.
+PASS: Script should have a sourceURL.
+
+-- Running test case: DocumentWithInlineScripts
+PASS: Main Resource should have 4 scripts.
+PASS: Inline script 1 does not have a sourceURL.
+PASS: Inline script 2 has a sourceURL.
+PASS: Inline script 3 does not have a sourceURL.
+PASS: Inline script 4 does not have a sourceURL.
+PASS: Inline script 1 should have a low start line.
+PASS: Inline script 2 should have a low start line.
+PASS: Inline script 3 should have a low start line.
+PASS: Inline script 4 should have a high start line.
+
</ins></span></pre></div>
<a id="trunkLayoutTestsinspectormodelscriptresourcerelationshiphtml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/inspector/model/script-resource-relationship.html (0 => 199602)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/inspector/model/script-resource-relationship.html                                (rev 0)
+++ trunk/LayoutTests/inspector/model/script-resource-relationship.html        2016-04-15 19:01:39 UTC (rev 199602)
</span><span class="lines">@@ -0,0 +1,170 @@
</span><ins>+&lt;!DOCTYPE html&gt;
+&lt;html&gt;
+&lt;head&gt;
+&lt;script src=&quot;../../http/tests/inspector/resources/inspector-test.js&quot;&gt;&lt;/script&gt;
+&lt;script&gt;function inlineScriptOne() { return 1; }&lt;/script&gt;
+  &lt;script&gt;
+  function inlineScriptTwo() {
+      return 2;
+  }
+  //# sourceURL=inline-script-two.js
+  &lt;/script&gt;
+&lt;script&gt;
+function triggerResourceWithNormalScript() {
+    let script = document.createElement(&quot;script&quot;);
+    script.src = &quot;resources/relationship-normal.js&quot;;
+    document.body.appendChild(script);
+}
+
+function triggerResourceWithNamedScript() {
+    let script = document.createElement(&quot;script&quot;);
+    script.src = &quot;resources/relationship-named.js&quot;;
+    document.body.appendChild(script);
+}
+
+function triggerScriptWithoutResource() {
+    eval(&quot;//# sourceURL=script-only.js\n1+1&quot;);
+}
+
+function test()
+{
+    let suite = InspectorTest.createAsyncSuite(&quot;WebInspector.Script and WebInspector.Resource relationship&quot;);
+
+    InspectorTest.dumpActivityToSystemConsole = true;
+    InspectorBackend.dumpInspectorProtocolMessages = true;
+
+    function validateNormalRelationship(resource, script) {
+        InspectorTest.expectThat(resource.url === script.url, &quot;Resource and Script have the same URL.&quot;);
+        InspectorTest.expectThat(resource.scripts.length === 1, &quot;Resource should be related to one script.&quot;);
+        InspectorTest.expectThat(resource.scripts[0] === script, &quot;Resource should be related to the newly added script.&quot;);
+        InspectorTest.expectThat(script.resource === resource, &quot;Script should be related to the resource.&quot;);
+    }
+
+    suite.addTestCase({
+        name: &quot;ScriptWithResource&quot;,
+        description: &quot;Normal relationship between a script and a resource.&quot;,
+        test: (resolve, reject) =&gt; {
+            let script = null, resource = null;
+            
+            WebInspector.debuggerManager.addEventListener(WebInspector.DebuggerManager.Event.ScriptAdded, scriptListener);
+            WebInspector.Frame.singleFireEventListener(WebInspector.Frame.Event.ResourceWasAdded, (event) =&gt; {
+                InspectorTest.pass(&quot;Resource was added.&quot;);
+                resource = event.data.resource;
+            });
+            
+            function scriptListener(event) {
+                if (!event.data.script.url)
+                    return;
+                InspectorTest.pass(&quot;Script was added.&quot;);
+                script = event.data.script;
+                validateRelationship();
+            }
+
+            function validateRelationship() {
+                validateNormalRelationship(resource, script);
+                InspectorTest.expectThat(!script.sourceURL, &quot;Script should not have a sourceURL.&quot;);
+
+                WebInspector.debuggerManager.removeEventListener(WebInspector.DebuggerManager.Event.ScriptAdded, scriptListener, null);
+                resolve();
+            }
+
+            InspectorTest.evaluateInPage(&quot;triggerResourceWithNormalScript()&quot;);
+        }
+    });
+
+    suite.addTestCase({
+        name: &quot;NamedScriptWithResource&quot;,
+        description: &quot;Normal relationship between a named script and a resource.&quot;,
+        test: (resolve, reject) =&gt; {
+            let script = null, resource = null;
+
+            WebInspector.debuggerManager.addEventListener(WebInspector.DebuggerManager.Event.ScriptAdded, scriptListener);
+            WebInspector.Frame.singleFireEventListener(WebInspector.Frame.Event.ResourceWasAdded, (event) =&gt; {
+                InspectorTest.pass(&quot;Resource was added.&quot;);
+                resource = event.data.resource;
+            });
+
+            function scriptListener(event) {
+                if (!event.data.script.url)
+                    return;
+                InspectorTest.pass(&quot;Script was added.&quot;);
+                script = event.data.script;
+                validateRelationship();
+            }
+
+            function validateRelationship() {
+                validateNormalRelationship(resource, script);
+                InspectorTest.expectThat(script.sourceURL === &quot;foo.js&quot;, &quot;Script should have a sourceURL.&quot;);
+                WebInspector.debuggerManager.removeEventListener(WebInspector.DebuggerManager.Event.ScriptAdded, scriptListener, null);
+                resolve();
+            }
+
+            InspectorTest.evaluateInPage(&quot;triggerResourceWithNamedScript()&quot;);
+        }
+    });
+
+    suite.addTestCase({
+        name: &quot;ScriptWithoutResource&quot;,
+        description: &quot;A named eval does not have a resource.&quot;,
+        test: (resolve, reject) =&gt; {
+            WebInspector.debuggerManager.addEventListener(WebInspector.DebuggerManager.Event.ScriptAdded, scriptListener);
+            let resourceListener = WebInspector.Frame.singleFireEventListener(WebInspector.Frame.Event.ResourceWasAdded, (event) =&gt; {
+                InspectorTest.fail(&quot;Resource should not be added.&quot;);
+                reject();
+            });
+
+            function scriptListener(event) {
+                if (!event.data.script.sourceURL)
+                    return;
+
+                InspectorTest.pass(&quot;Script was added.&quot;);
+                let script = event.data.script;
+
+                InspectorTest.expectThat(script.resource === null, &quot;Script should not be associated with a Resource.&quot;);
+                InspectorTest.expectThat(script.sourceURL === &quot;script-only.js&quot;, &quot;Script should have a sourceURL.&quot;);
+
+                WebInspector.Frame.removeEventListener(WebInspector.Frame.Event.ResourceWasAdded, resourceListener, null);
+                WebInspector.debuggerManager.removeEventListener(WebInspector.DebuggerManager.Event.ScriptAdded, scriptListener, null);
+                resolve();
+            }
+
+            InspectorTest.evaluateInPage(&quot;triggerScriptWithoutResource()&quot;);
+        }
+    });
+
+    suite.addTestCase({
+        name: &quot;DocumentWithInlineScripts&quot;,
+        description: &quot;A document resource may be associated with multiple inline scripts.&quot;,
+        test: (resolve, reject) =&gt; {
+            let mainResource = WebInspector.frameResourceManager.mainFrame.mainResource;
+            let scripts = mainResource.scripts.slice().sort((a, b) =&gt; a.range.startLine - b.range.startLine);
+
+            // Scripts are:
+            //   1. &lt;script&gt; with inlineScriptOne()
+            //   2. &lt;script&gt; with inlineScriptTwo()
+            //   3. This &lt;script&gt; with test()
+            //   4. The &lt;body onload&gt; inline script event listener
+
+            InspectorTest.expectThat(scripts.length === 4, &quot;Main Resource should have 4 scripts.&quot;);
+            InspectorTest.expectThat(!scripts[0].sourceURL, &quot;Inline script 1 does not have a sourceURL.&quot;);
+            InspectorTest.expectThat(scripts[1].sourceURL === &quot;inline-script-two.js&quot;, &quot;Inline script 2 has a sourceURL.&quot;);
+            InspectorTest.expectThat(!scripts[2].sourceURL, &quot;Inline script 3 does not have a sourceURL.&quot;);
+            InspectorTest.expectThat(!scripts[3].sourceURL, &quot;Inline script 4 does not have a sourceURL.&quot;);
+
+            InspectorTest.expectThat(scripts[0].range.startLine &lt; 15, &quot;Inline script 1 should have a low start line.&quot;);
+            InspectorTest.expectThat(scripts[1].range.startLine &lt; 15, &quot;Inline script 2 should have a low start line.&quot;);
+            InspectorTest.expectThat(scripts[2].range.startLine &lt; 15, &quot;Inline script 3 should have a low start line.&quot;);
+            InspectorTest.expectThat(scripts[3].range.startLine &gt; 100, &quot;Inline script 4 should have a high start line.&quot;);
+
+            resolve();
+        }
+    });
+
+    suite.runTestCasesAndFinish();
+}
+&lt;/script&gt;
+&lt;/head&gt;
+&lt;body onload=&quot;runTest()&quot;&gt;
+&lt;p&gt;WebInspector.Script and WebInspector.Resource relationship.&lt;/p&gt;
+&lt;/body&gt;
+&lt;/html&gt;
</ins></span></pre></div>
<a id="trunkSourceJavaScriptCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/ChangeLog (199601 => 199602)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/ChangeLog        2016-04-15 18:56:53 UTC (rev 199601)
+++ trunk/Source/JavaScriptCore/ChangeLog        2016-04-15 19:01:39 UTC (rev 199602)
</span><span class="lines">@@ -1,3 +1,27 @@
</span><ins>+2016-04-15  Joseph Pecoraro  &lt;pecoraro@apple.com&gt;
+
+        Web Inspector: sourceMappingURL not used when sourceURL is set
+        https://bugs.webkit.org/show_bug.cgi?id=156021
+        &lt;rdar://problem/25438417&gt;
+
+        Reviewed by Timothy Hatcher.
+
+        Clean up Debugger.sourceParsed to separately include:
+
+            - url (&quot;resource URL&quot;, &quot;source url&quot; in JSC APIs)
+            - sourceURL - //# sourceURL directive
+
+        By always having the resource URL the Web Inspector frontend
+        can better match this Script to a Resource of the same URL,
+        and decide to use the sourceURL if it is available when
+        appropriate.
+
+        * inspector/protocol/Debugger.json:
+        * inspector/agents/InspectorDebuggerAgent.cpp:
+        (Inspector::InspectorDebuggerAgent::setBreakpointByUrl):
+        (Inspector::InspectorDebuggerAgent::didParseSource):
+        Send the new sourceParsed parameters.
+
</ins><span class="cx"> 2016-04-14  Joseph Pecoraro  &lt;pecoraro@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         Web Inspector: Cleanup inspector/debugger tests
</span></span></pre></div>
<a id="trunkSourceJavaScriptCoreinspectoragentsInspectorDebuggerAgentcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/inspector/agents/InspectorDebuggerAgent.cpp (199601 => 199602)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/inspector/agents/InspectorDebuggerAgent.cpp        2016-04-15 18:56:53 UTC (rev 199601)
+++ trunk/Source/JavaScriptCore/inspector/agents/InspectorDebuggerAgent.cpp        2016-04-15 19:01:39 UTC (rev 199602)
</span><span class="lines">@@ -320,8 +320,8 @@
</span><span class="cx"> 
</span><span class="cx">     ScriptBreakpoint breakpoint(lineNumber, columnNumber, condition, breakpointActions, autoContinue, ignoreCount);
</span><span class="cx">     for (ScriptsMap::iterator it = m_scripts.begin(); it != m_scripts.end(); ++it) {
</span><del>-        String scriptURL = !it-&gt;value.sourceURL.isEmpty() ? it-&gt;value.sourceURL : it-&gt;value.url;
-        if (!matches(scriptURL, url, isRegex))
</del><ins>+        String scriptURLForBreakpoints = !it-&gt;value.sourceURL.isEmpty() ? it-&gt;value.sourceURL : it-&gt;value.url;
+        if (!matches(scriptURLForBreakpoints, url, isRegex))
</ins><span class="cx">             continue;
</span><span class="cx"> 
</span><span class="cx">         RefPtr&lt;Inspector::Protocol::Debugger::Location&gt; location = resolveBreakpoint(breakpointIdentifier, it-&gt;key, breakpoint);
</span><span class="lines">@@ -613,18 +613,21 @@
</span><span class="cx"> 
</span><span class="cx"> void InspectorDebuggerAgent::didParseSource(JSC::SourceID sourceID, const Script&amp; script)
</span><span class="cx"> {
</span><ins>+    String scriptIDStr = String::number(sourceID);
</ins><span class="cx">     bool hasSourceURL = !script.sourceURL.isEmpty();
</span><del>-    String scriptURL = hasSourceURL ? script.sourceURL : script.url;
-    bool* hasSourceURLParam = hasSourceURL ? &amp;hasSourceURL : nullptr;
</del><ins>+    String sourceURL = script.sourceURL;
</ins><span class="cx">     String sourceMappingURL = sourceMapURLForScript(script);
</span><del>-    String* sourceMapURLParam = sourceMappingURL.isNull() ? nullptr : &amp;sourceMappingURL;
</del><ins>+
</ins><span class="cx">     const bool* isContentScript = script.isContentScript ? &amp;script.isContentScript : nullptr;
</span><del>-    String scriptIDStr = String::number(sourceID);
-    m_frontendDispatcher-&gt;scriptParsed(scriptIDStr, scriptURL, script.startLine, script.startColumn, script.endLine, script.endColumn, isContentScript, sourceMapURLParam, hasSourceURLParam);
</del><ins>+    String* sourceURLParam = hasSourceURL ? &amp;sourceURL : nullptr;
+    String* sourceMapURLParam = sourceMappingURL.isEmpty() ? nullptr : &amp;sourceMappingURL;
</ins><span class="cx"> 
</span><ins>+    m_frontendDispatcher-&gt;scriptParsed(scriptIDStr, script.url, script.startLine, script.startColumn, script.endLine, script.endColumn, isContentScript, sourceURLParam, sourceMapURLParam);
+
</ins><span class="cx">     m_scripts.set(sourceID, script);
</span><span class="cx"> 
</span><del>-    if (scriptURL.isEmpty())
</del><ins>+    String scriptURLForBreakpoints = hasSourceURL ? script.sourceURL : script.url;
+    if (scriptURLForBreakpoints.isEmpty())
</ins><span class="cx">         return;
</span><span class="cx"> 
</span><span class="cx">     for (auto it = m_javaScriptBreakpoints.begin(), end = m_javaScriptBreakpoints.end(); it != end; ++it) {
</span><span class="lines">@@ -633,10 +636,10 @@
</span><span class="cx">             return;
</span><span class="cx"> 
</span><span class="cx">         bool isRegex;
</span><ins>+        String url;
</ins><span class="cx">         breakpointObject-&gt;getBoolean(ASCIILiteral(&quot;isRegex&quot;), isRegex);
</span><del>-        String url;
</del><span class="cx">         breakpointObject-&gt;getString(ASCIILiteral(&quot;url&quot;), url);
</span><del>-        if (!matches(scriptURL, url, isRegex))
</del><ins>+        if (!matches(scriptURLForBreakpoints, url, isRegex))
</ins><span class="cx">             continue;
</span><span class="cx"> 
</span><span class="cx">         ScriptBreakpoint breakpoint;
</span></span></pre></div>
<a id="trunkSourceJavaScriptCoreinspectorprotocolDebuggerjson"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/inspector/protocol/Debugger.json (199601 => 199602)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/inspector/protocol/Debugger.json        2016-04-15 18:56:53 UTC (rev 199601)
+++ trunk/Source/JavaScriptCore/inspector/protocol/Debugger.json        2016-04-15 19:01:39 UTC (rev 199602)
</span><span class="lines">@@ -275,14 +275,14 @@
</span><span class="cx">             &quot;name&quot;: &quot;scriptParsed&quot;,
</span><span class="cx">             &quot;parameters&quot;: [
</span><span class="cx">                 { &quot;name&quot;: &quot;scriptId&quot;, &quot;$ref&quot;: &quot;ScriptId&quot;, &quot;description&quot;: &quot;Identifier of the script parsed.&quot; },
</span><del>-                { &quot;name&quot;: &quot;url&quot;, &quot;type&quot;: &quot;string&quot;, &quot;description&quot;: &quot;URL or name of the script parsed (if any).&quot; },
</del><ins>+                { &quot;name&quot;: &quot;url&quot;, &quot;type&quot;: &quot;string&quot;, &quot;description&quot;: &quot;URL of the script parsed (if any).&quot; },
</ins><span class="cx">                 { &quot;name&quot;: &quot;startLine&quot;, &quot;type&quot;: &quot;integer&quot;, &quot;description&quot;: &quot;Line offset of the script within the resource with given URL (for script tags).&quot; },
</span><span class="cx">                 { &quot;name&quot;: &quot;startColumn&quot;, &quot;type&quot;: &quot;integer&quot;, &quot;description&quot;: &quot;Column offset of the script within the resource with given URL.&quot; },
</span><span class="cx">                 { &quot;name&quot;: &quot;endLine&quot;, &quot;type&quot;: &quot;integer&quot;, &quot;description&quot;: &quot;Last line of the script.&quot; },
</span><span class="cx">                 { &quot;name&quot;: &quot;endColumn&quot;, &quot;type&quot;: &quot;integer&quot;, &quot;description&quot;: &quot;Length of the last line of the script.&quot; },
</span><span class="cx">                 { &quot;name&quot;: &quot;isContentScript&quot;, &quot;type&quot;: &quot;boolean&quot;, &quot;optional&quot;: true, &quot;description&quot;: &quot;Determines whether this script is a user extension script.&quot; },
</span><del>-                { &quot;name&quot;: &quot;sourceMapURL&quot;, &quot;type&quot;: &quot;string&quot;, &quot;optional&quot;: true, &quot;description&quot;: &quot;URL of source map associated with script (if any).&quot; },
-                { &quot;name&quot;: &quot;hasSourceURL&quot;, &quot;type&quot;: &quot;boolean&quot;, &quot;optional&quot;: true, &quot;description&quot;: &quot;True, if this script has sourceURL.&quot; }
</del><ins>+                { &quot;name&quot;: &quot;sourceURL&quot;, &quot;type&quot;: &quot;string&quot;, &quot;optional&quot;: true, &quot;description&quot;: &quot;sourceURL name of the script (if any).&quot; },
+                { &quot;name&quot;: &quot;sourceMapURL&quot;, &quot;type&quot;: &quot;string&quot;, &quot;optional&quot;: true, &quot;description&quot;: &quot;URL of source map associated with script (if any).&quot; }
</ins><span class="cx">             ],
</span><span class="cx">             &quot;description&quot;: &quot;Fired when virtual machine parses script. This event is also fired for all known and uncollected scripts upon enabling debugger.&quot;
</span><span class="cx">         },
</span></span></pre></div>
<a id="trunkSourceWebInspectorUIChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebInspectorUI/ChangeLog (199601 => 199602)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebInspectorUI/ChangeLog        2016-04-15 18:56:53 UTC (rev 199601)
+++ trunk/Source/WebInspectorUI/ChangeLog        2016-04-15 19:01:39 UTC (rev 199602)
</span><span class="lines">@@ -1,3 +1,68 @@
</span><ins>+2016-04-15  Joseph Pecoraro  &lt;pecoraro@apple.com&gt;
+
+        Web Inspector: sourceMappingURL not used when sourceURL is set
+        https://bugs.webkit.org/show_bug.cgi?id=156021
+        &lt;rdar://problem/25438417&gt;
+
+        Reviewed by Timothy Hatcher.
+
+        Previously Debugger.sourceParsed only providing the sourceURL, and
+        wiping out the resourceURL, meant that a Script from a Resource that
+        set a sourceURL directive would fail to be associated with its Resource.
+
+        This would result in duplicated tree elements in the Resources Sidebar,
+        one for the Resource, and one for the Script. With the Script getting
+        ultimately getting the SourceMap resources. However, since the frontend
+        prefers Resources over Scripts when possible, an error that generated
+        from the script would point to a location in the Resource, not following
+        source maps.
+
+        By always providing the resource URL in Debugger.sourceParsed, a Script
+        can better be associated with its Resource. The result is now a single
+        shared tree element in the Resources Sidebar, and the Resource getting
+        the SourceMap resources. Now the script error goes through the Resource
+        to its SourceMap resources as we would expect.
+
+        * UserInterface/Protocol/DebuggerObserver.js:
+        (WebInspector.DebuggerObserver):
+        (WebInspector.DebuggerObserver.prototype.scriptParsed):
+        We now have to handle two different signatures of scriptParsed. One
+        for legacy, and one for non-legacy. Cache that value early on, since
+        scriptParsed happens a lot.
+
+        * UserInterface/Protocol/InspectorBackend.js:
+        (InspectorBackend.Agent.prototype.hasEventParameter):
+        Runtime check a protocol event to see if it has a parameter. This
+        is used to check if Debugger.sourceParsed is legacy or not based
+        on if it has the legacy &quot;hasSourceURL&quot; parameter.
+
+        * UserInterface/Models/Script.js:
+        (WebInspector.Script):
+        (WebInspector.Script.prototype.get sourceURL):
+        Treat sourceURL and url separately.
+
+        (WebInspector.Script.prototype.get displayName):
+        Handle both the url and sourceURL in displayName.
+
+        * UserInterface/Controllers/DebuggerManager.js:
+        (WebInspector.DebuggerManager.prototype.get knownNonResourceScripts):
+        (WebInspector.DebuggerManager.prototype.debuggerDidPause):
+        (WebInspector.DebuggerManager.prototype.scriptDidParse):
+        * UserInterface/Protocol/RemoteObject.js:
+        (WebInspector.RemoteObject.prototype.findFunctionSourceCodeLocation):
+        Update code that checks the sourceURL to explicitly use sourceURL.
+
+        * UserInterface/Controllers/SourceMapManager.js:
+        (WebInspector.SourceMapManager.prototype.downloadSourceMap):
+        For legacy backends, or in case we get a resource that has an incomplete
+        baseURL, attempt to get an absolute URL based on the main resource.
+
+        * UserInterface/Views/DebuggerSidebarPanel.js:
+        (WebInspector.DebuggerSidebarPanel.prototype._addScript):
+        * UserInterface/Views/ResourceSidebarPanel.js:
+        (WebInspector.ResourceSidebarPanel.prototype._scriptWasAdded):
+        Ignore scripts without a url or sourceURL.
+
</ins><span class="cx"> 2016-04-14  Joseph Pecoraro  &lt;pecoraro@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         Web Inspector: Cleanup inspector/debugger tests
</span></span></pre></div>
<a id="trunkSourceWebInspectorUIUserInterfaceControllersDebuggerManagerjs"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebInspectorUI/UserInterface/Controllers/DebuggerManager.js (199601 => 199602)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebInspectorUI/UserInterface/Controllers/DebuggerManager.js        2016-04-15 18:56:53 UTC (rev 199601)
+++ trunk/Source/WebInspectorUI/UserInterface/Controllers/DebuggerManager.js        2016-04-15 19:01:39 UTC (rev 199602)
</span><span class="lines">@@ -337,7 +337,7 @@
</span><span class="cx">         for (let script of this._scriptIdMap.values()) {
</span><span class="cx">             if (script.resource)
</span><span class="cx">                 continue;
</span><del>-            if (!WebInspector.isDebugUIEnabled() &amp;&amp; isWebKitInternalScript(script.url))
</del><ins>+            if (!WebInspector.isDebugUIEnabled() &amp;&amp; isWebKitInternalScript(script.sourceURL))
</ins><span class="cx">                 continue;
</span><span class="cx">             knownScripts.push(script);
</span><span class="cx">         }
</span><span class="lines">@@ -535,7 +535,7 @@
</span><span class="cx">                 continue;
</span><span class="cx"> 
</span><span class="cx">             // Exclude the case where the call frame is in the inspector code.
</span><del>-            if (!WebInspector.isDebugUIEnabled() &amp;&amp; isWebKitInternalScript(sourceCodeLocation.sourceCode.url))
</del><ins>+            if (!WebInspector.isDebugUIEnabled() &amp;&amp; isWebKitInternalScript(sourceCodeLocation.sourceCode.sourceURL))
</ins><span class="cx">                 continue;
</span><span class="cx"> 
</span><span class="cx">             let scopeChain = this._scopeChainFromPayload(callFramePayload.scopeChain);
</span><span class="lines">@@ -565,7 +565,7 @@
</span><span class="cx">         InspectorFrontendHost.beep();
</span><span class="cx">     }
</span><span class="cx"> 
</span><del>-    scriptDidParse(scriptIdentifier, url, isContentScript, startLine, startColumn, endLine, endColumn, sourceMapURL)
</del><ins>+    scriptDidParse(scriptIdentifier, url, startLine, startColumn, endLine, endColumn, isContentScript, sourceURL, sourceMapURL)
</ins><span class="cx">     {
</span><span class="cx">         // Don't add the script again if it is already known.
</span><span class="cx">         if (this._scriptIdMap.has(scriptIdentifier)) {
</span><span class="lines">@@ -578,10 +578,10 @@
</span><span class="cx">             return;
</span><span class="cx">         }
</span><span class="cx"> 
</span><del>-        if (isWebInspectorInternalScript(url))
</del><ins>+        if (isWebInspectorInternalScript(sourceURL))
</ins><span class="cx">             return;
</span><span class="cx"> 
</span><del>-        var script = new WebInspector.Script(scriptIdentifier, new WebInspector.TextRange(startLine, startColumn, endLine, endColumn), url, isContentScript, sourceMapURL);
</del><ins>+        let script = new WebInspector.Script(scriptIdentifier, new WebInspector.TextRange(startLine, startColumn, endLine, endColumn), url, isContentScript, sourceURL, sourceMapURL);
</ins><span class="cx"> 
</span><span class="cx">         this._scriptIdMap.set(scriptIdentifier, script);
</span><span class="cx"> 
</span><span class="lines">@@ -594,7 +594,7 @@
</span><span class="cx">             scripts.push(script);
</span><span class="cx">         }
</span><span class="cx"> 
</span><del>-        if (isWebKitInternalScript(script.url)) {
</del><ins>+        if (isWebKitInternalScript(script.sourceURL)) {
</ins><span class="cx">             this._internalWebKitScripts.push(script);
</span><span class="cx">             if (!WebInspector.isDebugUIEnabled())
</span><span class="cx">                 return;
</span></span></pre></div>
<a id="trunkSourceWebInspectorUIUserInterfaceControllersSourceMapManagerjs"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebInspectorUI/UserInterface/Controllers/SourceMapManager.js (199601 => 199602)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebInspectorUI/UserInterface/Controllers/SourceMapManager.js        2016-04-15 18:56:53 UTC (rev 199601)
+++ trunk/Source/WebInspectorUI/UserInterface/Controllers/SourceMapManager.js        2016-04-15 19:01:39 UTC (rev 199602)
</span><span class="lines">@@ -44,6 +44,11 @@
</span><span class="cx"> 
</span><span class="cx">     downloadSourceMap(sourceMapURL, baseURL, originalSourceCode)
</span><span class="cx">     {
</span><ins>+        // The baseURL could have come from a &quot;//# sourceURL&quot;. Attempt to get a
+        // reasonable absolute URL for the base by using the main resource's URL.
+        if (WebInspector.frameResourceManager.mainFrame)
+            baseURL = absoluteURL(WebInspector.frameResourceManager.mainFrame.url, baseURL);
+
</ins><span class="cx">         sourceMapURL = absoluteURL(sourceMapURL, baseURL);
</span><span class="cx">         if (!sourceMapURL)
</span><span class="cx">             return;
</span></span></pre></div>
<a id="trunkSourceWebInspectorUIUserInterfaceModelsScriptjs"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebInspectorUI/UserInterface/Models/Script.js (199601 => 199602)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebInspectorUI/UserInterface/Models/Script.js        2016-04-15 18:56:53 UTC (rev 199601)
+++ trunk/Source/WebInspectorUI/UserInterface/Models/Script.js        2016-04-15 19:01:39 UTC (rev 199602)
</span><span class="lines">@@ -25,7 +25,7 @@
</span><span class="cx"> 
</span><span class="cx"> WebInspector.Script = class Script extends WebInspector.SourceCode
</span><span class="cx"> {
</span><del>-    constructor(id, range, url, injected, sourceMapURL)
</del><ins>+    constructor(id, range, url, injected, sourceURL, sourceMapURL)
</ins><span class="cx">     {
</span><span class="cx">         super();
</span><span class="cx"> 
</span><span class="lines">@@ -35,6 +35,7 @@
</span><span class="cx">         this._id = id || null;
</span><span class="cx">         this._range = range || null;
</span><span class="cx">         this._url = url || null;
</span><ins>+        this._sourceURL = sourceURL || null;
</ins><span class="cx">         this._injected = injected || false;
</span><span class="cx"> 
</span><span class="cx">         this._resource = this._resolveResource();
</span><span class="lines">@@ -71,6 +72,11 @@
</span><span class="cx">         return this._url;
</span><span class="cx">     }
</span><span class="cx"> 
</span><ins>+    get sourceURL()
+    {
+        return this._sourceURL;
+    }
+
</ins><span class="cx">     get urlComponents()
</span><span class="cx">     {
</span><span class="cx">         if (!this._urlComponents)
</span><span class="lines">@@ -88,6 +94,12 @@
</span><span class="cx">         if (this._url)
</span><span class="cx">             return WebInspector.displayNameForURL(this._url, this.urlComponents);
</span><span class="cx"> 
</span><ins>+        if (this._sourceURL) {
+            if (!this._sourceURLComponents)
+                this._sourceURLComponents = parseURL(this._sourceURL);
+            return WebInspector.displayNameForURL(this._sourceURL, this._sourceURLComponents);
+        }
+
</ins><span class="cx">         // Assign a unique number to the script object so it will stay the same.
</span><span class="cx">         if (!this._uniqueDisplayNameNumber)
</span><span class="cx">             this._uniqueDisplayNameNumber = this.constructor._nextUniqueDisplayNameNumber++;
</span></span></pre></div>
<a id="trunkSourceWebInspectorUIUserInterfaceProtocolDebuggerObserverjs"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebInspectorUI/UserInterface/Protocol/DebuggerObserver.js (199601 => 199602)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebInspectorUI/UserInterface/Protocol/DebuggerObserver.js        2016-04-15 18:56:53 UTC (rev 199601)
+++ trunk/Source/WebInspectorUI/UserInterface/Protocol/DebuggerObserver.js        2016-04-15 19:01:39 UTC (rev 199602)
</span><span class="lines">@@ -25,6 +25,11 @@
</span><span class="cx"> 
</span><span class="cx"> WebInspector.DebuggerObserver = class DebuggerObserver
</span><span class="cx"> {
</span><ins>+    constructor()
+    {
+        this._legacyScriptParsed = DebuggerAgent.hasEventParameter(&quot;scriptParsed&quot;, &quot;hasSourceURL&quot;);
+    }
+
</ins><span class="cx">     // Events defined by the &quot;Debugger&quot; domain.
</span><span class="cx"> 
</span><span class="cx">     globalObjectCleared()
</span><span class="lines">@@ -32,9 +37,20 @@
</span><span class="cx">         WebInspector.debuggerManager.reset();
</span><span class="cx">     }
</span><span class="cx"> 
</span><del>-    scriptParsed(scriptId, url, startLine, startColumn, endLine, endColumn, isContentScript, sourceMapURL, hasSourceURL)
</del><ins>+    scriptParsed(scriptId, url, startLine, startColumn, endLine, endColumn, isContentScript, sourceURL, sourceMapURL)
</ins><span class="cx">     {
</span><del>-        WebInspector.debuggerManager.scriptDidParse(scriptId, url, isContentScript, startLine, startColumn, endLine, endColumn, sourceMapURL);
</del><ins>+        if (this._legacyScriptParsed) {
+            // COMPATIBILITY (iOS 9): Debugger.scriptParsed had slightly different arguments.
+            // Debugger.scriptParsed: (scriptId, url, startLine, startColumn, endLine, endColumn, isContentScript, sourceMapURL, hasSourceURL)
+            // Note that in this legacy version, url could be the sourceURL name, and the resource URL could be lost.
+            let legacySourceMapURL = arguments[7];
+            let hasSourceURL = arguments[8];
+            let legacySourceURL = hasSourceURL ? url : undefined;
+            WebInspector.debuggerManager.scriptDidParse(scriptId, url, startLine, startColumn, endLine, endColumn, isContentScript, legacySourceURL, legacySourceMapURL);
+            return;
+        }
+
+        WebInspector.debuggerManager.scriptDidParse(scriptId, url, startLine, startColumn, endLine, endColumn, isContentScript, sourceURL, sourceMapURL);
</ins><span class="cx">     }
</span><span class="cx"> 
</span><span class="cx">     scriptFailedToParse(url, scriptSource, startLine, errorLine, errorMessage)
</span></span></pre></div>
<a id="trunkSourceWebInspectorUIUserInterfaceProtocolInspectorBackendjs"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebInspectorUI/UserInterface/Protocol/InspectorBackend.js (199601 => 199602)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebInspectorUI/UserInterface/Protocol/InspectorBackend.js        2016-04-15 18:56:53 UTC (rev 199601)
+++ trunk/Source/WebInspectorUI/UserInterface/Protocol/InspectorBackend.js        2016-04-15 19:01:39 UTC (rev 199602)
</span><span class="lines">@@ -426,6 +426,12 @@
</span><span class="cx">         return eventName in this._events;
</span><span class="cx">     }
</span><span class="cx"> 
</span><ins>+    hasEventParameter(eventName, eventParameterName)
+    {
+        let event = this._events[eventName];
+        return event &amp;&amp; event.parameterNames.includes(eventParameterName);
+    }
+
</ins><span class="cx">     activate()
</span><span class="cx">     {
</span><span class="cx">         this._active = true;
</span></span></pre></div>
<a id="trunkSourceWebInspectorUIUserInterfaceProtocolRemoteObjectjs"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebInspectorUI/UserInterface/Protocol/RemoteObject.js (199601 => 199602)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebInspectorUI/UserInterface/Protocol/RemoteObject.js        2016-04-15 18:56:53 UTC (rev 199601)
+++ trunk/Source/WebInspectorUI/UserInterface/Protocol/RemoteObject.js        2016-04-15 19:01:39 UTC (rev 199602)
</span><span class="lines">@@ -513,7 +513,7 @@
</span><span class="cx">             var location = response.location;
</span><span class="cx">             var sourceCode = WebInspector.debuggerManager.scriptForIdentifier(location.scriptId);
</span><span class="cx"> 
</span><del>-            if (!sourceCode || (!WebInspector.isDebugUIEnabled() &amp;&amp; isWebKitInternalScript(sourceCode.url))) {
</del><ins>+            if (!sourceCode || (!WebInspector.isDebugUIEnabled() &amp;&amp; isWebKitInternalScript(sourceCode.sourceURL))) {
</ins><span class="cx">                 result.resolve(WebInspector.RemoteObject.SourceCodeLocationPromise.NoSourceFound);
</span><span class="cx">                 return;
</span><span class="cx">             }
</span></span></pre></div>
<a id="trunkSourceWebInspectorUIUserInterfaceViewsDebuggerSidebarPaneljs"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebInspectorUI/UserInterface/Views/DebuggerSidebarPanel.js (199601 => 199602)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebInspectorUI/UserInterface/Views/DebuggerSidebarPanel.js        2016-04-15 18:56:53 UTC (rev 199601)
+++ trunk/Source/WebInspectorUI/UserInterface/Views/DebuggerSidebarPanel.js        2016-04-15 19:01:39 UTC (rev 199602)
</span><span class="lines">@@ -428,7 +428,7 @@
</span><span class="cx">     _addScript(script)
</span><span class="cx">     {
</span><span class="cx">         // COMPATIBILITY(iOS 9): Backends could send the frontend built-in code, filter out JSC internals.
</span><del>-        if (!script.url)
</del><ins>+        if (!script.url &amp;&amp; !script.sourceURL)
</ins><span class="cx">             return;
</span><span class="cx"> 
</span><span class="cx">         // Don't add breakpoints if the script is represented by a Resource. They were
</span></span></pre></div>
<a id="trunkSourceWebInspectorUIUserInterfaceViewsResourceSidebarPaneljs"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebInspectorUI/UserInterface/Views/ResourceSidebarPanel.js (199601 => 199602)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebInspectorUI/UserInterface/Views/ResourceSidebarPanel.js        2016-04-15 18:56:53 UTC (rev 199601)
+++ trunk/Source/WebInspectorUI/UserInterface/Views/ResourceSidebarPanel.js        2016-04-15 19:01:39 UTC (rev 199602)
</span><span class="lines">@@ -275,7 +275,7 @@
</span><span class="cx"> 
</span><span class="cx">         // We don't add scripts without URLs here. Those scripts can quickly clutter the interface and
</span><span class="cx">         // are usually more transient. They will get added if/when they need to be shown in a content view.
</span><del>-        if (!script.url)
</del><ins>+        if (!script.url &amp;&amp; !script.sourceURL)
</ins><span class="cx">             return;
</span><span class="cx"> 
</span><span class="cx">         // If the script URL matches a resource we can assume it is part of that resource and does not need added.
</span></span></pre>
</div>
</div>

</body>
</html>