Title: [226435] trunk
Revision
226435
Author
[email protected]
Date
2018-01-04 20:34:07 -0800 (Thu, 04 Jan 2018)

Log Message

REGRESSION (r225709): Web Inspector: CSS Source maps not loading
https://bugs.webkit.org/show_bug.cgi?id=181314
<rdar://problem/36177620>

Patch by Joseph Pecoraro <[email protected]> on 2018-01-04
Reviewed by Brian Burg.

Source/WebInspectorUI:

* UserInterface/Controllers/SourceMapManager.js:
(WI.SourceMapManager.prototype._loadAndParseSourceMap):
* UserInterface/Models/SourceMapResource.js:
(WI.SourceMapResource.prototype.requestContentFromBackend):
Correct this so that we only fall back to a reasonable frame id
if we couldn't determine a frame id from earlier. Previously this
was incorrectly clearing the frame id if we had gotten it earlier.

* UserInterface/Test.html:
* UserInterface/Test/Test.js:
(WI.loaded):
Add SourceMap related files for tests.

LayoutTests:

* http/tests/inspector/network/resources/script-with-sourcemap.js: Added.
* http/tests/inspector/network/resources/script-with-sourcemap.js.map: Added.
* http/tests/inspector/network/resources/stylesheet-with-sourcemap.css: Added.
* http/tests/inspector/network/resources/stylesheet-with-sourcemap.css.map: Added.
* http/tests/inspector/network/resources/stylesheet-with-sourcemap.scss: Added.
Add a real script minified with a source map.
Add a real scss stylesheet compiled to css with a source map.

* http/tests/inspector/network/source-map-loads-expected.txt: Added.
* http/tests/inspector/network/source-map-loads.html: Added.
Test that we load source maps for resources with sourceMappingURL directives.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (226434 => 226435)


--- trunk/LayoutTests/ChangeLog	2018-01-05 04:15:49 UTC (rev 226434)
+++ trunk/LayoutTests/ChangeLog	2018-01-05 04:34:07 UTC (rev 226435)
@@ -1,3 +1,23 @@
+2018-01-04  Joseph Pecoraro  <[email protected]>
+
+        REGRESSION (r225709): Web Inspector: CSS Source maps not loading
+        https://bugs.webkit.org/show_bug.cgi?id=181314
+        <rdar://problem/36177620>
+
+        Reviewed by Brian Burg.
+
+        * http/tests/inspector/network/resources/script-with-sourcemap.js: Added.
+        * http/tests/inspector/network/resources/script-with-sourcemap.js.map: Added.
+        * http/tests/inspector/network/resources/stylesheet-with-sourcemap.css: Added.
+        * http/tests/inspector/network/resources/stylesheet-with-sourcemap.css.map: Added.
+        * http/tests/inspector/network/resources/stylesheet-with-sourcemap.scss: Added.
+        Add a real script minified with a source map.
+        Add a real scss stylesheet compiled to css with a source map.
+
+        * http/tests/inspector/network/source-map-loads-expected.txt: Added.
+        * http/tests/inspector/network/source-map-loads.html: Added.
+        Test that we load source maps for resources with sourceMappingURL directives.
+
 2018-01-04  Chris Fleizach  <[email protected]>
 
         AX: Implement updated CSS3 Speech for 'speak' and 'speak-as' properties

Added: trunk/LayoutTests/http/tests/inspector/network/resources/script-with-sourcemap.js (0 => 226435)


--- trunk/LayoutTests/http/tests/inspector/network/resources/script-with-sourcemap.js	                        (rev 0)
+++ trunk/LayoutTests/http/tests/inspector/network/resources/script-with-sourcemap.js	2018-01-05 04:34:07 UTC (rev 226435)
@@ -0,0 +1,2 @@
+function nothingSpecialToSeeHere1(){console.log("nothingSpecialToSeeHere1")}
+//# sourceMappingURL=script-with-sourcemap.js.map

Added: trunk/LayoutTests/http/tests/inspector/network/resources/script-with-sourcemap.js.map (0 => 226435)


--- trunk/LayoutTests/http/tests/inspector/network/resources/script-with-sourcemap.js.map	                        (rev 0)
+++ trunk/LayoutTests/http/tests/inspector/network/resources/script-with-sourcemap.js.map	2018-01-05 04:34:07 UTC (rev 226435)
@@ -0,0 +1,7 @@
+{
+"version": 3,
+"file": "script-with-sourcemap.js",
+"sources": ["script-with-sourcemap.js"],
+"names": ["nothingSpecialToSeeHere1","console","log"],
+"mappings": "AACA,QAASA,4BACLC,QAAQC,IAAI"
+}

