Title: [129485] trunk
Revision
129485
Author
[email protected]
Date
2012-09-25 03:58:51 -0700 (Tue, 25 Sep 2012)

Log Message

Web Inspector: ResourceScriptMapping should no steal scripts from other mappings.
https://bugs.webkit.org/show_bug.cgi?id=97453

Reviewed by Pavel Feldman.

Source/WebCore:

Exposed sourceMapping getter on Script so that resource mapping could check it.

* inspector/front-end/ResourceScriptMapping.js:
(WebInspector.ResourceScriptMapping):
(WebInspector.ResourceScriptMapping.prototype._scriptsForSourceURL):
(WebInspector.ResourceScriptMapping.prototype._reset):

LayoutTests:

* http/tests/inspector/compiler-script-mapping.html:

Modified Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (129484 => 129485)


--- trunk/LayoutTests/ChangeLog	2012-09-25 10:48:57 UTC (rev 129484)
+++ trunk/LayoutTests/ChangeLog	2012-09-25 10:58:51 UTC (rev 129485)
@@ -1,3 +1,12 @@
+2012-09-25  Vsevolod Vlasov  <[email protected]>
+
+        Web Inspector: ResourceScriptMapping should no steal scripts from other mappings.
+        https://bugs.webkit.org/show_bug.cgi?id=97453
+
+        Reviewed by Pavel Feldman.
+
+        * http/tests/inspector/compiler-script-mapping.html:
+
 2012-09-25  Raphael Kubo da Costa  <[email protected]>
 
         [EFL] More gardening.

Modified: trunk/LayoutTests/http/tests/inspector/compiler-script-mapping.html (129484 => 129485)


--- trunk/LayoutTests/http/tests/inspector/compiler-script-mapping.html	2012-09-25 10:48:57 UTC (rev 129484)
+++ trunk/LayoutTests/http/tests/inspector/compiler-script-mapping.html	2012-09-25 10:58:51 UTC (rev 129485)
@@ -2,11 +2,20 @@
 <head>
 <script src=""
 <script src=""
