Diff
Modified: trunk/LayoutTests/ChangeLog (196653 => 196654)
--- trunk/LayoutTests/ChangeLog 2016-02-16 21:16:18 UTC (rev 196653)
+++ trunk/LayoutTests/ChangeLog 2016-02-16 21:17:31 UTC (rev 196654)
@@ -1,3 +1,14 @@
+2016-02-16 Joseph Pecoraro <[email protected]>
+
+ JSContext Inspector: Support for inline source maps
+ https://bugs.webkit.org/show_bug.cgi?id=154303
+ <rdar://problem/24670392>
+
+ Reviewed by Timothy Hatcher.
+
+ * inspector/unit-tests/url-utilities-expected.txt: Added.
+ * inspector/unit-tests/url-utilities.html: Added.
+
2016-02-16 Daniel Bates <[email protected]>
CSP: Disallow an empty host in a host-source source _expression_
Added: trunk/LayoutTests/inspector/unit-tests/url-utilities-expected.txt (0 => 196654)
--- trunk/LayoutTests/inspector/unit-tests/url-utilities-expected.txt (rev 0)
+++ trunk/LayoutTests/inspector/unit-tests/url-utilities-expected.txt 2016-02-16 21:17:31 UTC (rev 196654)
@@ -0,0 +1,74 @@
+
+== Running test suite: URLUtilities
+-- Running test case: parseDataURL
+Test: https://webkit.org
+PASS: Should not be a data URL
+Test: data:
+PASS: Should not be a data URL
+Test: data:text/plain;test
+PASS: Should not be a data URL
+Test: data:text/plain;base64;test
+PASS: Should not be a data URL
+
+Test: data:,
+PASS: mimeType should be: 'text/plain'
+PASS: charset should be: 'US-ASCII'
+PASS: base64 should be: 'false'
+PASS: data should be: ''
+PASS: Resolved content should be: ''
+
+Test: data:,test
+PASS: mimeType should be: 'text/plain'
+PASS: charset should be: 'US-ASCII'
+PASS: base64 should be: 'false'
+PASS: data should be: 'test'
+PASS: Resolved content should be: 'test'
+
+Test: data:text/plain,test
+PASS: mimeType should be: 'text/plain'
+PASS: charset should be: 'US-ASCII'
+PASS: base64 should be: 'false'
+PASS: data should be: 'test'
+PASS: Resolved content should be: 'test'
+
+Test: data:text/plain;charset=TEST,test
+PASS: mimeType should be: 'text/plain'
+PASS: charset should be: 'TEST'
+PASS: base64 should be: 'false'
+PASS: data should be: 'test'
+PASS: Resolved content should be: 'test'
+
+Test: data:application/json,{"name":"test","list":[1,2,3]}
+PASS: mimeType should be: 'application/json'
+PASS: charset should be: 'US-ASCII'
+PASS: base64 should be: 'false'
+PASS: data should be: '{"name":"test","list":[1,2,3]}'
+PASS: Resolved content should be: '{"name":"test","list":[1,2,3]}'
+
+Test: data:application/json,%7B%22name%22%3A%22test%22%2C%22list%22%3A%5B1%2C2%2C3%5D%7D
+PASS: mimeType should be: 'application/json'
+PASS: charset should be: 'US-ASCII'
+PASS: base64 should be: 'false'
+PASS: data should be: '{"name":"test","list":[1,2,3]}'
+PASS: Resolved content should be: '{"name":"test","list":[1,2,3]}'
+
+Test: data:application/json;base64,eyJuYW1lIjoidGVzdCIsImxpc3QiOlsxLDIsM119
+PASS: mimeType should be: 'application/json'
+PASS: charset should be: 'US-ASCII'
+PASS: base64 should be: 'true'
+PASS: data should be: 'eyJuYW1lIjoidGVzdCIsImxpc3QiOlsxLDIsM119'
+PASS: Resolved content should be: '{"name":"test","list":[1,2,3]}'
+
+Test: data:application/json;charset=utf-8;base64,eyJuYW1lIjoidGVzdCIsImxpc3QiOlsxLDIsM119
+PASS: mimeType should be: 'application/json'
+PASS: charset should be: 'utf-8'
+PASS: base64 should be: 'true'
+PASS: data should be: 'eyJuYW1lIjoidGVzdCIsImxpc3QiOlsxLDIsM119'
+PASS: Resolved content should be: '{"name":"test","list":[1,2,3]}'
+
+Test: data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAUAAAAFCAYAAACNbyblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DHxgljNBAAO9TXL0Y4OHwAAAABJRU5ErkJggg==
+PASS: mimeType should be: 'image/png'
+PASS: charset should be: 'US-ASCII'
+PASS: base64 should be: 'true'
+PASS: data should be: 'iVBORw0KGgoAAAANSUhEUgAAAAUAAAAFCAYAAACNbyblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DHxgljNBAAO9TXL0Y4OHwAAAABJRU5ErkJggg=='
+
Added: trunk/LayoutTests/inspector/unit-tests/url-utilities.html (0 => 196654)
--- trunk/LayoutTests/inspector/unit-tests/url-utilities.html (rev 0)
+++ trunk/LayoutTests/inspector/unit-tests/url-utilities.html 2016-02-16 21:17:31 UTC (rev 196654)
@@ -0,0 +1,125 @@
+<!DOCTYPE html>
+<html>
+<head>
+<script src=""
+<script>
+function test()
+{
+ let suite = InspectorTest.createSyncSuite("URLUtilities");
+
+ suite.addTestCase({
+ name: "parseDataURL",
+ test: () => {
+ function testInvalid(url) {
+ InspectorTest.log("Test: " + url);
+ InspectorTest.expectThat(parseDataURL(url) === null, "Should not be a data URL");
+ }
+
+ function testValid(url, expected) {
+ InspectorTest.log("");
+ InspectorTest.log("Test: " + url);
+
+ let {mimeType: expectedMimeType, charset: expectedCharset, base64: expectedBase64, data: expectedData, content: expectedContent} = expected;
+ let {mimeType: actualMimeType, charset: actualCharset, base64: actualBase64, data: actualData, scheme: actualScheme} = parseDataURL(url);
+ let actualContent = actualData;
+ if (actualBase64)
+ actualContent = atob(actualContent);
+
+ InspectorTest.assert(actualScheme === "data", "scheme should always be 'data'");
+ InspectorTest.expectThat(actualMimeType === expectedMimeType, `mimeType should be: '${expectedMimeType}'`);
+ InspectorTest.expectThat(actualCharset === expectedCharset, `charset should be: '${expectedCharset}'`);
+ InspectorTest.expectThat(actualBase64 === expectedBase64, `base64 should be: '${expectedBase64}'`);
+ InspectorTest.expectThat(actualData === expectedData, `data should be: '${expectedData}'`);
+ if (expectedContent !== null)
+ InspectorTest.expectThat(actualContent === expectedContent, `Resolved content should be: '${expectedContent}'`);
+ }
+
+ testInvalid("https://webkit.org");
+ testInvalid("data:");
+ testInvalid("data:text/plain;test");
+ testInvalid("data:text/plain;base64;test");
+
+ testValid("data:,", {
+ mimeType: "text/plain",
+ charset: "US-ASCII",
+ base64: false,
+ data: "",
+ content: "",
+ });
+
+ testValid("data:,test", {
+ mimeType: "text/plain",
+ charset: "US-ASCII",
+ base64: false,
+ data: "test",
+ content: "test",
+ });
+
+ testValid("data:text/plain,test", {
+ mimeType: "text/plain",
+ charset: "US-ASCII",
+ base64: false,
+ data: "test",
+ content: "test",
+ });
+
+ testValid("data:text/plain;charset=TEST,test", {
+ mimeType: "text/plain",
+ charset: "TEST",
+ base64: false,
+ data: "test",
+ content: "test",
+ });
+
+ testValid("data:application/json,{\"name\":\"test\",\"list\":[1,2,3]}", {
+ mimeType: "application/json",
+ charset: "US-ASCII",
+ base64: false,
+ data: '{"name":"test","list":[1,2,3]}',
+ content: '{"name":"test","list":[1,2,3]}',
+ });
+
+ InspectorTest.assert(encodeURIComponent('{"name":"test","list":[1,2,3]}') === "%7B%22name%22%3A%22test%22%2C%22list%22%3A%5B1%2C2%2C3%5D%7D");
+ testValid("data:application/json,%7B%22name%22%3A%22test%22%2C%22list%22%3A%5B1%2C2%2C3%5D%7D", {
+ mimeType: "application/json",
+ charset: "US-ASCII",
+ base64: false,
+ data: '{"name":"test","list":[1,2,3]}',
+ content: '{"name":"test","list":[1,2,3]}',
+ });
+
+ testValid("data:application/json;base64,eyJuYW1lIjoidGVzdCIsImxpc3QiOlsxLDIsM119", {
+ mimeType: "application/json",
+ charset: "US-ASCII",
+ base64: true,
+ data: "eyJuYW1lIjoidGVzdCIsImxpc3QiOlsxLDIsM119",
+ content: '{"name":"test","list":[1,2,3]}',
+ });
+
+ testValid("data:application/json;charset=utf-8;base64,eyJuYW1lIjoidGVzdCIsImxpc3QiOlsxLDIsM119", {
+ mimeType: "application/json",
+ charset: "utf-8",
+ base64: true,
+ data: "eyJuYW1lIjoidGVzdCIsImxpc3QiOlsxLDIsM119",
+ content: '{"name":"test","list":[1,2,3]}',
+ });
+
+ testValid("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAUAAAAFCAYAAACNbyblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DHxgljNBAAO9TXL0Y4OHwAAAABJRU5ErkJggg==", {
+ mimeType: "image/png",
+ charset: "US-ASCII",
+ base64: true,
+ data: "iVBORw0KGgoAAAANSUhEUgAAAAUAAAAFCAYAAACNbyblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DHxgljNBAAO9TXL0Y4OHwAAAABJRU5ErkJggg==",
+ content: null, // Skip content check.
+ });
+
+ return true;
+ }
+ });
+
+ suite.runTestCasesAndFinish();
+}
+</script>
+</head>
+<body _onLoad_="runTest()">
+</body>
+</html>
Modified: trunk/Source/WebInspectorUI/ChangeLog (196653 => 196654)
--- trunk/Source/WebInspectorUI/ChangeLog 2016-02-16 21:16:18 UTC (rev 196653)
+++ trunk/Source/WebInspectorUI/ChangeLog 2016-02-16 21:17:31 UTC (rev 196654)
@@ -1,3 +1,35 @@
+2016-02-16 Joseph Pecoraro <[email protected]>
+
+ JSContext Inspector: Support for inline source maps
+ https://bugs.webkit.org/show_bug.cgi?id=154303
+ <rdar://problem/24670392>
+
+ Reviewed by Timothy Hatcher.
+
+ * UserInterface/Base/URLUtilities.js:
+ (parseDataURL):
+ Break a data URL into components.
+
+ * UserInterface/Controllers/SourceMapManager.js:
+ (WebInspector.SourceMapManager.prototype._loadAndParseSourceMap):
+ Handle a data URL without using NetworkAgent. Also move references
+ to a main frame after checking for NetworkAgent.
+
+ * UserInterface/Models/SourceMap.js:
+ (WebInspector.SourceMap.prototype.get sourceMappingBasePathURLComponents):
+ * UserInterface/Models/SourceMapResource.js:
+ (WebInspector.SourceMapResource.prototype.get sourceMapDisplaySubpath):
+ Handle _javascript_ debuggable script URLs which may not be complete URLs.
+
+ (WebInspector.SourceMapResource.prototype.requestContentFromBackend):
+ Also handle if NetworkAgent does not exist.
+
+ * UserInterface/Views/ResourceSidebarPanel.js:
+ (WebInspector.ResourceSidebarPanel):
+ When connected to a _javascript_ debuggable we were hiding disclosure
+ triangles as we did not expect resources to have subresources. If
+ a SourceMap is added, show them again.
+
2016-02-16 Nikita Vasilyev <[email protected]>
Web Inspector: Increase the width of the find banner's search field
Modified: trunk/Source/WebInspectorUI/UserInterface/Base/URLUtilities.js (196653 => 196654)
--- trunk/Source/WebInspectorUI/UserInterface/Base/URLUtilities.js 2016-02-16 21:16:18 UTC (rev 196653)
+++ trunk/Source/WebInspectorUI/UserInterface/Base/URLUtilities.js 2016-02-16 21:17:31 UTC (rev 196654)
@@ -70,6 +70,25 @@
return {scheme, host, port};
}
+function parseDataURL(url)
+{
+ if (!url.startsWith("data:"))
+ return null;
+
+ // data:[<media type>][;charset=<character set>][;base64],<data>
+ let match = url.match(/^data:([^;,]*)?(?:;charset=([^;,]*?))?(;base64)?,(.*)$/);
+ if (!match)
+ return null;
+
+ let scheme = "data";
+ let mimeType = match[1] || "text/plain";
+ let charset = match[2] || "US-ASCII";
+ let base64 = !!match[3];
+ let data = ""
+
+ return {scheme, mimeType, charset, base64, data};
+}
+
function parseURL(url)
{
url = "" ? url.trim() : "";
Modified: trunk/Source/WebInspectorUI/UserInterface/Controllers/SourceMapManager.js (196653 => 196654)
--- trunk/Source/WebInspectorUI/UserInterface/Controllers/SourceMapManager.js 2016-02-16 21:16:18 UTC (rev 196653)
+++ trunk/Source/WebInspectorUI/UserInterface/Controllers/SourceMapManager.js 2016-02-16 21:17:31 UTC (rev 196654)
@@ -108,6 +108,20 @@
}
}
+ if (sourceMapURL.startsWith("data:")) {
+ let {mimeType, base64, data} = parseDataURL(sourceMapURL);
+ let content = base64 ? atob(data) : data;
+ sourceMapLoaded.call(this, null, content, mimeType, 0);
+ return;
+ }
+
+ // COMPATIBILITY (iOS 7): Network.loadResource did not exist.
+ // Also, _javascript_ Debuggable may reach this.
+ if (!window.NetworkAgent || !NetworkAgent.loadResource) {
+ this._loadAndParseFailed(sourceMapURL);
+ return;
+ }
+
var frameIdentifier = null;
if (originalSourceCode instanceof WebInspector.Resource && originalSourceCode.parentFrame)
frameIdentifier = originalSourceCode.parentFrame.id;
@@ -115,12 +129,6 @@
if (!frameIdentifier)
frameIdentifier = WebInspector.frameResourceManager.mainFrame.id;
- // COMPATIBILITY (iOS 7): Network.loadResource did not exist.
- if (!NetworkAgent.loadResource) {
- this._loadAndParseFailed(sourceMapURL);
- return;
- }
-
NetworkAgent.loadResource(frameIdentifier, sourceMapURL, sourceMapLoaded.bind(this));
}
Modified: trunk/Source/WebInspectorUI/UserInterface/Models/SourceMap.js (196653 => 196654)
--- trunk/Source/WebInspectorUI/UserInterface/Models/SourceMap.js 2016-02-16 21:16:18 UTC (rev 196653)
+++ trunk/Source/WebInspectorUI/UserInterface/Models/SourceMap.js 2016-02-16 21:17:31 UTC (rev 196654)
@@ -74,6 +74,11 @@
}
var urlComponents = parseURL(this._sourceMappingURL);
+
+ // Fallback for _javascript_ debuggable named scripts that may not have a complete URL.
+ if (!urlComponents.path)
+ urlComponents.path = this._sourceMappingURL;
+
urlComponents.path = urlComponents.path.substr(0, urlComponents.path.lastIndexOf(urlComponents.lastPathComponent));
urlComponents.lastPathComponent = null;
this._sourceMappingURLBasePathComponents = urlComponents;
Modified: trunk/Source/WebInspectorUI/UserInterface/Models/SourceMapResource.js (196653 => 196654)
--- trunk/Source/WebInspectorUI/UserInterface/Models/SourceMapResource.js 2016-02-16 21:16:18 UTC (rev 196653)
+++ trunk/Source/WebInspectorUI/UserInterface/Models/SourceMapResource.js 2016-02-16 21:17:31 UTC (rev 196654)
@@ -61,6 +61,10 @@
var sourceMappingBasePathURLComponents = this._sourceMap.sourceMappingBasePathURLComponents;
var resourceURLComponents = this.urlComponents;
+ // Fallback for _javascript_ debuggable named scripts that may not have a complete URL.
+ if (!resourceURLComponents.path)
+ resourceURLComponents.path = this.url;
+
// Different schemes / hosts. Return the host + path of this resource.
if (resourceURLComponents.scheme !== sourceMappingBasePathURLComponents.scheme || resourceURLComponents.host !== sourceMappingBasePathURLComponents.host)
return resourceURLComponents.host + (resourceURLComponents.port ? (":" + resourceURLComponents.port) : "") + resourceURLComponents.path;
@@ -128,7 +132,8 @@
}
// COMPATIBILITY (iOS 7): Network.loadResource did not exist.
- if (!NetworkAgent.loadResource)
+ // Also, _javascript_ Debuggable with SourceMaps that do not have inlined content may reach this.
+ if (!window.NetworkAgent || !NetworkAgent.loadResource)
return sourceMapResourceLoadError.call(this);
var frameIdentifier = null;
Modified: trunk/Source/WebInspectorUI/UserInterface/Views/ResourceSidebarPanel.js (196653 => 196654)
--- trunk/Source/WebInspectorUI/UserInterface/Views/ResourceSidebarPanel.js 2016-02-16 21:16:18 UTC (rev 196653)
+++ trunk/Source/WebInspectorUI/UserInterface/Views/ResourceSidebarPanel.js 2016-02-16 21:17:31 UTC (rev 196654)
@@ -66,8 +66,10 @@
this.contentTreeOutline.addEventListener(WebInspector.TreeOutline.Event.SelectionDidChange, this._treeSelectionDidChange, this);
this.contentTreeOutline.includeSourceMapResourceChildren = true;
- if (WebInspector.debuggableType === WebInspector.DebuggableType._javascript_)
+ if (WebInspector.debuggableType === WebInspector.DebuggableType._javascript_) {
this.contentTreeOutline.disclosureButtons = false;
+ WebInspector.SourceCode.addEventListener(WebInspector.SourceCode.Event.SourceMapAdded, () => { this.contentTreeOutline.disclosureButtons = true }, this);
+ }
if (WebInspector.frameResourceManager.mainFrame)
this._mainFrameMainResourceDidChange(WebInspector.frameResourceManager.mainFrame);