Added: trunk/LayoutTests/http/tests/inspector/network/resources/stylesheet-with-sourcemap.css (0 => 226435)


--- trunk/LayoutTests/http/tests/inspector/network/resources/stylesheet-with-sourcemap.css	                        (rev 0)
+++ trunk/LayoutTests/http/tests/inspector/network/resources/stylesheet-with-sourcemap.css	2018-01-05 04:34:07 UTC (rev 226435)
@@ -0,0 +1,22 @@
+div {
+  background-color: #ABC;
+  width: 200px;
+  height: 100px;
+  margin: 20px; }
+
+.div1 {
+  border-top-left-radius: 10px;
+  -moz-border-radius-topleft: 10px;
+  -webkit-border-top-left-radius: 10px; }
+
+.div2 {
+  border-top-left-radius: 20px;
+  -moz-border-radius-topleft: 20px;
+  -webkit-border-top-left-radius: 20px; }
+
+.div3 {
+  border-top-left-radius: 30px;
+  -moz-border-radius-topleft: 30px;
+  -webkit-border-top-left-radius: 30px; }
+
+/*# sourceMappingURL=stylesheet-with-sourcemap.css.map */

Added: trunk/LayoutTests/http/tests/inspector/network/resources/stylesheet-with-sourcemap.css.map (0 => 226435)


--- trunk/LayoutTests/http/tests/inspector/network/resources/stylesheet-with-sourcemap.css.map	                        (rev 0)
+++ trunk/LayoutTests/http/tests/inspector/network/resources/stylesheet-with-sourcemap.css.map	2018-01-05 04:34:07 UTC (rev 226435)
@@ -0,0 +1,7 @@
+{
+"version": 3,
+"mappings": "AAMA,GAAI;EAAE,gBAAgB,EAAE,IAAI;EAAE,KAAK,EAAE,KAAK;EAAE,MAAM,EAAE,KAAK;EAAE,MAAM,EAAE,IAAI;;AACvE,KAAM;EANJ,sBAA+B,EADK,IAAI;EAExC,0BAAmC,EAFC,IAAI;EAGxC,8BAAuC,EAHH,IAAI;;AAQ1C,KAAM;EAPJ,sBAA+B,EAOG,IAAI;EANtC,0BAAmC,EAMD,IAAI;EALtC,8BAAuC,EAKL,IAAI;;AACxC,KAAM;EARJ,sBAA+B,EAQG,IAAI;EAPtC,0BAAmC,EAOD,IAAI;EANtC,8BAAuC,EAML,IAAI",
+"sources": ["styles.scss"],
+"names": [],
+"file": "stylesheet-with-sourcemap.css"
+}

Added: trunk/LayoutTests/http/tests/inspector/network/resources/stylesheet-with-sourcemap.scss (0 => 226435)