+<script src=""
 
 <script>
 
 function test()
 {
+    function createCompilerScriptMapping()
+    {
+        InspectorTest.createWorkspace();
+        var compilerScriptMapping = new WebInspector.CompilerScriptMapping(InspectorTest.testWorkspace);
+        var resourceScriptMapping = new WebInspector.ResourceScriptMapping(InspectorTest.testWorkspace);
+        return compilerScriptMapping;
+    }
+
     function checkMapping(compiledLineNumber, compiledColumnNumber, sourceURL, sourceLineNumber, sourceColumnNumber, mapping)
     {
         var entry = mapping.findEntry(compiledLineNumber, compiledColumnNumber);
@@ -126,38 +135,64 @@
 
         function testCompilerScriptMapping(next)
         {
+            var script;
             WebInspector.debuggerModel._reset();
-            var workspace = new WebInspector.Workspace();
-            var mapping = new WebInspector.CompilerScriptMapping(workspace);
-            var script = InspectorTest.createScriptMock("compiled.js", 0, 0, true, "");
-            script.sourceMapURL = "http://localhost:8000/inspector/resources/source-map.json";
-            mapping.addScript(script);
+            var mapping = createCompilerScriptMapping();
+            step1();
 
-            var uiSourceCode1 = mapping._uiSourceCodeByURL["http://localhost:8000/inspector/resources/source1.js"];
-            var uiSourceCode2 = mapping._uiSourceCodeByURL["http://localhost:8000/inspector/resources/source2.js"];
-            var originalUISourceCode = mapping._originalUISourceCodeForScriptId[script.scriptId];
+            function step1()
+            {
+                InspectorTest.waitForWorkspaceUISourceCodeAddedEvent(originalUISourceCodeAdded);
+                script = InspectorTest.createScriptMock("compiled.js", 0, 0, true, "");
+                script.sourceMapURL = "http://localhost:8000/inspector/resources/source-map.json";
+                script.setSourceMapping(mapping);
+                mapping.addScript(script);
+            }
 
-            InspectorTest.checkUILocation(uiSourceCode1, 4, 4, mapping.rawLocationToUILocation(WebInspector.debuggerModel.createRawLocation(script, 0, 81)));
-            InspectorTest.checkUILocation(uiSourceCode1, 5, 4, mapping.rawLocationToUILocation(WebInspector.debuggerModel.createRawLocation(script, 0, 93)));
-            InspectorTest.checkUILocation(uiSourceCode2, 7, 4, mapping.rawLocationToUILocation(WebInspector.debuggerModel.createRawLocation(script, 1, 151)));
-            InspectorTest.checkUILocation(originalUISourceCode, 1, 200, mapping.rawLocationToUILocation(WebInspector.debuggerModel.createRawLocation(script, 1, 200)));
+            function originalUISourceCodeAdded(uiSourceCode)
+            {
+                InspectorTest.waitForWorkspaceUISourceCodeAddedEvent(firstUISourceCodeAdded);
+            }
 
-            InspectorTest.checkRawLocation(script, 0, 42, mapping.uiLocationToRawLocation(uiSourceCode1, 3, 10));
-            InspectorTest.checkRawLocation(script, 1, 85, mapping.uiLocationToRawLocation(uiSourceCode2, 0, 0));
-            InspectorTest.checkRawLocation(script, 1, 110, mapping.uiLocationToRawLocation(uiSourceCode2, 5, 2));
+            function firstUISourceCodeAdded(uiSourceCode)
+            {
+                InspectorTest.waitForWorkspaceUISourceCodeAddedEvent(secondUISourceCodeAdded);
+            }
 
-            uiSourceCode1.requestContent(didRequestContent1);
-
-            function didRequestContent1(content, contentEncoded, mimeType)
+            function secondUISourceCodeAdded(uiSourceCode)
             {
-                InspectorTest.assertEquals(0, content.indexOf("window.addEventListener"));
-                uiSourceCode2.requestContent(didRequestContent2);
+                InspectorTest.waitForWorkspaceUISourceCodeAddedEvent(originalResourceUISourceCodeAdded);
+                InspectorTest.addMockUISourceCodeToWorkspace("compiled.js", WebInspector.resourceTypes.Script, "");
             }
 
-            function didRequestContent2(content, contentEncoded, mimeType)
+            function originalResourceUISourceCodeAdded(uiSourceCode)
             {
-                InspectorTest.assertEquals(0, content.indexOf("function ClickHandler()"));
-                next();
+                var uiSourceCode1 = mapping._uiSourceCodeByURL["http://localhost:8000/inspector/resources/source1.js"];
+                var uiSourceCode2 = mapping._uiSourceCodeByURL["http://localhost:8000/inspector/resources/source2.js"];
+                var originalUISourceCode = mapping._originalUISourceCodeForScriptId[script.scriptId];
+
+                InspectorTest.checkUILocation(uiSourceCode1, 4, 4, script.rawLocationToUILocation(0, 81));
+                InspectorTest.checkUILocation(uiSourceCode1, 5, 4, script.rawLocationToUILocation(0, 93));
+                InspectorTest.checkUILocation(uiSourceCode2, 7, 4, script.rawLocationToUILocation(1, 151));
+                InspectorTest.checkUILocation(originalUISourceCode, 1, 200, script.rawLocationToUILocation(1, 200));
+
+                InspectorTest.checkRawLocation(script, 0, 42, uiSourceCode1.uiLocationToRawLocation(3, 10));
+                InspectorTest.checkRawLocation(script, 1, 85, uiSourceCode2.uiLocationToRawLocation(0, 0));
+                InspectorTest.checkRawLocation(script, 1, 110, uiSourceCode2.uiLocationToRawLocation(5, 2));
+
+                uiSourceCode1.requestContent(didRequestContent1);
+
+                function didRequestContent1(content, contentEncoded, mimeType)
+                {
+                    InspectorTest.assertEquals(0, content.indexOf("window.addEventListener"));
+                    uiSourceCode2.requestContent(didRequestContent2);
+                }
+
+                function didRequestContent2(content, contentEncoded, mimeType)
+                {
+                    InspectorTest.assertEquals(0, content.indexOf("function ClickHandler()"));
+                    next();
+                }
             }
         },
 

Modified: trunk/Source/WebCore/ChangeLog (129484 => 129485)


--- trunk/Source/WebCore/ChangeLog	2012-09-25 10:48:57 UTC (rev 129484)
+++ trunk/Source/WebCore/ChangeLog	2012-09-25 10:58:51 UTC (rev 129485)
@@ -1,3 +1,17 @@
+2012-09-25  Vsevolod Vlasov  <[email protected]>
+
+        Web Inspector: ResourceScriptMapping should no steal scripts from other mappings.
+        https://bugs.webkit.org/show_bug.cgi?id=97453
+
+        Reviewed by Pavel Feldman.
+
+        Exposed sourceMapping getter on Script so that resource mapping could check it.
+
+        * inspector/front-end/ResourceScriptMapping.js:
+        (WebInspector.ResourceScriptMapping):
+        (WebInspector.ResourceScriptMapping.prototype._scriptsForSourceURL):
+        (WebInspector.ResourceScriptMapping.prototype._reset):
+
 2012-09-25  Keishi Hattori  <[email protected]>
 
         REGRESSION(r129448): multiple fields time input UI doesn't use system time format settings on Chromium-Mac

Modified: trunk/Source/WebCore/inspector/front-end/ResourceScriptMapping.js (129484 => 129485)


--- trunk/Source/WebCore/inspector/front-end/ResourceScriptMapping.js	2012-09-25 10:48:57 UTC (rev 129484)
+++ trunk/Source/WebCore/inspector/front-end/ResourceScriptMapping.js	2012-09-25 10:58:51 UTC (rev 129485)
@@ -45,6 +45,7 @@
     this._temporaryUISourceCodes = new Map();
     /** @type {Object.<string, number>} */
     this._nextDynamicScriptIndexForURL = {};
+    this._scripts = [];
 }
 
 WebInspector.ResourceScriptMapping.prototype = {
@@ -82,6 +83,7 @@
 
         var isDynamicScript = false;
         if (!script.isAnonymousScript()) {
+            this._scripts.push(script);
             var uiSourceCode = this._workspace.uiSourceCodeForURL(script.sourceURL);
             isDynamicScript = !!uiSourceCode && uiSourceCode.contentType() === WebInspector.resourceTypes.Document && !script.isInlineScript();
             if (uiSourceCode && !isDynamicScript && !this._temporaryUISourceCodes.get(uiSourceCode))
@@ -122,7 +124,7 @@
             return script.sourceURL === sourceURL && script.isInlineScript() === isInlineScript;
         }
 
-        return Object.values(WebInspector.debuggerModel.scripts).filter(filter);
+        return this._scripts.filter(filter.bind(this));
     },
 
     /**
@@ -220,5 +222,6 @@
         this._scriptIdForUISourceCode.clear();
         this._temporaryUISourceCodes.clear();
         this._nextDynamicScriptIndexForURL = {};
+        this._scripts = [];
     },
 }
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to