Unreviewed, rolling out r127427.
authorcommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 3 Sep 2012 17:16:28 +0000 (17:16 +0000)
committercommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 3 Sep 2012 17:16:28 +0000 (17:16 +0000)
http://trac.webkit.org/changeset/127427
https://bugs.webkit.org/show_bug.cgi?id=95695

Breaks some inspector/debugger tests on JSC (Requested by
vsevik on #webkit).

Patch by Sheriff Bot <webkit.review.bot@gmail.com> on 2012-09-03

Source/WebCore:

* WebCore.gypi:
* WebCore.vcproj/WebCore.vcproj:
* inspector/compile-front-end.py:
* inspector/front-end/CompilerScriptMapping.js:
* inspector/front-end/JavaScriptSource.js:
(WebInspector.JavaScriptSource):
* inspector/front-end/NetworkUISourceCodeProvider.js: Removed.
* inspector/front-end/RawSourceCode.js:
(WebInspector.RawSourceCode):
(WebInspector.RawSourceCode.prototype.addScript):
(WebInspector.RawSourceCode.prototype.rawLocationToUILocation):
(WebInspector.RawSourceCode.prototype._createUISourceCode):
(WebInspector.RawSourceCode.prototype.uiLocationToRawLocation):
(WebInspector.RawSourceCode.prototype.uiSourceCode):
(WebInspector.RawSourceCode.prototype._finishedLoading):
* inspector/front-end/ResourceScriptMapping.js:
(WebInspector.ResourceScriptMapping):
(WebInspector.ResourceScriptMapping.prototype.rawLocationToUILocation):
(WebInspector.ResourceScriptMapping.prototype.addScript):
(WebInspector.ResourceScriptMapping.prototype._shouldBindScriptToContentProvider):
(WebInspector.ResourceScriptMapping.prototype._handleUISourceCodeChanged):
(WebInspector.ResourceScriptMapping.prototype._uiSourceCodeAdded):
(WebInspector.ResourceScriptMapping.prototype._uiSourceCodeReplaced):
(WebInspector.ResourceScriptMapping.prototype._uiSourceCodeRemoved):
(WebInspector.ResourceScriptMapping.prototype._bindScriptToRawSourceCode):
(WebInspector.ResourceScriptMapping.prototype._reset):
* inspector/front-end/ScriptSnippetModel.js:
(WebInspector.ScriptSnippetModel.prototype._addScriptSnippet):
(WebInspector.ScriptSnippetModel.prototype._createUISourceCodeForScript):
(WebInspector.SnippetJavaScriptSource):
* inspector/front-end/StylesUISourceCodeProvider.js: Added.
(WebInspector.StylesUISourceCodeProvider):
(WebInspector.StylesUISourceCodeProvider.prototype._populate):
(WebInspector.StylesUISourceCodeProvider.prototype._resourceAdded):
(WebInspector.StylesUISourceCodeProvider.prototype._reset):
* inspector/front-end/UISourceCode.js:
(WebInspector.UISourceCode):
(WebInspector.UISourceCode.prototype.uiLocationToRawLocation):
* inspector/front-end/WebKit.qrc:
* inspector/front-end/inspector.html:
* inspector/front-end/inspector.js:

LayoutTests:

* http/tests/inspector/network/network-request-revision-content.html:
* http/tests/inspector/workspace-test.js: Removed.
* inspector/debugger/breakpoint-manager.html:
* inspector/debugger/dynamic-script-tag-expected.txt:
* inspector/debugger/dynamic-script-tag.html:
* inspector/debugger/network-uisourcecode-provider-expected.txt: Removed.
* inspector/debugger/network-uisourcecode-provider.html: Removed.
* inspector/debugger/raw-source-code-expected.txt: Added.
* inspector/debugger/raw-source-code.html: Added.
* inspector/debugger/resource-script-mapping-expected.txt: Removed.
* inspector/debugger/resource-script-mapping.html: Removed.
* inspector/debugger/scripts-panel.html:

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@127429 268f45cc-cd09-0410-ab3c-d52691b4dbfc

27 files changed:
LayoutTests/ChangeLog
LayoutTests/http/tests/inspector/network/network-request-revision-content.html
LayoutTests/http/tests/inspector/workspace-test.js [deleted file]
LayoutTests/inspector/debugger/breakpoint-manager.html
LayoutTests/inspector/debugger/dynamic-script-tag-expected.txt
LayoutTests/inspector/debugger/dynamic-script-tag.html
LayoutTests/inspector/debugger/network-uisourcecode-provider-expected.txt [deleted file]
LayoutTests/inspector/debugger/network-uisourcecode-provider.html [deleted file]
LayoutTests/inspector/debugger/raw-source-code-expected.txt [new file with mode: 0644]
LayoutTests/inspector/debugger/raw-source-code.html [new file with mode: 0644]
LayoutTests/inspector/debugger/resource-script-mapping-expected.txt [deleted file]
LayoutTests/inspector/debugger/resource-script-mapping.html [deleted file]
LayoutTests/inspector/debugger/scripts-panel.html
Source/WebCore/ChangeLog
Source/WebCore/WebCore.gypi
Source/WebCore/WebCore.vcproj/WebCore.vcproj
Source/WebCore/inspector/compile-front-end.py
Source/WebCore/inspector/front-end/CompilerScriptMapping.js
Source/WebCore/inspector/front-end/JavaScriptSource.js
Source/WebCore/inspector/front-end/RawSourceCode.js
Source/WebCore/inspector/front-end/ResourceScriptMapping.js
Source/WebCore/inspector/front-end/ScriptSnippetModel.js
Source/WebCore/inspector/front-end/StylesUISourceCodeProvider.js [moved from Source/WebCore/inspector/front-end/NetworkUISourceCodeProvider.js with 61% similarity]
Source/WebCore/inspector/front-end/UISourceCode.js
Source/WebCore/inspector/front-end/WebKit.qrc
Source/WebCore/inspector/front-end/inspector.html
Source/WebCore/inspector/front-end/inspector.js

index 9fd13c3..a3ce38a 100644 (file)
@@ -1,3 +1,25 @@
+2012-09-03  Sheriff Bot  <webkit.review.bot@gmail.com>
+
+        Unreviewed, rolling out r127427.
+        http://trac.webkit.org/changeset/127427
+        https://bugs.webkit.org/show_bug.cgi?id=95695
+
+        Breaks some inspector/debugger tests on JSC (Requested by
+        vsevik on #webkit).
+
+        * http/tests/inspector/network/network-request-revision-content.html:
+        * http/tests/inspector/workspace-test.js: Removed.
+        * inspector/debugger/breakpoint-manager.html:
+        * inspector/debugger/dynamic-script-tag-expected.txt:
+        * inspector/debugger/dynamic-script-tag.html:
+        * inspector/debugger/network-uisourcecode-provider-expected.txt: Removed.
+        * inspector/debugger/network-uisourcecode-provider.html: Removed.
+        * inspector/debugger/raw-source-code-expected.txt: Added.
+        * inspector/debugger/raw-source-code.html: Added.
+        * inspector/debugger/resource-script-mapping-expected.txt: Removed.
+        * inspector/debugger/resource-script-mapping.html: Removed.
+        * inspector/debugger/scripts-panel.html:
+
 2012-09-03  Vsevolod Vlasov  <vsevik@chromium.org>
 
         Web Inspector: Create JavaScriptSources based on network resources.
index e7d39b5..d6837c6 100644 (file)
@@ -14,7 +14,7 @@ function loadStylesheet()
 function test()
 {
     InspectorTest.addConsoleSniffer(step2, true);
-    InspectorTest.addSniffer(WebInspector.NetworkUISourceCodeProvider.prototype, "_resourceAdded", true);
+    InspectorTest.addSniffer(WebInspector.StylesUISourceCodeProvider.prototype, "_resourceAdded", true);
     InspectorTest.evaluateInPage("loadStylesheet()");
 
     var resource;
diff --git a/LayoutTests/http/tests/inspector/workspace-test.js b/LayoutTests/http/tests/inspector/workspace-test.js
deleted file mode 100644 (file)
index 4ba7367..0000000
+++ /dev/null
@@ -1,68 +0,0 @@
-var initialize_WorkspaceTest = function() {
-
-InspectorTest.testWorkspace;
-InspectorTest.createWorkspace = function()
-{
-    InspectorTest.testWorkspace = new WebInspector.Workspace();
-    InspectorTest.testWorkspace.addEventListener(WebInspector.UISourceCodeProvider.Events.UISourceCodeAdded, InspectorTest._defaultUISourceCodeProviderEventHandler);
-    InspectorTest.testWorkspace.addEventListener(WebInspector.UISourceCodeProvider.Events.UISourceCodeReplaced, InspectorTest._defaultUISourceCodeProviderEventHandler);
-    InspectorTest.testWorkspace.addEventListener(WebInspector.UISourceCodeProvider.Events.UISourceCodeRemoved, InspectorTest._defaultUISourceCodeProviderEventHandler);
-}
-
-InspectorTest.waitForWorkspaceUISourceCodeReplacedEvent = function(callback)
-{
-    InspectorTest.testWorkspace.removeEventListener(WebInspector.UISourceCodeProvider.Events.UISourceCodeReplaced, InspectorTest._defaultUISourceCodeProviderEventHandler);
-    InspectorTest.testWorkspace.addEventListener(WebInspector.UISourceCodeProvider.Events.UISourceCodeReplaced, uiSourceCodeReplaced);
-
-    function uiSourceCodeReplaced(event)
-    {
-        InspectorTest.testWorkspace.removeEventListener(WebInspector.UISourceCodeProvider.Events.UISourceCodeReplaced, uiSourceCodeReplaced);
-        InspectorTest.testWorkspace.addEventListener(WebInspector.UISourceCodeProvider.Events.UISourceCodeReplaced, InspectorTest._defaultUISourceCodeProviderEventHandler);
-        callback(event.data.uiSourceCode, event.data.oldUISourceCode);
-    }
-}
-
-InspectorTest.waitForWorkspaceUISourceCodeAddedEvent = function(callback)
-{
-    InspectorTest.testWorkspace.removeEventListener(WebInspector.UISourceCodeProvider.Events.UISourceCodeAdded, InspectorTest._defaultUISourceCodeProviderEventHandler);
-    InspectorTest.testWorkspace.addEventListener(WebInspector.UISourceCodeProvider.Events.UISourceCodeAdded, uiSourceCodeAdded);
-
-    function uiSourceCodeAdded(event)
-    {
-        InspectorTest.testWorkspace.removeEventListener(WebInspector.UISourceCodeProvider.Events.UISourceCodeAdded, uiSourceCodeAdded);
-        InspectorTest.testWorkspace.addEventListener(WebInspector.UISourceCodeProvider.Events.UISourceCodeAdded, InspectorTest._defaultUISourceCodeProviderEventHandler);
-        callback(event.data);
-    }
-}
-
-InspectorTest.addMockUISourceCodeToWorkspace = function(url, type, content)
-{
-    var isDocument = type === WebInspector.resourceTypes.Document;
-    var mockContentProvider = new WebInspector.StaticContentProvider(type, content);
-    var uiSourceCode = new WebInspector.JavaScriptSource(url, null, mockContentProvider, !isDocument);
-    InspectorTest.testWorkspace.project().addUISourceCode(uiSourceCode);
-}
-
-InspectorTest._defaultUISourceCodeProviderEventHandler = function(event)
-{
-    throw new Error("Unexpected UISourceCodeProvider event: " + event.type + ".");
-}
-
-InspectorTest.dumpUISourceCode = function(uiSourceCode, callback)
-{
-    InspectorTest.addResult("UISourceCode: " + uiSourceCode.url);
-    if (uiSourceCode instanceof WebInspector.JavaScriptSource) {
-        InspectorTest.addResult("UISourceCode is editable: " + uiSourceCode._isEditable);
-        InspectorTest.addResult("UISourceCode is content script: " + uiSourceCode.isContentScript);
-    }
-    uiSourceCode.requestContent(didRequestContent);
-
-    function didRequestContent(content, contentEncoded, mimeType)
-    {
-        InspectorTest.addResult("Mime type: " + mimeType);
-        InspectorTest.addResult("UISourceCode content: " + content);
-        callback();
-    }
-}
-
-};
index c3db09e..fb3d0d7 100644 (file)
@@ -111,8 +111,7 @@ function test()
     WorkspaceMock.prototype = {
         _addUISourceCode: function(url)
         {
-            var uiSourceCode = new WebInspector.JavaScriptSource(url, null, null, false);
-            uiSourceCode.setSourceMapping(defaultMapping);
+            var uiSourceCode = new WebInspector.JavaScriptSource(url, null, null, defaultMapping, false);
             uiSourceCodes[url] = uiSourceCode;
             this.dispatchEventToListeners(WebInspector.UISourceCodeProvider.Events.UISourceCodeAdded, uiSourceCode);
             return uiSourceCode;
index 7615330..6930c8f 100644 (file)
@@ -1,28 +1,12 @@
-Tests that inline scripts and document.write scripts get different uiSourceCodes with different URLs. Bug 87119
+CONSOLE MESSAGE: line 1: 123
+Tests that dynamically added script tag gets its own JavaScriptSource and is not bound to the resource. Bug 87119
 
 Debugger was enabled.
-Dumping scripts:
-script1: file:///usr/local/google/home/vsevik/chromium/src/third_party/WebKit/LayoutTests/inspector/debugger/dynamic-script-tag.html
-Is anonymous:false
-Is inline script:true
-script2: file:///usr/local/google/home/vsevik/chromium/src/third_party/WebKit/LayoutTests/inspector/debugger/dynamic-script-tag.html
-Is anonymous:false
-Is inline script:false
-script3: file:///usr/local/google/home/vsevik/chromium/src/third_party/WebKit/LayoutTests/inspector/debugger/dynamic-script-tag.html
 Is anonymous:false
 Is inline script:false
-Dumping uiSourceCodes:
-UISourceCode: file:///usr/local/google/home/vsevik/chromium/src/third_party/WebKit/LayoutTests/inspector/debugger/dynamic-script-tag.html (1)
-UISourceCode is editable: true
-UISourceCode is content script: false
-Mime type: text/javascript
-UISourceCode content: function bar() { }
-UI resource: null
-UISourceCode: file:///usr/local/google/home/vsevik/chromium/src/third_party/WebKit/LayoutTests/inspector/debugger/dynamic-script-tag.html (2)
-UISourceCode is editable: true
-UISourceCode is content script: false
-Mime type: text/javascript
-UISourceCode content: function foo() { }
+dynamic-script-tag.html
+UI name: dynamic-script-tag.html
 UI resource: null
+UI content: console.log(123)
 Debugger was disabled.
 
index 527987b..b45368c 100644 (file)
@@ -2,79 +2,51 @@
 <head>
 <script src="../../http/tests/inspector/inspector-test.js"></script>
 <script src="../../http/tests/inspector/debugger-test.js"></script>
-<script src="../../http/tests/inspector/workspace-test.js"></script>
+
 <script>
-document.write("<scrip" + "t>function foo() { }</sc" + "ript>");
-var scriptElement = document.createElement("script");
-scriptElement.textContent = "function bar() { }";
-document.head.appendChild(scriptElement);
 
-var test = function()
+function createScriptTag()
+{
+    var script = document.createElement("script");
+    script.innerHTML = "console.log(123)";
+    document.head.appendChild(script);
+}
+
+function test()
 {
     InspectorTest.startDebuggerTest(step1);
 
     function step1()
     {
-        var model = WebInspector.debuggerModel;
-
-        var scripts = Object.values(WebInspector.debuggerModel.scripts);
-        function filterOutStandaloneScripts(script)
-        {
-            return script.sourceURL.indexOf("dynamic-script-tag.html") !== -1;
-        }
-        scripts = scripts.filter(filterOutStandaloneScripts);
+        InspectorTest.evaluateInPage("createScriptTag()");
+        WebInspector.debuggerModel.addEventListener(WebInspector.DebuggerModel.Events.ParsedScriptSource, step2);
+    }
 
-        function compareScriptFunction(script1, script2)
+    function step2(event)
+    {
+        var script = event.data;
+        script.requestContent(callback);
+        function callback(content)
         {
-            return script1.sourceURL.localeCompare(script2.sourceURL);
-        }
-        scripts.sort(compareScriptFunction);
-        InspectorTest.assertEquals(3, scripts.length, "Wrong scripts count.");
-
-        var uiSourceCodes = [];
-        InspectorTest.addResult("Dumping scripts:");
-        for (var i = 0; i < scripts.length; ++i) {
-            var script = scripts[i];
-            InspectorTest.addResult("script" + (i+1) + ": " + script.sourceURL);
+            if (content !== "console.log(123)")
+                return;
             InspectorTest.addResult("Is anonymous:" + script.isAnonymousScript());
             InspectorTest.addResult("Is inline script:" + script.isInlineScript());
-            if (!script.isInlineScript())
-                uiSourceCodes.push(script.rawLocationToUILocation(0, 0).uiSourceCode);
-        }
-
-        function compareUISourceCodeFunction(uiSourceCode1, uiSourceCode2)
-        {
-            return uiSourceCode1.url.localeCompare(uiSourceCode2.url);
+            InspectorTest.addResult(new WebInspector.ParsedURL(script.sourceURL).displayName);
+            // Invoke post source map install.
+            setTimeout(step3.bind(this, script), 0);
         }
-        uiSourceCodes.sort(compareUISourceCodeFunction);
-
-        var seenUISourceCodes = new Map();
-        InspectorTest.assertEquals(2, uiSourceCodes.length, "Wrong uiSourceCodes count.");
-        InspectorTest.addResult("Dumping uiSourceCodes:");
-        
-        var index = 0;
-        dumpNextUISourceCode();
-        function dumpNextUISourceCode()
-        {
-            if (index >= uiSourceCodes.length) {
-                uiSourceCodesDumped();
-                return;
-            }
-            var uiSourceCode = uiSourceCodes[index];
-            InspectorTest.dumpUISourceCode(uiSourceCode, uiSourceCodeDumped);
+    }
 
-            function uiSourceCodeDumped()
-            {
-                InspectorTest.addResult("UI resource: " + uiSourceCode.resource());
-                InspectorTest.assertTrue(!seenUISourceCodes.get(uiSourceCode), "UISourceCode matches two scripts: " + uiSourceCode.url);
-                seenUISourceCodes.put(uiSourceCode, uiSourceCode);
-                ++index;
-                dumpNextUISourceCode();
-            }
-        }
-        
-        function uiSourceCodesDumped()
+    function step3(script)
+    {
+        var uiLocation = script.rawLocationToUILocation(0, 0);
+        InspectorTest.addResult("UI name: " + uiLocation.uiSourceCode.parsedURL.displayName);
+        InspectorTest.addResult("UI resource: " + uiLocation.uiSourceCode.resource());
+        uiLocation.uiSourceCode.requestContent(callback);
+        function callback(content)
         {
+            InspectorTest.addResult("UI content: " + content);
             InspectorTest.completeDebuggerTest();
         }
     }
@@ -82,7 +54,10 @@ var test = function()
 </script>
 </head>
 <body onload="runTest()">
-<p>Tests that inline scripts and document.write scripts get different uiSourceCodes with different URLs.
+<p>
+Tests that dynamically added script tag gets its own JavaScriptSource and is not bound to the resource.
 <a href="https://bugs.webkit.org/show_bug.cgi?id=87119">Bug 87119</a>
+</p>
 </body>
+
 </html>
diff --git a/LayoutTests/inspector/debugger/network-uisourcecode-provider-expected.txt b/LayoutTests/inspector/debugger/network-uisourcecode-provider-expected.txt
deleted file mode 100644 (file)
index 04991f2..0000000
+++ /dev/null
@@ -1,50 +0,0 @@
-Tests NetworkUISourceCodeProvider class.
-
-
-Running: testDocumentResourceWithPendingRequest
-Creating request.
-Finishing request.
-UISourceCode: http://fake.url/2
-UISourceCode is editable: false
-UISourceCode is content script: false
-Mime type: text/html
-UISourceCode content: <document request content>
-
-Running: testDocumentResource
-Creating resource.
-UISourceCode: http://fake.url/3
-UISourceCode is editable: false
-UISourceCode is content script: false
-Mime type: text/html
-UISourceCode content: <document resource content>
-
-Running: testScriptResourceWithPendingRequest
-Creating request.
-Finishing request.
-UISourceCode: http://fake.url/4
-UISourceCode is editable: true
-UISourceCode is content script: false
-Mime type: text/javascript
-UISourceCode content: <script request content>
-
-Running: testScriptResource
-Creating resource.
-UISourceCode: http://fake.url/5
-UISourceCode is editable: true
-UISourceCode is content script: false
-Mime type: text/javascript
-UISourceCode content: <script resource content>
-
-Running: testStylesheetResourceWithPendingRequest
-Creating request.
-UISourceCode: http://fake.url/6
-Finishing request.
-Mime type: text/css
-UISourceCode content: <stylesheet request content>
-
-Running: testStylesheetResource
-Creating resource.
-UISourceCode: http://fake.url/7
-Mime type: text/css
-UISourceCode content: <stylesheet resource content>
-
diff --git a/LayoutTests/inspector/debugger/network-uisourcecode-provider.html b/LayoutTests/inspector/debugger/network-uisourcecode-provider.html
deleted file mode 100644 (file)
index 9d927f6..0000000
+++ /dev/null
@@ -1,173 +0,0 @@
-<html>
-<head>
-<script src="../../http/tests/inspector/inspector-test.js"></script>
-<script src="../../http/tests/inspector/debugger-test.js"></script>
-<script src="../../http/tests/inspector/workspace-test.js"></script>
-<script>
-function test()
-{
-    var mockContentsMap = {};
-    var lastResouceId = 1;
-
-    NetworkAgent.getResponseBody = function(requestId, callback)
-    {
-        callback(undefined, mockContentsMap[requestId], false);
-    }
-
-    PageAgent.getResourceContent = function(frameId, url, callback)
-    {
-        callback(undefined, mockContentsMap[url], false);
-    }
-
-    function createResourceMock(type, withPendingRequest, content)
-    {
-        var documentURL = "http://fake.url";
-        var resourceId = ++lastResouceId + "";
-        var url = documentURL + "/" + resourceId;
-        var frameId = "frame-id";
-        var loaderId = "loader-id";
-        var mimeType;
-        switch (type) {
-        case WebInspector.resourceTypes.Document:
-            mimeType = "text/html";
-            break;
-        case WebInspector.resourceTypes.Script:
-            mimeType = "text/javascript";
-            break;
-        case WebInspector.resourceTypes.Stylesheet:
-            mimeType = "text/css";
-            break;
-        }
-
-        if (withPendingRequest) {
-            var request = new WebInspector.NetworkRequest(resourceId, url, "http://fake.url", frameId, loaderId);
-            request.type = type;
-            request.mimeType = mimeType;
-            mockContentsMap[resourceId] = content;
-        }
-        var resource = new WebInspector.Resource(request, url, documentURL, frameId, loaderId, type, mimeType);
-        mockContentsMap[url] = content;
-        WebInspector.resourceTreeModel.dispatchEventToListeners(WebInspector.ResourceTreeModel.EventTypes.ResourceAdded, resource);
-
-        return resource;
-    }
-
-    function finishResource(resource)
-    {
-        resource.request.finished = true;
-        resource.request.dispatchEventToListeners(WebInspector.NetworkRequest.Events.FinishedLoading, resource.request);
-    }
-
-    function createNetworkUISourceCodeProvider()
-    {
-        InspectorTest.createWorkspace();
-        WebInspector.resourceTreeModel = new WebInspector.Object();
-        var networkUISourceCodeProvider = new WebInspector.NetworkUISourceCodeProvider(InspectorTest.testWorkspace);
-        return networkUISourceCodeProvider;
-    }
-
-    InspectorTest.runTestSuite([
-        function testDocumentResourceWithPendingRequest(next)
-        {
-            var networkUISourceCodeProvider = createNetworkUISourceCodeProvider();
-
-            InspectorTest.addResult("Creating request.");
-            var resource = createResourceMock(WebInspector.resourceTypes.Document, true, "<document request content>");
-
-            InspectorTest.waitForWorkspaceUISourceCodeAddedEvent(uiSourceCodeAdded);
-            InspectorTest.addResult("Finishing request.");
-            finishResource(resource);
-
-            function uiSourceCodeAdded(uiSourceCode)
-            {
-                InspectorTest.dumpUISourceCode(uiSourceCode, next);
-            }
-        },
-
-        function testDocumentResource(next)
-        {
-            var networkUISourceCodeProvider = createNetworkUISourceCodeProvider();
-            InspectorTest.addResult("Creating resource.");
-            InspectorTest.waitForWorkspaceUISourceCodeAddedEvent(uiSourceCodeAdded);
-            var resource = createResourceMock(WebInspector.resourceTypes.Document, false, "<document resource content>");
-
-            function uiSourceCodeAdded(uiSourceCode)
-            {
-                InspectorTest.dumpUISourceCode(uiSourceCode, next);
-            }
-        },
-
-        function testScriptResourceWithPendingRequest(next)
-        {
-            var networkUISourceCodeProvider = createNetworkUISourceCodeProvider();
-
-            InspectorTest.addResult("Creating request.");
-            var resource = createResourceMock(WebInspector.resourceTypes.Script, true, "<script request content>");
-
-            InspectorTest.waitForWorkspaceUISourceCodeAddedEvent(uiSourceCodeAdded);
-            InspectorTest.addResult("Finishing request.");
-            finishResource(resource);
-
-            function uiSourceCodeAdded(uiSourceCode)
-            {
-                InspectorTest.dumpUISourceCode(uiSourceCode, next);
-            }
-        },
-
-        function testScriptResource(next)
-        {
-            var networkUISourceCodeProvider = createNetworkUISourceCodeProvider();
-            InspectorTest.addResult("Creating resource.");
-            InspectorTest.waitForWorkspaceUISourceCodeAddedEvent(uiSourceCodeAdded);
-            var resource = createResourceMock(WebInspector.resourceTypes.Script, false, "<script resource content>");
-
-            function uiSourceCodeAdded(uiSourceCode)
-            {
-                InspectorTest.dumpUISourceCode(uiSourceCode, next);
-            }
-        },
-
-        function testStylesheetResourceWithPendingRequest(next)
-        {
-            var endTestCallsLeft = 2;
-            var networkUISourceCodeProvider = createNetworkUISourceCodeProvider();
-            InspectorTest.waitForWorkspaceUISourceCodeAddedEvent(uiSourceCodeAdded);
-            InspectorTest.addResult("Creating request.");
-            var resource = createResourceMock(WebInspector.resourceTypes.Stylesheet, true, "<stylesheet request content>");
-            InspectorTest.addResult("Finishing request.");
-            finishResource(resource);
-            endTest();
-
-            function uiSourceCodeAdded(uiSourceCode)
-            {
-                InspectorTest.dumpUISourceCode(uiSourceCode, endTest);
-            }
-
-            function endTest()
-            {
-                if (--endTestCallsLeft)
-                    return;
-                next();
-            }
-        },
-
-        function testStylesheetResource(next)
-        {
-            var networkUISourceCodeProvider = createNetworkUISourceCodeProvider();
-            InspectorTest.addResult("Creating resource.");
-            InspectorTest.waitForWorkspaceUISourceCodeAddedEvent(uiSourceCodeAdded);
-            var resource = createResourceMock(WebInspector.resourceTypes.Stylesheet, false, "<stylesheet resource content>");
-
-            function uiSourceCodeAdded(uiSourceCode)
-            {
-                InspectorTest.dumpUISourceCode(uiSourceCode, next);
-            }
-        },
-    ]);
-};
-</script>
-</head>
-<body onload="runTest()">
-<p>Tests NetworkUISourceCodeProvider class.</p>
-</body>
-</html>
diff --git a/LayoutTests/inspector/debugger/raw-source-code-expected.txt b/LayoutTests/inspector/debugger/raw-source-code-expected.txt
new file mode 100644 (file)
index 0000000..e071806
--- /dev/null
@@ -0,0 +1,32 @@
+Tests RawSourceCode class.
+
+
+Running: testScriptWithoutResource
+UISourceCode: foo.js
+UISourceCode is content script: true
+Mime type: text/javascript
+Script source: <script source>
+
+Running: testHTMLWithPendingResource
+Adding first script for pending request.
+UISourceCode: index.html
+UISourceCode is content script: false
+Mime type: text/html
+Script source:   <script><script source 1></script>
+Adding second script for pending request.
+UISourceCode: index.html
+UISourceCode is content script: false
+Mime type: text/html
+Script source:   <script><script source 1></script> <script><script source 2></script>
+Finishing request.
+UISourceCode: index.html
+UISourceCode is content script: false
+Mime type: text/html
+Script source: <resource content>
+
+Running: testHTMLWithFinishedResource
+UISourceCode: index.html
+UISourceCode is content script: false
+Mime type: text/html
+Script source: <resource content>
+
diff --git a/LayoutTests/inspector/debugger/raw-source-code.html b/LayoutTests/inspector/debugger/raw-source-code.html
new file mode 100644 (file)
index 0000000..4532b8e
--- /dev/null
@@ -0,0 +1,224 @@
+<html>
+<head>
+<script src="../../http/tests/inspector/inspector-test.js"></script>
+<script src="../../http/tests/inspector/debugger-test.js"></script>
+
+<script>
+
+function test()
+{
+    var mockContentsMap = {};
+    var lastRequestId = 1;
+
+    NetworkAgent.getResponseBody = function(requestId, callback)
+    {
+        callback(undefined, mockContentsMap[requestId], false);
+    }
+
+    PageAgent.getResourceContent = function(frameId, url, callback)
+    {
+        callback(undefined, mockContentsMap[url], false);
+    }
+
+    function createRequestMock(type, finished, content)
+    {
+        var requestId = ++lastRequestId + "";
+        var url = "http://fake.url/" + requestId;
+        WebInspector.resourceTreeModel._addFrame(new WebInspector.ResourceTreeFrame(WebInspector.resourceTreeModel, null, {id: "frame-id"}));
+        var request = new WebInspector.NetworkRequest(requestId, url, "http://fake.url", "frame-id", "loader-id");
+        request.type = type === "document" ? WebInspector.resourceTypes.Document : WebInspector.resourceTypes.Script;
+        request.mimeType = type === "document" ? "text/html" : "text/javascript";
+
+        WebInspector.networkManager._dispatcher._startNetworkRequest(request);
+        if (finished)
+            finishRequest(request);
+
+        mockContentsMap[requestId] = content;
+        mockContentsMap[url] = content;
+        return request;
+    }
+
+    function finishRequest(request) { WebInspector.networkManager._dispatcher._updateNetworkRequest(request); WebInspector.networkManager._dispatcher._finishNetworkRequest(request); }
+    function createPendingRequestMock(type, content) { return createRequestMock(type, false, content); }
+    function createFinishedRequestMock(type, content) { return createRequestMock(type, true, content); }
+
+    function createScriptFormatterMock()
+    {
+        var mapping = {
+            originalToFormatted: function(lineNumber, columnNumber) { return [lineNumber * 2, columnNumber * 2]; },
+            formattedToOriginal: function(lineNumber, columnNumber) { return [Math.floor(lineNumber / 2), Math.floor(columnNumber / 2)]; }
+        };
+        var formatter = {
+            formatContent: function(mimeType, content, callback) { formatter._callback = callback.bind(null, "<formatted> " + content, mapping); },
+            finish: function() { formatter._callback(); }
+        };
+        return formatter;
+    };
+
+    function createRawSourceCode(script, request, compilerSourceMapping)
+    {
+        var resource = null;
+        if (request && request.finished) {
+            resource = WebInspector.resourceForURL(request.url)
+            request = null;
+        }
+        var rawSourceCode = new WebInspector.RawSourceCode("id", script, resource, request, compilerSourceMapping);
+        rawSourceCode.addEventListener(WebInspector.RawSourceCode.Events.UISourceCodeChanged, defaultUISourceCodeChangedHandler);
+        return rawSourceCode;
+    }
+
+    function waitForUISourceCodeChangedEvent(rawSourceCode, callback)
+    {
+        rawSourceCode.removeEventListener(WebInspector.RawSourceCode.Events.UISourceCodeChanged, defaultUISourceCodeChangedHandler);
+        rawSourceCode.addEventListener(WebInspector.RawSourceCode.Events.UISourceCodeChanged, uiSourceCodeChanged);
+        function uiSourceCodeChanged(event)
+        {
+            rawSourceCode.removeEventListener(WebInspector.RawSourceCode.Events.UISourceCodeChanged, uiSourceCodeChanged);
+            rawSourceCode.addEventListener(WebInspector.RawSourceCode.Events.UISourceCodeChanged, defaultUISourceCodeChangedHandler);
+            callback(event);
+        }
+    }
+
+    function defaultUISourceCodeChangedHandler()
+    {
+        throw new Error("Unexpected UISourceCodeChanged event.");
+    }
+
+    function createRawLocation(lineNumber, columnNumber)
+    {
+        return { lineNumber: lineNumber, columnNumber: columnNumber };
+    }
+
+    InspectorTest.runTestSuite([
+        function testScriptWithoutResource(next)
+        {
+            WebInspector.debuggerModel._reset();
+            var script = InspectorTest.createScriptMock("foo.js", 0, 0, true, "<script source>");
+            var rawSourceCode = createRawSourceCode(script, null);
+
+            var uiSourceCode = rawSourceCode.uiSourceCode();
+            InspectorTest.addResult("UISourceCode: " + rawSourceCode.uiSourceCode().url);
+            InspectorTest.addResult("UISourceCode is content script: " + uiSourceCode.isContentScript);
+            InspectorTest.checkUILocation(uiSourceCode, 0, 5, rawSourceCode.rawLocationToUILocation(createRawLocation(0, 5)));
+            InspectorTest.checkRawLocation(script, 10, 0, rawSourceCode.uiLocationToRawLocation(uiSourceCode, 10, 0));
+            uiSourceCode.requestContent(didRequestContent);
+
+            function didRequestContent(content, contentEncoded, mimeType)
+            {
+                InspectorTest.addResult("Mime type: " + mimeType);
+                InspectorTest.addResult("Script source: " + content);
+                next();
+            }
+        },
+
+        function testHTMLWithPendingResource(next)
+        {
+            WebInspector.debuggerModel._reset();
+            var script1 = InspectorTest.createScriptMock("index.html", 0, 10, false, "<script source 1>");
+            var script2 = InspectorTest.createScriptMock("index.html", 0, 45, false, "<script source 2>");
+            var request = createPendingRequestMock("document", "<resource content>");
+            InspectorTest.addResult("Adding first script for pending request.");
+            var rawSourceCode = createRawSourceCode(script1, request);
+
+            InspectorTest.assertTrue(!rawSourceCode.uiSourceCode());
+
+            waitForUISourceCodeChangedEvent(rawSourceCode, uiSourceCodeAdded);
+            rawSourceCode.rawLocationToUILocation(createRawLocation(0, 10));
+            function uiSourceCodeAdded(event)
+            {
+                InspectorTest.assertTrue(!event.data.oldUISourceCode);
+                InspectorTest.assertTrue(!!rawSourceCode.uiSourceCode());
+                var uiSourceCode = rawSourceCode.uiSourceCode();
+                InspectorTest.addResult("UISourceCode: " + uiSourceCode.url);
+                InspectorTest.addResult("UISourceCode is content script: " + uiSourceCode.isContentScript);
+                uiSourceCode.requestContent(didRequestContent);
+
+                function didRequestContent(content, contentEncoded, mimeType)
+                {
+                    InspectorTest.addResult("Mime type: " + mimeType);
+                    InspectorTest.addResult("Script source: " + content);
+
+                    waitForUISourceCodeChangedEvent(rawSourceCode, uiSourceCodeChangedAfterScriptAdded);
+                    InspectorTest.addResult("Adding second script for pending request.");
+                    rawSourceCode.addScript(script2);
+                  }
+            }
+
+            function uiSourceCodeChangedAfterScriptAdded(event)
+            {
+                InspectorTest.assertTrue(event.data.oldUISourceCode);
+                InspectorTest.assertTrue(!!rawSourceCode.uiSourceCode());
+                var uiSourceCode = rawSourceCode.uiSourceCode();
+                InspectorTest.addResult("UISourceCode: " + uiSourceCode.url);
+                InspectorTest.addResult("UISourceCode is content script: " + uiSourceCode.isContentScript);
+                uiSourceCode.requestContent(didRequestContent);
+
+                function didRequestContent(content, contentEncoded, mimeType)
+                {
+                    InspectorTest.addResult("Mime type: " + mimeType);
+                    InspectorTest.addResult("Script source: " + content);
+
+                    waitForUISourceCodeChangedEvent(rawSourceCode, uiSourceCodeChangedAfterRequestFinished);
+                    InspectorTest.addResult("Finishing request.");
+                    finishRequest(request);
+                }
+              }
+
+            function uiSourceCodeChangedAfterRequestFinished(event)
+            {
+                InspectorTest.assertTrue(event.data.oldUISourceCode);
+                InspectorTest.assertTrue(!!rawSourceCode.uiSourceCode());
+                var uiSourceCode = rawSourceCode.uiSourceCode();
+                InspectorTest.addResult("UISourceCode: " + uiSourceCode.url);
+                InspectorTest.addResult("UISourceCode is content script: " + uiSourceCode.isContentScript);
+                uiSourceCode.requestContent(didRequestContent);
+
+                function didRequestContent(content, contentEncoded, mimeType)
+                {
+                    InspectorTest.addResult("Mime type: " + mimeType);
+                    InspectorTest.addResult("Script source: " + content);
+
+                    next();
+                }
+              }
+        },
+
+        function testHTMLWithFinishedResource(next)
+        {
+            WebInspector.debuggerModel._reset();
+            var script1 = InspectorTest.createScriptMock("index.html", 1, 10, false, "<script source 1>");
+            var script2 = InspectorTest.createScriptMock("index.html", 5, 45, false, "<script\nsource\n2>");
+            var request = createFinishedRequestMock("document", "<resource content>");
+            var rawSourceCode = createRawSourceCode(script1, request);
+
+            InspectorTest.assertTrue(!!rawSourceCode.uiSourceCode());
+            var uiSourceCode = rawSourceCode.uiSourceCode();
+            InspectorTest.addResult("UISourceCode: " + uiSourceCode.url);
+            InspectorTest.addResult("UISourceCode is content script: " + uiSourceCode.isContentScript);
+            uiSourceCode.requestContent(didRequestContent);
+
+            function didRequestContent(content, contentEncoded, mimeType)
+            {
+                InspectorTest.addResult("Mime type: " + mimeType);
+                InspectorTest.addResult("Script source: " + content);
+
+                rawSourceCode.addScript(script2);
+                InspectorTest.checkUILocation(uiSourceCode, 1, 20, rawSourceCode.rawLocationToUILocation(createRawLocation(1, 20)));
+                InspectorTest.checkRawLocation(script1, 1, 0, rawSourceCode.uiLocationToRawLocation(uiSourceCode, 1, 0));
+                InspectorTest.checkRawLocation(script2, 6, 0, rawSourceCode.uiLocationToRawLocation(uiSourceCode, 6, 0));
+
+                next();
+            }
+        }
+    ]);
+};
+
+</script>
+
+</head>
+
+<body onload="runTest()">
+<p>Tests RawSourceCode class.</p>
+
+</body>
+</html>
diff --git a/LayoutTests/inspector/debugger/resource-script-mapping-expected.txt b/LayoutTests/inspector/debugger/resource-script-mapping-expected.txt
deleted file mode 100644 (file)
index afa9c21..0000000
+++ /dev/null
@@ -1,71 +0,0 @@
-Tests ResourceScriptMapping class.
-
-
-Running: testScriptWithPendingResource
-Adding script for pending request.
-UISourceCode: foo.js
-UISourceCode is editable: true
-UISourceCode is content script: true
-Mime type: text/javascript
-UISourceCode content: <content script source>
-Adding uiSourceCode for finished resource.
-UISourceCode: foo.js
-UISourceCode is editable: true
-UISourceCode is content script: true
-Mime type: text/javascript
-UISourceCode content: <content script resource content>
-
-Running: testScriptWithFinishedResource
-Adding uiSourceCode for finished resource.
-UISourceCode: foo.js
-UISourceCode is editable: true
-UISourceCode is content script: false
-Mime type: text/javascript
-UISourceCode content: <script resource content>
-Adding script for finished request.
-UISourceCode: foo.js
-UISourceCode is editable: true
-UISourceCode is content script: false
-Mime type: text/javascript
-UISourceCode content: <script resource content>
-
-Running: testHTMLWithPendingResource
-Adding first script for pending request.
-UISourceCode: index.html
-UISourceCode is editable: false
-UISourceCode is content script: false
-Mime type: text/html
-UISourceCode content:   <script><script source 1></script>
-Adding second script for pending request.
-UISourceCode: index.html
-UISourceCode is editable: false
-UISourceCode is content script: false
-Mime type: text/html
-UISourceCode content:   <script><script source 1></script> <script><script source 2></script>
-Adding uiSourceCode for finished resource.
-UISourceCode: index.html
-UISourceCode is editable: false
-UISourceCode is content script: false
-Mime type: text/html
-UISourceCode content: <resource content>
-
-Running: testHTMLWithFinishedResource
-Adding uiSourceCode for finished resource.
-UISourceCode: index.html
-UISourceCode is editable: false
-UISourceCode is content script: false
-Mime type: text/html
-UISourceCode content: <resource content>
-Adding first script for finished request.
-UISourceCode: index.html
-UISourceCode is editable: false
-UISourceCode is content script: false
-Mime type: text/html
-UISourceCode content: <resource content>
-Adding second script for finished request.
-UISourceCode: index.html
-UISourceCode is editable: false
-UISourceCode is content script: false
-Mime type: text/html
-UISourceCode content: <resource content>
-
diff --git a/LayoutTests/inspector/debugger/resource-script-mapping.html b/LayoutTests/inspector/debugger/resource-script-mapping.html
deleted file mode 100644 (file)
index 69e7d5a..0000000
+++ /dev/null
@@ -1,198 +0,0 @@
-<html>
-<head>
-<script src="../../http/tests/inspector/inspector-test.js"></script>
-<script src="../../http/tests/inspector/debugger-test.js"></script>
-<script src="../../http/tests/inspector/workspace-test.js"></script>
-<script>
-function test()
-{
-    var workspace;
-    function createResourceScriptMapping()
-    {
-        InspectorTest.createWorkspace();
-        var resourceScriptMapping = new WebInspector.ResourceScriptMapping(InspectorTest.testWorkspace);
-        return resourceScriptMapping;
-    }
-
-    InspectorTest.runTestSuite([
-        function testScriptWithPendingResource(next)
-        {
-            var script;
-            WebInspector.debuggerModel._reset();
-            var resourceScriptMapping = createResourceScriptMapping();
-            var url = "foo.js";
-            step1();
-
-            function step1()
-            {
-                InspectorTest.waitForWorkspaceUISourceCodeAddedEvent(uiSourceCodeAdded);
-                InspectorTest.addResult("Adding script for pending request.");
-                script = InspectorTest.createScriptMock(url, 0, 0, true, "<content script source>");
-                resourceScriptMapping.addScript(script);
-            }
-
-            function uiSourceCodeAdded(uiSourceCode)
-            {
-                InspectorTest.checkUILocation(uiSourceCode, 0, 5, script.rawLocationToUILocation(0, 5));
-                InspectorTest.checkRawLocation(script, 10, 0, uiSourceCode.uiLocationToRawLocation(10, 0));
-                InspectorTest.dumpUISourceCode(uiSourceCode, step2);
-            }
-
-            function step2()
-            {
-                InspectorTest.addResult("Adding uiSourceCode for finished resource.");
-                InspectorTest.waitForWorkspaceUISourceCodeReplacedEvent(uiSourceCodeReplacedWithResource);
-                InspectorTest.waitForWorkspaceUISourceCodeAddedEvent(function() { });
-                InspectorTest.addMockUISourceCodeToWorkspace(url, WebInspector.resourceTypes.Script, "<content script resource content>");
-            }
-
-            function uiSourceCodeReplacedWithResource(uiSourceCode, oldUISourceCode)
-            {
-                InspectorTest.checkUILocation(uiSourceCode, 0, 5, script.rawLocationToUILocation(0, 5));
-                InspectorTest.checkRawLocation(script, 10, 0, uiSourceCode.uiLocationToRawLocation(10, 0));
-                InspectorTest.dumpUISourceCode(uiSourceCode, next);
-            }
-        },
-
-        function testScriptWithFinishedResource(next)
-        {
-            var script;
-            WebInspector.debuggerModel._reset();
-            var mockUISourceCode;
-            var resourceScriptMapping = createResourceScriptMapping();
-            var url = "foo.js";
-            step1();
-
-            function step1()
-            {
-                InspectorTest.addResult("Adding uiSourceCode for finished resource.");
-                InspectorTest.waitForWorkspaceUISourceCodeAddedEvent(uiSourceCodeForResourceAdded);
-                InspectorTest.addMockUISourceCodeToWorkspace(url, WebInspector.resourceTypes.Script, "<script resource content>");
-            }
-
-            function uiSourceCodeForResourceAdded(uiSourceCode)
-            {
-                mockUISourceCode = uiSourceCode;
-                InspectorTest.dumpUISourceCode(uiSourceCode, step2);
-            }
-
-            function step2()
-            {
-                InspectorTest.addResult("Adding script for finished request.");
-                script = InspectorTest.createScriptMock(url, 0, 0, false, "<script source>");
-                resourceScriptMapping.addScript(script);
-                InspectorTest.checkUILocation(mockUISourceCode, 0, 5, script.rawLocationToUILocation(0, 5));
-                InspectorTest.checkRawLocation(script, 10, 0, mockUISourceCode.uiLocationToRawLocation(10, 0));
-                InspectorTest.dumpUISourceCode(mockUISourceCode, next);
-            }
-        },
-
-        function testHTMLWithPendingResource(next)
-        {
-            var script1;
-            var script2;
-            WebInspector.debuggerModel._reset();
-            var resourceScriptMapping = createResourceScriptMapping();
-            var url = "index.html";
-            step1();
-
-            function step1()
-            {
-                InspectorTest.waitForWorkspaceUISourceCodeAddedEvent(uiSourceCodeAdded);
-                InspectorTest.addResult("Adding first script for pending request.");
-                script1 = InspectorTest.createScriptMock(url, 0, 10, false, "<script source 1>");
-                resourceScriptMapping.addScript(script1);
-            }
-
-            function uiSourceCodeAdded(uiSourceCode)
-            {
-                InspectorTest.checkUILocation(uiSourceCode, 0, 5, script1.rawLocationToUILocation(0, 5));
-                InspectorTest.checkRawLocation(script1, 10, 0, uiSourceCode.uiLocationToRawLocation(10, 0));
-                InspectorTest.dumpUISourceCode(uiSourceCode, step2);
-            }
-
-            function step2()
-            {
-                InspectorTest.addResult("Adding second script for pending request.");
-                InspectorTest.waitForWorkspaceUISourceCodeReplacedEvent(uiSourceCodeReplaced);
-                script2 = InspectorTest.createScriptMock(url, 0, 45, false, "<script source 2>");
-                resourceScriptMapping.addScript(script2);
-            }
-
-            function uiSourceCodeReplaced(uiSourceCode, oldUISourceCode)
-            {
-                InspectorTest.checkUILocation(uiSourceCode, 0, 5, script2.rawLocationToUILocation(0, 5));
-                InspectorTest.checkRawLocation(script1, 10, 0, uiSourceCode.uiLocationToRawLocation(10, 0));
-                InspectorTest.dumpUISourceCode(uiSourceCode, step3);
-            }
-
-            function step3()
-            {
-                InspectorTest.addResult("Adding uiSourceCode for finished resource.");
-                InspectorTest.waitForWorkspaceUISourceCodeReplacedEvent(uiSourceCodeReplacedWithResource);
-                InspectorTest.waitForWorkspaceUISourceCodeAddedEvent(function() { });
-                InspectorTest.addMockUISourceCodeToWorkspace(url, WebInspector.resourceTypes.Document, "<resource content>");
-            }
-
-            function uiSourceCodeReplacedWithResource(uiSourceCode, oldUISourceCode)
-            {
-                InspectorTest.checkUILocation(uiSourceCode, 0, 5, script1.rawLocationToUILocation(0, 5));
-                InspectorTest.checkRawLocation(script1, 10, 0, uiSourceCode.uiLocationToRawLocation(10, 0));
-                InspectorTest.dumpUISourceCode(uiSourceCode, next);
-            }
-        },
-
-        function testHTMLWithFinishedResource(next)
-        {
-            var script1;
-            var script2;
-            WebInspector.debuggerModel._reset();
-            var mockUISourceCode;
-            var resourceScriptMapping = createResourceScriptMapping();
-            var url = "index.html";
-            step1();
-
-            function step1()
-            {
-                InspectorTest.addResult("Adding uiSourceCode for finished resource.");
-                InspectorTest.waitForWorkspaceUISourceCodeAddedEvent(uiSourceCodeForResourceAdded);
-                InspectorTest.addMockUISourceCodeToWorkspace(url, WebInspector.resourceTypes.Document, "<resource content>");
-            }
-
-            function uiSourceCodeForResourceAdded(uiSourceCode)
-            {
-                mockUISourceCode = uiSourceCode;
-                InspectorTest.dumpUISourceCode(uiSourceCode, step2);
-            }
-
-            function step2()
-            {
-                InspectorTest.addResult("Adding first script for finished request.");
-                script1 = InspectorTest.createScriptMock(url, 1, 10, false, "<script source 1>");
-                resourceScriptMapping.addScript(script1);
-                InspectorTest.checkUILocation(mockUISourceCode, 1, 20, script1.rawLocationToUILocation(1, 20));
-                InspectorTest.checkRawLocation(script1, 1, 0, mockUISourceCode.uiLocationToRawLocation(1, 0));
-                InspectorTest.checkRawLocation(script1, 6, 0, mockUISourceCode.uiLocationToRawLocation(6, 0));
-                InspectorTest.dumpUISourceCode(mockUISourceCode, step3);
-            }
-
-            function step3()
-            {
-                InspectorTest.addResult("Adding second script for finished request.");
-                script2 = InspectorTest.createScriptMock(url, 5, 45, false, "<script\nsource\n2>");
-                resourceScriptMapping.addScript(script2);
-                InspectorTest.checkUILocation(mockUISourceCode, 1, 20, script1.rawLocationToUILocation(1, 20));
-                InspectorTest.checkRawLocation(script1, 1, 0, mockUISourceCode.uiLocationToRawLocation(1, 0));
-                InspectorTest.checkRawLocation(script2, 6, 0, mockUISourceCode.uiLocationToRawLocation(6, 0));
-                InspectorTest.dumpUISourceCode(mockUISourceCode, next);
-            }
-        }
-    ]);
-};
-
-</script>
-</head>
-<body onload="runTest()">
-<p>Tests ResourceScriptMapping class.</p>
-</body>
-</html>
index e5bcc38..a2fd591 100644 (file)
@@ -24,7 +24,7 @@ function test()
     
     function createUISouceCode(url)
     {
-        var uiSourceCode = new WebInspector.JavaScriptSource(url, null, contentProvider, false);
+        var uiSourceCode = new WebInspector.JavaScriptSource(url, null, contentProvider, null, false);
         uiSourceCode.requestContent = function(callback)
         {
             InspectorTest.addResult("Source requested for " + url);
index 1c43f54..78dc664 100644 (file)
@@ -1,3 +1,54 @@
+2012-09-03  Sheriff Bot  <webkit.review.bot@gmail.com>
+
+        Unreviewed, rolling out r127427.
+        http://trac.webkit.org/changeset/127427
+        https://bugs.webkit.org/show_bug.cgi?id=95695
+
+        Breaks some inspector/debugger tests on JSC (Requested by
+        vsevik on #webkit).
+
+        * WebCore.gypi:
+        * WebCore.vcproj/WebCore.vcproj:
+        * inspector/compile-front-end.py:
+        * inspector/front-end/CompilerScriptMapping.js:
+        * inspector/front-end/JavaScriptSource.js:
+        (WebInspector.JavaScriptSource):
+        * inspector/front-end/NetworkUISourceCodeProvider.js: Removed.
+        * inspector/front-end/RawSourceCode.js:
+        (WebInspector.RawSourceCode):
+        (WebInspector.RawSourceCode.prototype.addScript):
+        (WebInspector.RawSourceCode.prototype.rawLocationToUILocation):
+        (WebInspector.RawSourceCode.prototype._createUISourceCode):
+        (WebInspector.RawSourceCode.prototype.uiLocationToRawLocation):
+        (WebInspector.RawSourceCode.prototype.uiSourceCode):
+        (WebInspector.RawSourceCode.prototype._finishedLoading):
+        * inspector/front-end/ResourceScriptMapping.js:
+        (WebInspector.ResourceScriptMapping):
+        (WebInspector.ResourceScriptMapping.prototype.rawLocationToUILocation):
+        (WebInspector.ResourceScriptMapping.prototype.addScript):
+        (WebInspector.ResourceScriptMapping.prototype._shouldBindScriptToContentProvider):
+        (WebInspector.ResourceScriptMapping.prototype._handleUISourceCodeChanged):
+        (WebInspector.ResourceScriptMapping.prototype._uiSourceCodeAdded):
+        (WebInspector.ResourceScriptMapping.prototype._uiSourceCodeReplaced):
+        (WebInspector.ResourceScriptMapping.prototype._uiSourceCodeRemoved):
+        (WebInspector.ResourceScriptMapping.prototype._bindScriptToRawSourceCode):
+        (WebInspector.ResourceScriptMapping.prototype._reset):
+        * inspector/front-end/ScriptSnippetModel.js:
+        (WebInspector.ScriptSnippetModel.prototype._addScriptSnippet):
+        (WebInspector.ScriptSnippetModel.prototype._createUISourceCodeForScript):
+        (WebInspector.SnippetJavaScriptSource):
+        * inspector/front-end/StylesUISourceCodeProvider.js: Added.
+        (WebInspector.StylesUISourceCodeProvider):
+        (WebInspector.StylesUISourceCodeProvider.prototype._populate):
+        (WebInspector.StylesUISourceCodeProvider.prototype._resourceAdded):
+        (WebInspector.StylesUISourceCodeProvider.prototype._reset):
+        * inspector/front-end/UISourceCode.js:
+        (WebInspector.UISourceCode):
+        (WebInspector.UISourceCode.prototype.uiLocationToRawLocation):
+        * inspector/front-end/WebKit.qrc:
+        * inspector/front-end/inspector.html:
+        * inspector/front-end/inspector.js:
+
 2012-09-03  Vsevolod Vlasov  <vsevik@chromium.org>
 
         Web Inspector: Create JavaScriptSources based on network resources.
index 002ae08..9fea291 100644 (file)
             'inspector/front-end/NetworkLog.js',
             'inspector/front-end/NetworkPanelDescriptor.js',
             'inspector/front-end/NetworkRequest.js',
-            'inspector/front-end/NetworkUISourceCodeProvider.js',
             'inspector/front-end/Object.js',
             'inspector/front-end/ObjectPopoverHelper.js',
             'inspector/front-end/ObjectPropertiesSection.js',
             'inspector/front-end/PresentationConsoleMessageHelper.js',
             'inspector/front-end/ProgressBar.js',
             'inspector/front-end/PropertiesSection.js',
+            'inspector/front-end/RawSourceCode.js',
             'inspector/front-end/RemoteObject.js',
             'inspector/front-end/Resource.js',
             'inspector/front-end/ResourceScriptMapping.js',
             'inspector/front-end/StatusBarButton.js',
             'inspector/front-end/StyleSource.js',
             'inspector/front-end/StylesSourceMapping.js',
+            'inspector/front-end/StylesUISourceCodeProvider.js',
             'inspector/front-end/TabbedPane.js',
             'inspector/front-end/TestController.js',
             'inspector/front-end/TextEditor.js',
index 81b049f..8afa3ae 100755 (executable)
                                        >
                                </File>
                                <File
-                                       RelativePath="..\inspector\front-end\NetworkUISourceCodeProvider.js"
-                                       >
-                               </File>
-                               <File
                                        RelativePath="..\inspector\front-end\NetworkRequest.js"
                                        >
                                </File>
                                        >
                                </File>
                                <File
+                                       RelativePath="..\inspector\front-end\RawSourceCode.js"
+                                       >
+                               </File>
+                               <File
                                        RelativePath="..\inspector\front-end\RemoteObject.js"
                                        >
                                </File>
                                        >
                                </File>
                                <File
+                                       RelativePath="..\inspector\front-end\StylesUISourceCodeProvider.js"
+                                       >
+                               </File>
+                               <File
                                        RelativePath="..\inspector\front-end\StyleSource.js"
                                        >
                                </File>
index 6baca12..c76f570 100755 (executable)
@@ -82,7 +82,6 @@ modules = [
             "JavaScriptSource.js",
             "Linkifier.js",
             "NetworkLog.js",
-            "NetworkUISourceCodeProvider.js",
             "PresentationConsoleMessageHelper.js",
             "SASSSourceMapping.js",
             "Script.js",
@@ -92,7 +91,9 @@ modules = [
             "SourceMapping.js",
             "StyleSource.js",
             "StylesSourceMapping.js",
+            "StylesUISourceCodeProvider.js",
             "TimelineManager.js",
+            "RawSourceCode.js",
             "RemoteObject.js",
             "Resource.js",
             "ResourceScriptMapping.js",
index 05c0051..8096d56 100644 (file)
@@ -120,8 +120,7 @@ WebInspector.CompilerScriptMapping.prototype = {
                 contentProvider = new WebInspector.StaticContentProvider(WebInspector.resourceTypes.Script, sourceContent);
             else
                 contentProvider = new WebInspector.CompilerSourceMappingContentProvider(sourceURL);
-            var uiSourceCode = new WebInspector.JavaScriptSource(sourceURL, null, contentProvider, false);
-            uiSourceCode.setSourceMapping(this);
+            var uiSourceCode = new WebInspector.JavaScriptSource(sourceURL, null, contentProvider, this, false);
             uiSourceCode.isContentScript = script.isContentScript;
             this._uiSourceCodeByURL[sourceURL] = uiSourceCode;
             this._sourceMapForUISourceCode.put(uiSourceCode, sourceMap);
index a641c2d..2ac4953 100644 (file)
  * @param {string} url
  * @param {WebInspector.Resource} resource
  * @param {WebInspector.ContentProvider} contentProvider
+ * @param {WebInspector.SourceMapping} sourceMapping
  */
-WebInspector.JavaScriptSource = function(url, resource, contentProvider, isEditable)
+WebInspector.JavaScriptSource = function(url, resource, contentProvider, sourceMapping, isEditable)
 {
-    WebInspector.UISourceCode.call(this, url, resource, contentProvider);
+    WebInspector.UISourceCode.call(this, url, resource, contentProvider, sourceMapping);
     this._isEditable = isEditable;
 }
 
index e69de29..7e1b44c 100644 (file)
@@ -0,0 +1,145 @@
+/*
+ * Copyright (C) 2011 Google Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ *     * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *     * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ *     * Neither the name of Google Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+// RawSourceCode represents JavaScript resource or HTML resource with inlined scripts
+// as it came from network.
+
+/**
+ * @constructor
+ * @extends {WebInspector.Object}
+ * @param {string} id
+ * @param {WebInspector.Script} script
+ * @param {WebInspector.Resource} resource
+ * @param {WebInspector.NetworkRequest} request
+ * @param {WebInspector.SourceMapping} sourceMapping
+ */
+WebInspector.RawSourceCode = function(id, script, resource, request, sourceMapping)
+{
+    this.id = id;
+    this.url = script.sourceURL;
+    this.isContentScript = script.isContentScript;
+    this._scripts = [script];
+    this._resource = resource;
+    this._pendingRequest = request;
+    this._sourceMapping = sourceMapping;
+
+    this._uiSourceCode = null;
+    if (this._pendingRequest)
+        this._pendingRequest.addEventListener(WebInspector.NetworkRequest.Events.FinishedLoading, this._finishedLoading, this);
+    else
+        this._uiSourceCode = this._createUISourceCode();
+}
+
+WebInspector.RawSourceCode.Events = {
+    UISourceCodeChanged: "us-source-code-changed"
+}
+
+WebInspector.RawSourceCode.prototype = {
+    /**
+     * @param {WebInspector.Script} script
+     */
+    addScript: function(script)
+    {
+        this._scripts.push(script);
+        if (this._temporaryUISourceCode) {
+            var oldUISourceCode = this._temporaryUISourceCode;
+            this._temporaryUISourceCode = this._createUISourceCode();
+            this.dispatchEventToListeners(WebInspector.RawSourceCode.Events.UISourceCodeChanged, { uiSourceCode: this._temporaryUISourceCode, oldUISourceCode: oldUISourceCode });
+        }
+    },
+
+    /**
+     * @param {WebInspector.DebuggerModel.Location} rawLocation
+     * @return {WebInspector.UILocation}
+     */
+    rawLocationToUILocation: function(rawLocation)
+    {
+        var uiSourceCode = this._uiSourceCode || this._temporaryUISourceCode;
+        if (!uiSourceCode) {
+            this._temporaryUISourceCode = this._createUISourceCode();
+            uiSourceCode = this._temporaryUISourceCode;
+            this.dispatchEventToListeners(WebInspector.RawSourceCode.Events.UISourceCodeChanged, { uiSourceCode: uiSourceCode });
+        }
+        return new WebInspector.UILocation(uiSourceCode, rawLocation.lineNumber, rawLocation.columnNumber || 0);
+    },
+
+    /**
+     * @return {WebInspector.UISourceCode}
+     */
+    _createUISourceCode: function()
+    {
+        var isStandaloneScript = this._scripts.length === 1 && !this._scripts[0].isInlineScript();
+
+        var contentProvider;
+        if (this._resource)
+            contentProvider = this._resource;
+        else if (isStandaloneScript)
+            contentProvider = this._scripts[0];
+        else
+            contentProvider = new WebInspector.ConcatenatedScriptsContentProvider(this._scripts);
+
+        var uiSourceCode = new WebInspector.JavaScriptSource(this.url, this._resource, contentProvider, this._sourceMapping, isStandaloneScript);
+        uiSourceCode.isContentScript = this.isContentScript;
+        return uiSourceCode;
+    },
+
+    /**
+     * @param {WebInspector.UISourceCode} uiSourceCode
+     * @param {number} lineNumber
+     * @param {number} columnNumber
+     * @return {WebInspector.RawLocation}
+     */
+    uiLocationToRawLocation: function(uiSourceCode, lineNumber, columnNumber)
+    {
+        if (this.url)
+            return WebInspector.debuggerModel.createRawLocationByURL(this.url, lineNumber, columnNumber);
+        return WebInspector.debuggerModel.createRawLocation(this._scripts[0], lineNumber, columnNumber);
+    },
+
+    /**
+     * @return {WebInspector.UISourceCode|null}
+     */
+    uiSourceCode: function()
+    {
+        return this._uiSourceCode || this._temporaryUISourceCode;
+    },
+
+    _finishedLoading: function(event)
+    {
+        this._resource = WebInspector.resourceForURL(this._pendingRequest.url);
+        delete this._pendingRequest;
+        var oldUISourceCode = this._uiSourceCode || this._temporaryUISourceCode;
+        delete this._temporaryUISourceCode;
+        this._uiSourceCode = this._createUISourceCode();
+        this.dispatchEventToListeners(WebInspector.RawSourceCode.Events.UISourceCodeChanged, { uiSourceCode: this._uiSourceCode, oldUISourceCode: oldUISourceCode });
+    }
+}
+
+WebInspector.RawSourceCode.prototype.__proto__ = WebInspector.Object.prototype;
index 02eb62e..a16389c 100644 (file)
 WebInspector.ResourceScriptMapping = function(workspace)
 {
     this._workspace = workspace;
+    /** @type {Array.<WebInspector.RawSourceCode>} */
+    this._rawSourceCodes = [];
+    /** @type {Object.<string, WebInspector.RawSourceCode>} */
+    this._rawSourceCodeForScriptId = {};
+    /** @type {Object.<string, WebInspector.RawSourceCode>} */
+    this._rawSourceCodeForURL = {};
+    /** @type {Object.<string, WebInspector.RawSourceCode>} */
+    this._rawSourceCodeForDocumentURL = {};
+    this._rawSourceCodeForUISourceCode = new Map();
     this._workspace.addEventListener(WebInspector.Workspace.Events.ProjectWillReset, this._reset, this);
-    this._workspace.addEventListener(WebInspector.UISourceCodeProvider.Events.UISourceCodeAdded, this._uiSourceCodeAddedToWorkspace, this);
-
-    /** @type {Object.<string, WebInspector.UISourceCode>} */
-    this._uiSourceCodeForScriptId = {};
-    this._scriptIdForUISourceCode = new Map();
-    this._temporaryUISourceCodes = new Map();
-    /** @type {Object.<string, number>} */
-    this._nextDynamicScriptIndexForURL = {};
 }
 
 WebInspector.ResourceScriptMapping.prototype = {
@@ -55,9 +56,8 @@ WebInspector.ResourceScriptMapping.prototype = {
     rawLocationToUILocation: function(rawLocation)
     {
         var debuggerModelLocation = /** @type {WebInspector.DebuggerModel.Location} */ rawLocation;
-        var script = WebInspector.debuggerModel.scriptForId(debuggerModelLocation.scriptId);
-        var uiSourceCode = this._uiSourceCodeForScriptId[debuggerModelLocation.scriptId];
-        return new WebInspector.UILocation(uiSourceCode, debuggerModelLocation.lineNumber, debuggerModelLocation.columnNumber || 0);
+        var rawSourceCode = this._rawSourceCodeForScriptId[debuggerModelLocation.scriptId];
+        return rawSourceCode.rawLocationToUILocation(debuggerModelLocation);
     },
 
     /**
@@ -68,9 +68,8 @@ WebInspector.ResourceScriptMapping.prototype = {
      */
     uiLocationToRawLocation: function(uiSourceCode, lineNumber, columnNumber)
     {
-        var scriptId = this._scriptIdForUISourceCode.get(uiSourceCode);
-        var script = WebInspector.debuggerModel.scriptForId(scriptId);
-        return WebInspector.debuggerModel.createRawLocation(script, lineNumber, columnNumber);
+        var rawSourceCode = this._rawSourceCodeForUISourceCode.get(uiSourceCode);
+        return rawSourceCode.uiLocationToRawLocation(uiSourceCode, lineNumber, columnNumber);
     },
 
     /**
@@ -78,147 +77,137 @@ WebInspector.ResourceScriptMapping.prototype = {
      */
     addScript: function(script)
     {
-        console.assert(!this._uiSourceCodeForScriptId[script.scriptId]);
-
-        var isDynamicScript = false;
+        var resource = null;
+        var request = null;
         if (!script.isAnonymousScript()) {
-            var uiSourceCode = this._workspace.uiSourceCodeForURL(script.sourceURL);
-            isDynamicScript = !!uiSourceCode && uiSourceCode.contentType() === WebInspector.resourceTypes.Document && !script.isInlineScript();
-            if (uiSourceCode && !isDynamicScript && !this._temporaryUISourceCodes.get(uiSourceCode))
-                this._bindUISourceCodeToScripts(uiSourceCode, [script]);
+            // First lookup the resource that has already been loaded.
+            resource = WebInspector.resourceForURL(script.sourceURL);
+            // Ignore resource in case it has not yet finished loading.
+            if (resource && resource.request && !resource.request.finished)
+                resource = null;
+            // Only bind inline and standalone scripts.
+            if (resource && !this._shouldBindScriptToContentProvider(script, resource))
+                resource = null;
+            if (!resource) {
+                // When there is no resource, lookup in-flight requests.
+                request = WebInspector.networkManager.inflightRequestForURL(script.sourceURL);
+                // Only bind inline and standalone scripts.
+                if (request && !this._shouldBindScriptToContentProvider(script, request))
+                  request = null;
+            }
+        }
+        console.assert(!resource || !request);
+
+        var isInlineScript = script.isInlineScript() && (request || resource);
+        // If either of these exists, we bind script to the resource.
+        if (isInlineScript) {
+            var rawSourceCode = this._rawSourceCodeForDocumentURL[script.sourceURL];
+            if (rawSourceCode) {
+                rawSourceCode.addScript(script);
+                this._bindScriptToRawSourceCode(script, rawSourceCode);
+                return;
+            }
         }
-        if (!this._uiSourceCodeForScriptId[script.scriptId])
-            this._addOrReplaceTemporaryUISourceCode(script, isDynamicScript);
-
-        console.assert(this._uiSourceCodeForScriptId[script.scriptId]);
-    },
 
-    /**
-     * @param {WebInspector.UISourceCode} uiSourceCode
-     * @param {Array.<WebInspector.Script>} scripts
-     */
-    _bindUISourceCodeToScripts: function(uiSourceCode, scripts)
-    {
-        console.assert(scripts.length);
+        var rawSourceCode = new WebInspector.RawSourceCode(script.scriptId, script, resource, request, this);
+        this._rawSourceCodes.push(rawSourceCode);
+        this._bindScriptToRawSourceCode(script, rawSourceCode);
+        if (isInlineScript)
+            this._rawSourceCodeForDocumentURL[script.sourceURL] = rawSourceCode;
 
-        for (var i = 0; i < scripts.length; ++i) {
-            this._uiSourceCodeForScriptId[scripts[i].scriptId] = uiSourceCode;
-            scripts[i].setSourceMapping(this);
-        }
-        uiSourceCode.isContentScript = scripts[0].isContentScript;
-        uiSourceCode.setSourceMapping(this);
-        this._scriptIdForUISourceCode.put(uiSourceCode, scripts[0].scriptId);
+        if (rawSourceCode.uiSourceCode())
+            this._uiSourceCodeAdded(rawSourceCode, rawSourceCode.uiSourceCode());
+        rawSourceCode.addEventListener(WebInspector.RawSourceCode.Events.UISourceCodeChanged, this._handleUISourceCodeChanged, this);
     },
 
     /**
-     * @param {string} sourceURL
-     * @param {boolean} isInlineScript
-     * @return {Array.<WebInspector.Script>}
+     * @param {WebInspector.Script} script
+     * @param {WebInspector.ContentProvider} contentProvider
+     * @return {boolean}
      */
-    _scriptsForSourceURL: function(sourceURL, isInlineScript)
+    _shouldBindScriptToContentProvider: function(script, contentProvider)
     {
-        function filter(script)
-        {
-            return script.sourceURL === sourceURL && script.isInlineScript() === isInlineScript;
-        }
-
-        return Object.values(WebInspector.debuggerModel.scripts).filter(filter);
+        if (script.isInlineScript())
+            return contentProvider.contentType() === WebInspector.resourceTypes.Document;
+        return contentProvider.contentType() === WebInspector.resourceTypes.Script;
     },
 
     /**
-     * @param {WebInspector.Script} script
-     * @param {boolean} isDynamicScript
+     * @param {WebInspector.Event} event
      */
-    _addOrReplaceTemporaryUISourceCode: function(script, isDynamicScript)
+    _handleUISourceCodeChanged: function(event)
     {
-        var scripts = script.isInlineScript() ? this._scriptsForSourceURL(script.sourceURL, true) : [script];
-
-        var oldUISourceCode;
-        for (var i = 0; i < scripts.length; ++i) {
-            oldUISourceCode = this._uiSourceCodeForScriptId[scripts[i].scriptId];
-            if (oldUISourceCode)
-                break;
-        }
-        console.assert(!oldUISourceCode || this._temporaryUISourceCodes.get(oldUISourceCode));
-
-        var contentProvider = script.isInlineScript() ? new WebInspector.ConcatenatedScriptsContentProvider(scripts) : script;
-        var url = script.sourceURL;
-        if (isDynamicScript) {
-            var nextIndex = this._nextDynamicScriptIndexForURL[script.sourceURL] || 1;
-            url += " (" + nextIndex + ")";
-            this._nextDynamicScriptIndexForURL[script.sourceURL] = nextIndex + 1;
-        }
-        var uiSourceCode = new WebInspector.JavaScriptSource(url, null, contentProvider, !script.isInlineScript());
-        this._temporaryUISourceCodes.put(uiSourceCode, uiSourceCode);
-        this._bindUISourceCodeToScripts(uiSourceCode, scripts);
-
-        if (!script.sourceURL)
-            return uiSourceCode;
-
-        if (oldUISourceCode)
-            this._uiSourceCodeReplaced(oldUISourceCode, uiSourceCode);
+        var rawSourceCode = /** @type {WebInspector.RawSourceCode} */ event.target;
+        var uiSourceCode = /** @type {WebInspector.UISourceCode} */ event.data.uiSourceCode;
+        var oldUISourceCode = /** @type {WebInspector.UISourceCode} */ event.data.oldUISourceCode;
+        if (!oldUISourceCode)
+            this._uiSourceCodeAdded(rawSourceCode, uiSourceCode);
         else
-            this._workspace.project().addUISourceCode(uiSourceCode);
-        return uiSourceCode;
+            this._uiSourceCodeReplaced(rawSourceCode, oldUISourceCode, uiSourceCode);
     },
 
-    _uiSourceCodeAddedToWorkspace: function(event)
+    /**
+     * @param {WebInspector.RawSourceCode} rawSourceCode
+     * @paran {WebInspector.UISourceCode} uiSourceCode
+     */
+    _uiSourceCodeAdded: function(rawSourceCode, uiSourceCode)
     {
-        var uiSourceCode = /** @type {WebInspector.UISourceCode} */ event.data;
-        console.assert(!this._scriptIdForUISourceCode.get(uiSourceCode) || this._temporaryUISourceCodes.get(uiSourceCode));
-        if (!uiSourceCode.url || this._temporaryUISourceCodes.get(uiSourceCode))
+        if (!uiSourceCode.url)
             return;
-        this._addUISourceCode(uiSourceCode);
+        this._rawSourceCodeForUISourceCode.put(uiSourceCode, rawSourceCode);
+        this._workspace.project().addUISourceCode(uiSourceCode);
     },
 
     /**
+     * @param {WebInspector.RawSourceCode} rawSourceCode
+     * @param {WebInspector.UISourceCode} oldUISourceCode
      * @param {WebInspector.UISourceCode} uiSourceCode
      */
-    _addUISourceCode: function(uiSourceCode)
+    _uiSourceCodeReplaced: function(rawSourceCode, oldUISourceCode, uiSourceCode)
     {
-        var isInlineScript;
-        switch (uiSourceCode.contentType()) {
-        case WebInspector.resourceTypes.Document:
-            isInlineScript = true;
-            break;
-        case WebInspector.resourceTypes.Script:
-            isInlineScript = false;
-            break;
-        default:
-            return;
-        }
-
-        var scripts = this._scriptsForSourceURL(uiSourceCode.url, isInlineScript);
-        if (!scripts.length)
+        if (!uiSourceCode.url)
             return;
+        this._rawSourceCodeForUISourceCode.remove(oldUISourceCode);
+        this._rawSourceCodeForUISourceCode.put(uiSourceCode, rawSourceCode);
 
-        var oldUISourceCode = this._uiSourceCodeForScriptId[scripts[0].scriptId];
-        this._bindUISourceCodeToScripts(uiSourceCode, scripts);
-
-        if (oldUISourceCode) {
-            console.assert(this._temporaryUISourceCodes.get(oldUISourceCode));
-            this._uiSourceCodeReplaced(oldUISourceCode, uiSourceCode);
-        }
+        for (var i = 0; i < rawSourceCode._scripts.length; ++i)
+            rawSourceCode._scripts[i].setSourceMapping(this);
+        this._workspace.project().replaceUISourceCode(oldUISourceCode, uiSourceCode);
+    },
 
-        console.assert(this._scriptIdForUISourceCode.get(uiSourceCode) && !this._temporaryUISourceCodes.get(uiSourceCode));
+    /**
+     * @param {WebInspector.RawSourceCode} rawSourceCode
+     * @paran {WebInspector.UISourceCode} uiSourceCode
+     */
+    _uiSourceCodeRemoved: function(rawSourceCode, uiSourceCode)
+    {
+        if (!uiSourceCode.url)
+            return;
+        this._rawSourceCodeForUISourceCode.remove(uiSourceCode);
     },
 
     /**
-     * @param {WebInspector.UISourceCode} oldUISourceCode
-     * @param {WebInspector.UISourceCode} uiSourceCode
+     * @param {WebInspector.Script} script
+     * @param {WebInspector.RawSourceCode} rawSourceCode
      */
-    _uiSourceCodeReplaced: function(oldUISourceCode, uiSourceCode)
+    _bindScriptToRawSourceCode: function(script, rawSourceCode)
     {
-        this._temporaryUISourceCodes.remove(oldUISourceCode);
-        this._scriptIdForUISourceCode.remove(oldUISourceCode);
-        this._workspace.project().replaceUISourceCode(oldUISourceCode, uiSourceCode);
+        this._rawSourceCodeForScriptId[script.scriptId] = rawSourceCode;
+        this._rawSourceCodeForURL[script.sourceURL] = rawSourceCode;
+        script.setSourceMapping(this);
     },
 
     _reset: function()
     {
-        this._uiSourceCodeForScriptId = {};
-        this._scriptIdForUISourceCode.clear();
-        this._temporaryUISourceCodes.clear();
-        this._nextDynamicScriptIndexForURL = {};
-    },
+        for (var i = 0; i < this._rawSourceCodes.length; ++i) {
+            var rawSourceCode = this._rawSourceCodes[i];
+            this._uiSourceCodeRemoved(rawSourceCode, rawSourceCode.uiSourceCode());
+            rawSourceCode.removeAllListeners();
+        }
+        this._rawSourceCodes = [];
+        this._rawSourceCodeForScriptId = {};
+        this._rawSourceCodeForURL = {};
+        this._rawSourceCodeForDocumentURL = {};
+        this._rawSourceCodeForUISourceCode.clear();
+    }
 }
index 0605f7c..d92a2d3 100644 (file)
@@ -81,7 +81,6 @@ WebInspector.ScriptSnippetModel.prototype = {
     _addScriptSnippet: function(snippet)
     {
         var snippetJavaScriptSource = new WebInspector.SnippetJavaScriptSource(snippet.id, snippet.name, new WebInspector.SnippetContentProvider(snippet), this);
-        snippetJavaScriptSource.setSourceMapping(this._snippetScriptMapping); 
         this._snippetJavaScriptSourceForSnippetId[snippet.id] = snippetJavaScriptSource;
         this._workspace.project().addUISourceCode(snippetJavaScriptSource);
         return snippetJavaScriptSource;
@@ -279,8 +278,7 @@ WebInspector.ScriptSnippetModel.prototype = {
      */
     _createUISourceCodeForScript: function(script)
     {
-        var uiSourceCode = new WebInspector.JavaScriptSource(script.sourceURL, null, script, false);
-        uiSourceCode.setSourceMapping(this._snippetScriptMapping); 
+        var uiSourceCode = new WebInspector.JavaScriptSource(script.sourceURL, null, script, this._snippetScriptMapping, false);
         uiSourceCode.isSnippetEvaluation = true;
         this._uiSourceCodeForScriptId[script.scriptId] = uiSourceCode;
         this._scriptForUISourceCode.put(uiSourceCode, script);
@@ -374,7 +372,7 @@ WebInspector.ScriptSnippetModel.prototype.__proto__ = WebInspector.Object.protot
  */
 WebInspector.SnippetJavaScriptSource = function(snippetId, snippetName, contentProvider, scriptSnippetModel)
 {
-    WebInspector.JavaScriptSource.call(this, snippetName, null, contentProvider, true);
+    WebInspector.JavaScriptSource.call(this, snippetName, null, contentProvider, scriptSnippetModel.scriptMapping, true);
     this._snippetId = snippetId;
     this._scriptSnippetModel = scriptSnippetModel;
     this.isSnippet = true;
  * @constructor
  * @param {WebInspector.Workspace} workspace
  */
-WebInspector.NetworkUISourceCodeProvider = function(workspace)
+WebInspector.StylesUISourceCodeProvider = function(workspace)
 {
     this._workspace = workspace;
     WebInspector.resourceTreeModel.addEventListener(WebInspector.ResourceTreeModel.EventTypes.ResourceAdded, this._resourceAdded, this);
     this._workspace.addEventListener(WebInspector.Workspace.Events.ProjectWillReset, this._reset, this);
     this._stylesSourceMapping = new WebInspector.StylesSourceMapping();
-
-    this._uiSourceCodeForResource = {};
 }
 
-WebInspector.NetworkUISourceCodeProvider.prototype = {
+WebInspector.StylesUISourceCodeProvider.prototype = {
     _populate: function()
     {
         function populateFrame(frame)
@@ -59,74 +57,20 @@ WebInspector.NetworkUISourceCodeProvider.prototype = {
     },
 
     /**
-     * @param {WebInspector.Resource} resource
-     */
-    _styleResourceAdded: function(resource)
-    {
-        var uiSourceCode = new WebInspector.StyleSource(resource);
-        this._stylesSourceMapping.addUISourceCode(uiSourceCode);
-        this._addUISourceCode(uiSourceCode);
-    },
-
-    /**
-     * @param {WebInspector.Resource} resource
-     */
-    _scriptResourceAdded: function(resource)
-    {
-        if (resource.request && !resource.request.finished) {
-            resource.request.addEventListener(WebInspector.NetworkRequest.Events.FinishedLoading, resourceFinished, this);
-            return;
-        }
-        this._addJavaScriptSource(resource);
-        
-        function resourceFinished()
-        {
-            resource.request.removeEventListener(WebInspector.NetworkRequest.Events.FinishedLoading, resourceFinished, this);
-            this._addJavaScriptSource(resource);
-        }
-    },
-
-    /**
-     * @param {WebInspector.Resource} resource
-     */
-    _addJavaScriptSource: function(resource)
-    {
-        if (this._uiSourceCodeForResource[resource.url])
-            return;
-        var isDocument = resource.type === WebInspector.resourceTypes.Document;
-        var uiSourceCode = new WebInspector.JavaScriptSource(resource.url, resource, resource, !isDocument);
-        this._uiSourceCodeForResource[resource.url] = uiSourceCode;
-        this._addUISourceCode(uiSourceCode);
-    },
-
-    /**
-     * @param {WebInspector.UISourceCode} uiSourceCode
-     */
-    _addUISourceCode: function(uiSourceCode)
-    {
-        this._workspace.project().addUISourceCode(uiSourceCode);
-    },
-
-    /**
      * @param {WebInspector.Event} event
      */
     _resourceAdded: function(event)
     {
         var resource = /** @type {WebInspector.Resource} */ event.data;
-        switch (resource.type) {
-        case WebInspector.resourceTypes.Stylesheet:
-            this._styleResourceAdded(resource);
-            break;
-        case WebInspector.resourceTypes.Document:
-        case WebInspector.resourceTypes.Script:
-            this._scriptResourceAdded(resource);
-            break;
-        }
+        if (resource.type !== WebInspector.resourceTypes.Stylesheet)
+            return;
+        var uiSourceCode = new WebInspector.StyleSource(resource);
+        this._stylesSourceMapping.addUISourceCode(uiSourceCode);
+        this._workspace.project().addUISourceCode(uiSourceCode);
     },
 
     _reset: function()
     {
-        this._uiSourceCodeForResource = {};
         this._stylesSourceMapping.reset();
         // FIXME: We should not populate until the ProjectWillReset event was handled by all listeners. Introduce ProjectDidReset event for that matter.
         setTimeout(this._populate.bind(this), 0);
index 47c8c34..17aaaa0 100644 (file)
  * @param {string} url
  * @param {WebInspector.Resource} resource
  * @param {WebInspector.ContentProvider} contentProvider
+ * @param {WebInspector.SourceMapping=} sourceMapping
  */
-WebInspector.UISourceCode = function(url, resource, contentProvider)
+WebInspector.UISourceCode = function(url, resource, contentProvider, sourceMapping)
 {
     this._url = url;
     this._resource = resource;
     this._parsedURL = new WebInspector.ParsedURL(url);
     this._contentProvider = contentProvider;
+    this._sourceMapping = sourceMapping;
     this.isContentScript = false;
     /**
      * @type Array.<function(?string,boolean,string)>
@@ -382,8 +384,6 @@ WebInspector.UISourceCode.prototype = {
      */
     uiLocationToRawLocation: function(lineNumber, columnNumber)
     {
-        if (!this._sourceMapping)
-            return null;
         var location = this._formatterMapping.formattedToOriginal(lineNumber, columnNumber);
         return this._sourceMapping.uiLocationToRawLocation(this, location[0], location[1]);
     },
@@ -537,14 +537,6 @@ WebInspector.UISourceCode.prototype = {
         return null;
     },
 
-    /**
-     * @param {WebInspector.SourceMapping} sourceMapping
-     */
-    setSourceMapping: function(sourceMapping)
-    {
-        this._sourceMapping = sourceMapping;
-    },
-
     formattedChanged: function()
     {
     }
index 75b8914..5de89ad 100644 (file)
     <file>NavigatorView.js</file>
     <file>NetworkItemView.js</file>
     <file>NetworkLog.js</file>
-    <file>NetworkUISourceCodeProvider.js</file>
     <file>NetworkManager.js</file>
     <file>NetworkPanel.js</file>
     <file>NetworkPanelDescriptor.js</file>
     <file>ProgressBar.js</file>
     <file>PropertiesSection.js</file>
     <file>PropertiesSidebarPane.js</file>
+    <file>RawSourceCode.js</file>
     <file>RemoteObject.js</file>
     <file>Resource.js</file>
     <file>RequestCookiesView.js</file>
     <file>StyleSheetOutlineDialog.js</file>
     <file>StyleSource.js</file>
     <file>StylesSourceMapping.js</file>
+    <file>StylesUISourceCodeProvider.js</file>
     <file>StylesSidebarPane.js</file>
     <file>TabbedEditorContainer.js</file>
     <file>TabbedPane.js</file>
index cb9b8e8..1beefed 100644 (file)
@@ -139,6 +139,7 @@ THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
     <script type="text/javascript" src="Workspace.js"></script>
     <script type="text/javascript" src="BreakpointManager.js"></script>
     <script type="text/javascript" src="ContentProviders.js"></script>
+    <script type="text/javascript" src="RawSourceCode.js"></script>
     <script type="text/javascript" src="ResourceScriptMapping.js"></script>
     <script type="text/javascript" src="CompilerScriptMapping.js"></script>
     <script type="text/javascript" src="SASSSourceMapping.js"></script>
@@ -161,8 +162,8 @@ THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
     <script type="text/javascript" src="ScriptSnippetModel.js"></script>
     <script type="text/javascript" src="ProgressBar.js"></script>
     <script type="text/javascript" src="StylesSourceMapping.js"></script>
+    <script type="text/javascript" src="StylesUISourceCodeProvider.js"></script>
     <script type="text/javascript" src="StyleSource.js"></script>
-    <script type="text/javascript" src="NetworkUISourceCodeProvider.js"></script>
     <script type="text/javascript" src="ElementsPanelDescriptor.js"></script>
     <script type="text/javascript" src="NetworkPanelDescriptor.js"></script>
     <script type="text/javascript" src="ScriptsPanelDescriptor.js"></script>
index 782964f..3b98ed7 100644 (file)
@@ -523,7 +523,7 @@ WebInspector._doLoadedDoneWithCapabilities = function()
 
     this.scriptSnippetModel = new WebInspector.ScriptSnippetModel(this.workspace);
     new WebInspector.DebuggerScriptMapping(this.workspace);
-    new WebInspector.NetworkUISourceCodeProvider(this.workspace);
+    new WebInspector.StylesUISourceCodeProvider(this.workspace);
     if (WebInspector.experimentsSettings.sass.isEnabled())
         new WebInspector.SASSSourceMapping(this.workspace);