--- trunk/LayoutTests/http/tests/inspector/network/resources/stylesheet-with-sourcemap.scss	                        (rev 0)
+++ trunk/LayoutTests/http/tests/inspector/network/resources/stylesheet-with-sourcemap.scss	2018-01-05 04:34:07 UTC (rev 226435)
@@ -0,0 +1,10 @@
+@mixin rounded($vert, $horz, $radius: 10px) {
+  border-#{$vert}-#{$horz}-radius: $radius;
+  -moz-border-radius-#{$vert}#{$horz}: $radius;
+  -webkit-border-#{$vert}-#{$horz}-radius: $radius;
+}
+
+div { background-color: #ABC; width: 200px; height: 100px; margin: 20px; }
+.div1 { @include rounded(top, left); }
+.div2 { @include rounded(top, left, 20px); }
+.div3 { @include rounded(top, left, 30px); }

Added: trunk/LayoutTests/http/tests/inspector/network/source-map-loads-expected.txt (0 => 226435)


--- trunk/LayoutTests/http/tests/inspector/network/source-map-loads-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/http/tests/inspector/network/source-map-loads-expected.txt	2018-01-05 04:34:07 UTC (rev 226435)
@@ -0,0 +1,14 @@
+Ensure a source map loads for resources with sourceMappingURLs.
+
+
+== Running test suite: Network.SourceMap
+-- Running test case: Network.SourceMap.Stylesheet
+PASS: Stylesheet Resource should be created.
+PASS: Resource should have loaded 1 SourceMap.
+PASS: SourceMap should be a WI.SourceMap instance.
+
+-- Running test case: Network.SourceMap.Script
+PASS: Script Resource should be created.
+PASS: Resource should have loaded 1 SourceMap.
+PASS: SourceMap should be a WI.SourceMap instance.
+

Added: trunk/LayoutTests/http/tests/inspector/network/source-map-loads.html (0 => 226435)


--- trunk/LayoutTests/http/tests/inspector/network/source-map-loads.html	                        (rev 0)
+++ trunk/LayoutTests/http/tests/inspector/network/source-map-loads.html	2018-01-05 04:34:07 UTC (rev 226435)
@@ -0,0 +1,58 @@
+<!DOCTYPE html>
+<html>
+<head>
+<script src=""
+<script>
+function triggerStylesheetResource() {
+    let link = document.createElement("link");
+    link.rel = "stylesheet";
+    link.href = ""
+    document.head.appendChild(link);
+}
+
+function triggerScriptResource() {
+    let script = document.createElement("script");
+    script.src = ""
+    document.body.appendChild(script);
+}
+
+function test()
+{
+    let suite = InspectorTest.createAsyncSuite("Network.SourceMap");
+
+    suite.addTestCase({
+        name: "Network.SourceMap.Stylesheet",
+        description: "Ensure a source map loads for a stylesheet resource.",
+        async test(resolve, reject) {
+            InspectorTest.evaluateInPage(`triggerStylesheetResource()`);
+            let resourceEvent = await WI.Frame.awaitEvent(WI.Frame.Event.ResourceWasAdded);
+            let resource = resourceEvent.data.resource;
+            InspectorTest.expectThat(resource.url.endsWith("stylesheet-with-sourcemap.css"), "Stylesheet Resource should be created.");
+            let sourceMapEvent = await resource.awaitEvent(WI.SourceCode.Event.SourceMapAdded);
+            InspectorTest.expectEqual(resource.sourceMaps.length, 1, "Resource should have loaded 1 SourceMap.");
+            InspectorTest.expectThat(resource.sourceMaps[0] instanceof WI.SourceMap, "SourceMap should be a WI.SourceMap instance.");
+        }
+    });
+
+    suite.addTestCase({
+        name: "Network.SourceMap.Script",
+        description: "Ensure a source map loads for a script resource.",
+        async test(resolve, reject) {
+            InspectorTest.evaluateInPage(`triggerScriptResource()`);
+            let resourceEvent = await WI.Frame.awaitEvent(WI.Frame.Event.ResourceWasAdded);
+            let resource = resourceEvent.data.resource;
+            InspectorTest.expectThat(resource.url.endsWith("script-with-sourcemap.js"), "Script Resource should be created.");
+            let sourceMapEvent = await resource.awaitEvent(WI.SourceCode.Event.SourceMapAdded);
+            InspectorTest.expectEqual(resource.sourceMaps.length, 1, "Resource should have loaded 1 SourceMap.");
+            InspectorTest.expectThat(resource.sourceMaps[0] instanceof WI.SourceMap, "SourceMap should be a WI.SourceMap instance.");
+        }
+    });
+
+    suite.runTestCasesAndFinish();
+}
+</script>
+</head>
+<body _onload_="runTest()">
+<p>Ensure a source map loads for resources with sourceMappingURLs.</p>
+</body>
+</html>

Modified: trunk/Source/WebInspectorUI/ChangeLog (226434 => 226435)


--- trunk/Source/WebInspectorUI/ChangeLog	2018-01-05 04:15:49 UTC (rev 226434)
+++ trunk/Source/WebInspectorUI/ChangeLog	2018-01-05 04:34:07 UTC (rev 226435)
@@ -1,3 +1,24 @@
+2018-01-04  Joseph Pecoraro  <[email protected]>
+
+        REGRESSION (r225709): Web Inspector: CSS Source maps not loading
+        https://bugs.webkit.org/show_bug.cgi?id=181314
+        <rdar://problem/36177620>
+
+        Reviewed by Brian Burg.
+
+        * UserInterface/Controllers/SourceMapManager.js:
+        (WI.SourceMapManager.prototype._loadAndParseSourceMap):
+        * UserInterface/Models/SourceMapResource.js:
+        (WI.SourceMapResource.prototype.requestContentFromBackend):
+        Correct this so that we only fall back to a reasonable frame id
+        if we couldn't determine a frame id from earlier. Previously this
+        was incorrectly clearing the frame id if we had gotten it earlier.
+
+        * UserInterface/Test.html:
+        * UserInterface/Test/Test.js:
+        (WI.loaded):
+        Add SourceMap related files for tests.
+
 2018-01-04  Brian Burg  <[email protected]>
 
         Web Inspector: Capture Element Screenshot looks fuzzy

Modified: trunk/Source/WebInspectorUI/UserInterface/Controllers/SourceMapManager.js (226434 => 226435)


--- trunk/Source/WebInspectorUI/UserInterface/Controllers/SourceMapManager.js	2018-01-05 04:15:49 UTC (rev 226434)
+++ trunk/Source/WebInspectorUI/UserInterface/Controllers/SourceMapManager.js	2018-01-05 04:34:07 UTC (rev 226435)
@@ -136,10 +136,8 @@
         if (originalSourceCode instanceof WI.Resource && originalSourceCode.parentFrame)
             frameIdentifier = originalSourceCode.parentFrame.id;
 
-        if (!frameIdentifier && WI.frameResourceManager.mainFrame)
-            frameIdentifier = WI.frameResourceManager.mainFrame.id;
-        else
-            frameIdentifier = "";
+        if (!frameIdentifier)
+            frameIdentifier = WI.frameResourceManager.mainFrame ? WI.frameResourceManager.mainFrame.id : "";
 
         NetworkAgent.loadResource(frameIdentifier, sourceMapURL, sourceMapLoaded.bind(this));
     }

Modified: trunk/Source/WebInspectorUI/UserInterface/Models/SourceMapResource.js (226434 => 226435)


--- trunk/Source/WebInspectorUI/UserInterface/Models/SourceMapResource.js	2018-01-05 04:15:49 UTC (rev 226434)
+++ trunk/Source/WebInspectorUI/UserInterface/Models/SourceMapResource.js	2018-01-05 04:34:07 UTC (rev 226435)
@@ -140,10 +140,8 @@
         if (this._sourceMap.originalSourceCode instanceof WI.Resource && this._sourceMap.originalSourceCode.parentFrame)
             frameIdentifier = this._sourceMap.originalSourceCode.parentFrame.id;
 
-        if (!frameIdentifier && WI.frameResourceManager.mainFrame)
-            frameIdentifier = WI.frameResourceManager.mainFrame.id;
-        else
-            frameIdentifier = "";
+        if (!frameIdentifier)
+            frameIdentifier = WI.frameResourceManager.mainFrame ? WI.frameResourceManager.mainFrame.id : "";
 
         return NetworkAgent.loadResource(frameIdentifier, this.url).then(sourceMapResourceLoaded.bind(this)).catch(sourceMapResourceLoadError.bind(this));
     }

Modified: trunk/Source/WebInspectorUI/UserInterface/Test/Test.js (226434 => 226435)


--- trunk/Source/WebInspectorUI/UserInterface/Test/Test.js	2018-01-05 04:15:49 UTC (rev 226434)
+++ trunk/Source/WebInspectorUI/UserInterface/Test/Test.js	2018-01-05 04:34:07 UTC (rev 226435)
@@ -60,6 +60,7 @@
     this.memoryManager = new WI.MemoryManager;
     this.timelineManager = new WI.TimelineManager;
     this.debuggerManager = new WI.DebuggerManager;
+    this.sourceMapManager = new WI.SourceMapManager;
     this.layerTreeManager = new WI.LayerTreeManager;
     this.probeManager = new WI.ProbeManager;
     this.workerManager = new WI.WorkerManager;

Modified: trunk/Source/WebInspectorUI/UserInterface/Test.html (226434 => 226435)


--- trunk/Source/WebInspectorUI/UserInterface/Test.html	2018-01-05 04:15:49 UTC (rev 226434)
+++ trunk/Source/WebInspectorUI/UserInterface/Test.html	2018-01-05 04:34:07 UTC (rev 226435)
@@ -185,6 +185,7 @@
     <script src=""
     <script src=""
     <script src=""
+    <script src=""
     <script src=""
     <script src=""
     <script src=""
@@ -216,6 +217,7 @@
     <script src=""
     <script src=""
     <script src=""
+    <script src=""
     <script src=""
     <script src=""
     <script src=""
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to