Diff
Modified: trunk/LayoutTests/ChangeLog (148767 => 148768)
--- trunk/LayoutTests/ChangeLog 2013-04-19 21:02:21 UTC (rev 148767)
+++ trunk/LayoutTests/ChangeLog 2013-04-19 21:06:03 UTC (rev 148768)
@@ -1,3 +1,19 @@
+2013-04-19 Joseph Pecoraro <[email protected]>
+
+ Web Inspector: Backend should detect sourceMappingURLs in CSS Resources
+ https://bugs.webkit.org/show_bug.cgi?id=114854
+
+ Test a different ways we would expect to see a sourceMapURL for
+ stylesheet resources.
+
+ Reviewed by Timothy Hatcher.
+
+ * http/tests/inspector/network/css-source-mapping-url-expected.txt: Added.
+ * http/tests/inspector/network/css-source-mapping-url.html: Added.
+ * http/tests/inspector/network/resources/source-map-test-style.css: Added.
+ * http/tests/inspector/network/resources/source-map-test-style.css.map: Added.
+ * http/tests/inspector/network/resources/source-map-test-style.scss: Added.
+
2013-04-19 Sudarsana Nagineni <[email protected]>
[EFL] Unreviewed Gardening.
Added: trunk/LayoutTests/http/tests/inspector/network/css-source-mapping-url-expected.txt (0 => 148768)
--- trunk/LayoutTests/http/tests/inspector/network/css-source-mapping-url-expected.txt (rev 0)
+++ trunk/LayoutTests/http/tests/inspector/network/css-source-mapping-url-expected.txt 2013-04-19 21:06:03 UTC (rev 148768)
@@ -0,0 +1,7 @@
+Tests that the extraResourceInfo in Network.loadingFinished contains a sourceMapURL for a Stylesheet containing a sourceMappingURL. Also then tests that Page.getResourceTree contains the sourceMapURL for the resource.
+
+Response received for style.css
+Network.loadingFailed extraResourceInfo contains a sourceMapURL: source-map-test-style.css.map
+Page.getResourceTree resourcePayload contains sourceMapURL: source-map-test-style.css.map
+SUCCESS
+
Added: trunk/LayoutTests/http/tests/inspector/network/css-source-mapping-url.html (0 => 148768)
--- trunk/LayoutTests/http/tests/inspector/network/css-source-mapping-url.html (rev 0)
+++ trunk/LayoutTests/http/tests/inspector/network/css-source-mapping-url.html 2013-04-19 21:06:03 UTC (rev 148768)
@@ -0,0 +1,88 @@
+<html>
+<head>
+<script src=""
+<script>
+function loadStylesheetWithSourceMappingURL()
+{
+ var link = document.createElement("link");
+ link.rel = "stylesheet";
+ link.type = "text/css";
+ link.href = ""
+ document.head.appendChild(link);
+}
+
+function test()
+{
+ InspectorTest.addSniffer(WebInspector.NetworkDispatcher.prototype, "loadingFinished", loadingFinished);
+ InspectorTest.addSniffer(WebInspector.NetworkDispatcher.prototype, "loadingFailed", loadingFailed);
+
+ InspectorTest.evaluateInPage("loadStylesheetWithSourceMappingURL()");
+
+ function loadingFinished(requestId, timestamp, sourceMapURL)
+ {
+ var request = WebInspector.networkLog.requestForId(requestId);
+ if (/source-map-test-style\.css$/.exec(request.url)) {
+ InspectorTest.addResult("Response received for style.css");
+ if (sourceMapURL) {
+ InspectorTest.addResult("Network.loadingFailed extraResourceInfo contains a sourceMapURL: " + sourceMapURL);
+ afterLoadingResource();
+ } else {
+ InspectorTest.addResult("Network.loadingFailed extraResourceInfo missing sourceMapURL");
+ InspectorTest.addResult("FAILURE");
+ InspectorTest.completeTest();
+ }
+ }
+ }
+
+ function loadingFailed(requestId, time, localizedDescription, canceled)
+ {
+ var request = WebInspector.networkLog.requestForId(requestId);
+ if (/source-map-test-style\.css$/.exec(request.url)) {
+ InspectorTest.addResult("Failed to load source-map-test-style.css");
+ InspectorTest.addResult("FAILURE");
+ InspectorTest.completeTest();
+ }
+ }
+
+ function afterLoadingResource()
+ {
+ PageAgent.getResourceTree(processResourceTree);
+
+ function processResourceTree(error, mainFramePayload)
+ {
+ if (error) {
+ InspectorTest.addResult("Page.getResourceTree error: " + error);
+ InspectorTest.addResult("FAILURE");
+ InspectorTest.completeTest();
+ return;
+ }
+
+ var resources = mainFramePayload.resources;
+ for (var i = 0; i < resources.length; ++i) {
+ var resourcePayload = resources[i];
+ if (/source-map-test-style\.css$/.exec(resourcePayload.url)) {
+ if (resourcePayload.sourceMapURL) {
+ InspectorTest.addResult("Page.getResourceTree resourcePayload contains sourceMapURL: " + resourcePayload.sourceMapURL);
+ InspectorTest.addResult("SUCCESS");
+ InspectorTest.completeTest();
+ } else {
+ InspectorTest.addResult("Page.getResourceTree resourcePayload missing sourceMapURL");
+ InspectorTest.addResult("FAILURE");
+ InspectorTest.completeTest();
+ }
+ return;
+ }
+ }
+
+ InspectorTest.addResult("Page.getResourceTree missing source-map-test-style.css");
+ InspectorTest.addResult("FAILURE");
+ InspectorTest.completeTest();
+ }
+ }
+}
+</script>
+</head>
+<body _onload_="runTest()">
+<p>Tests that the extraResourceInfo in Network.loadingFinished contains a sourceMapURL for a Stylesheet containing a sourceMappingURL. Also then tests that Page.getResourceTree contains the sourceMapURL for the resource.</p>
+</body>
+</html>
Added: trunk/LayoutTests/http/tests/inspector/network/resources/source-map-test-style.css (0 => 148768)
--- trunk/LayoutTests/http/tests/inspector/network/resources/source-map-test-style.css (rev 0)
+++ trunk/LayoutTests/http/tests/inspector/network/resources/source-map-test-style.css 2013-04-19 21:06:03 UTC (rev 148768)
@@ -0,0 +1,6 @@
+#container {
+ background: papayawhip; }
+ #container #inspected {
+ color: green; }
+
+/*@ sourceMappingURL=source-map-test-style.css.map */
\ No newline at end of file
Added: trunk/LayoutTests/http/tests/inspector/network/resources/source-map-test-style.css.map (0 => 148768)
--- trunk/LayoutTests/http/tests/inspector/network/resources/source-map-test-style.css.map (rev 0)
+++ trunk/LayoutTests/http/tests/inspector/network/resources/source-map-test-style.css.map 2013-04-19 21:06:03 UTC (rev 148768)
@@ -0,0 +1,6 @@
+{
+"version": "3",
+"mappings": "AAAA,UAAW;EACP,UAAU,EAAE,UAAU;EAEtB,qBAAW;IACP,KAAK,EAAE,KAAK",
+"sources": ["style.scss"],
+"file": "style.css"
+}
Added: trunk/LayoutTests/http/tests/inspector/network/resources/source-map-test-style.scss (0 => 148768)
--- trunk/LayoutTests/http/tests/inspector/network/resources/source-map-test-style.scss (rev 0)
+++ trunk/LayoutTests/http/tests/inspector/network/resources/source-map-test-style.scss 2013-04-19 21:06:03 UTC (rev 148768)
@@ -0,0 +1,7 @@
+#container {
+ background: papayawhip;
+
+ #inspected {
+ color: green;
+ }
+}
Modified: trunk/Source/WebCore/ChangeLog (148767 => 148768)
--- trunk/Source/WebCore/ChangeLog 2013-04-19 21:02:21 UTC (rev 148767)
+++ trunk/Source/WebCore/ChangeLog 2013-04-19 21:06:03 UTC (rev 148768)
@@ -1,3 +1,46 @@
+2013-04-19 Joseph Pecoraro <[email protected]>
+
+ Web Inspector: Backend should detect sourceMappingURLs in CSS Resources
+ https://bugs.webkit.org/show_bug.cgi?id=114854
+
+ Reviewed by Timothy Hatcher.
+
+ Test: http/tests/inspector/network/css-source-mapping-url.html
+
+ * inspector/Inspector.json:
+ - Page.getResourceTree - add sourceMapURL to resource payloads
+ - Network.loadingFinished and Network.requestServedFromMemoryCache,
+ include the sourceMapURL in the results.
+
+ * inspector/ContentSearchUtils.h:
+ * inspector/ContentSearchUtils.cpp:
+ (WebCore::ContentSearchUtils::scriptCommentPattern):
+ (WebCore::ContentSearchUtils::stylesheetCommentPattern):
+ (WebCore::ContentSearchUtils::findMagicComment):
+ (WebCore::ContentSearchUtils::findScriptSourceURL):
+ (WebCore::ContentSearchUtils::findScriptSourceMapURL):
+ (WebCore::ContentSearchUtils::findStylesheetSourceMapURL):
+ Separate Script and Stylesheet regex pattern creation, but
+ share the search function using the pattern.
+
+ * inspector/InspectorDebuggerAgent.cpp:
+ (WebCore::InspectorDebuggerAgent::sourceMapURLForScript):
+ (WebCore::InspectorDebuggerAgent::didParseSource):
+ Update function names. Check for the SourceMap header before
+ checking for a sourceMappingURL comment.
+
+ * inspector/InspectorPageAgent.h:
+ * inspector/InspectorPageAgent.cpp:
+ (WebCore::InspectorPageAgent::sourceMapURLForResource):
+ (WebCore::InspectorPageAgent::buildObjectForFrameTree):
+ Provide the sourceMapURL for Page.getResourceTree.
+
+ * inspector/InspectorResourceAgent.cpp:
+ (WebCore::buildObjectForCachedResource):
+ (WebCore::InspectorResourceAgent::didFinishLoading):
+ (WebCore::InspectorResourceAgent::didLoadResourceFromMemoryCache):
+ Include sourceMapURLs in finish loading and request served from cache.
+
2013-04-19 Shawn Singh <[email protected]>
Remove non-overlap testing code in RenderLayerCompositor
Modified: trunk/Source/WebCore/inspector/ContentSearchUtils.cpp (148767 => 148768)
--- trunk/Source/WebCore/inspector/ContentSearchUtils.cpp 2013-04-19 21:02:21 UTC (rev 148767)
+++ trunk/Source/WebCore/inspector/ContentSearchUtils.cpp 2013-04-19 21:06:03 UTC (rev 148768)
@@ -168,9 +168,20 @@
return result;
}
-static String findMagicComment(const String& content, const String& name)
+static String scriptCommentPattern(const String& name)
{
- String patternString = "//@[\040\t]" + name + "=[\040\t]*([^\\s\'\"]*)[\040\t]*$";
+ // "//@ <name>=<value>"
+ return "//@[\040\t]" + name + "=[\040\t]*([^\\s\'\"]*)[\040\t]*$";
+}
+
+static String stylesheetCommentPattern(const String& name)
+{
+ // "/*@ <name>=<value> */"
+ return "/\\*@[\040\t]" + name + "=[\040\t]*([^\\s\'\"]*)[\040\t]*\\*/";
+}
+
+static String findMagicComment(const String& content, const String& patternString)
+{
const char* error = 0;
JSC::Yarr::YarrPattern pattern(patternString, false, true, &error);
ASSERT(!error);
@@ -188,16 +199,21 @@
return content.substring(matches[2], matches[3] - matches[2]);
}
-String findSourceURL(const String& content)
+String findScriptSourceURL(const String& content)
{
- return findMagicComment(content, "sourceURL");
+ return findMagicComment(content, scriptCommentPattern("sourceURL"));
}
-String findSourceMapURL(const String& content)
+String findScriptSourceMapURL(const String& content)
{
- return findMagicComment(content, "sourceMappingURL");
+ return findMagicComment(content, scriptCommentPattern("sourceMappingURL"));
}
+String findStylesheetSourceMapURL(const String& content)
+{
+ return findMagicComment(content, stylesheetCommentPattern("sourceMappingURL"));
+}
+
} // namespace ContentSearchUtils
} // namespace WebCore
Modified: trunk/Source/WebCore/inspector/ContentSearchUtils.h (148767 => 148768)
--- trunk/Source/WebCore/inspector/ContentSearchUtils.h 2013-04-19 21:02:21 UTC (rev 148767)
+++ trunk/Source/WebCore/inspector/ContentSearchUtils.h 2013-04-19 21:06:03 UTC (rev 148768)
@@ -49,8 +49,9 @@
TextPosition textPositionFromOffset(size_t offset, const Vector<size_t>& lineEndings);
PassOwnPtr<Vector<size_t> > lineEndings(const String&);
-String findSourceURL(const String& content);
-String findSourceMapURL(const String& content);
+String findScriptSourceURL(const String& content);
+String findScriptSourceMapURL(const String& content);
+String findStylesheetSourceMapURL(const String& content);
} // namespace ContentSearchUtils
} // namespace WebCore
Modified: trunk/Source/WebCore/inspector/Inspector.json (148767 => 148768)
--- trunk/Source/WebCore/inspector/Inspector.json 2013-04-19 21:02:21 UTC (rev 148767)
+++ trunk/Source/WebCore/inspector/Inspector.json 2013-04-19 21:06:03 UTC (rev 148768)
@@ -135,7 +135,8 @@
{ "name": "type", "$ref": "ResourceType", "description": "Type of this resource." },
{ "name": "mimeType", "type": "string", "description": "Resource mimeType as determined by the browser." },
{ "name": "failed", "type": "boolean", "optional": true, "description": "True if the resource failed to load." },
- { "name": "canceled", "type": "boolean", "optional": true, "description": "True if the resource was canceled during loading." }
+ { "name": "canceled", "type": "boolean", "optional": true, "description": "True if the resource was canceled during loading." },
+ { "name": "sourceMapURL", "type": "string", "optional": true, "description": "URL of source map associated with this resource (if any)." }
]
},
"description": "Information about frame resources."
@@ -975,7 +976,8 @@
{ "name": "url", "type": "string", "description": "Resource URL. This is the url of the original network request." },
{ "name": "type", "$ref": "Page.ResourceType", "description": "Type of this resource." },
{ "name": "response", "$ref": "Response", "optional": true, "description": "Cached response data." },
- { "name": "bodySize", "type": "number", "description": "Cached response body size." }
+ { "name": "bodySize", "type": "number", "description": "Cached response body size." },
+ { "name": "sourceMapURL", "type": "string", "optional": true, "description": "URL of source map associated with this resource (if any)." }
]
},
{
@@ -1111,7 +1113,8 @@
"description": "Fired when HTTP request has finished loading.",
"parameters": [
{ "name": "requestId", "$ref": "RequestId", "description": "Request identifier." },
- { "name": "timestamp", "$ref": "Timestamp", "description": "Timestamp." }
+ { "name": "timestamp", "$ref": "Timestamp", "description": "Timestamp." },
+ { "name": "sourceMapURL", "type": "string", "optional": true, "description": "URL of source map associated with this resource (if any)." }
]
},
{
Modified: trunk/Source/WebCore/inspector/InspectorDebuggerAgent.cpp (148767 => 148768)
--- trunk/Source/WebCore/inspector/InspectorDebuggerAgent.cpp 2013-04-19 21:02:21 UTC (rev 148767)
+++ trunk/Source/WebCore/inspector/InspectorDebuggerAgent.cpp 2013-04-19 21:06:03 UTC (rev 148768)
@@ -632,23 +632,20 @@
String InspectorDebuggerAgent::sourceMapURLForScript(const Script& script)
{
- DEFINE_STATIC_LOCAL(String, sourceMapHttpHeader, (ASCIILiteral("X-SourceMap")));
+ DEFINE_STATIC_LOCAL(String, sourceMapHTTPHeader, (ASCIILiteral("X-SourceMap")));
- String sourceMapURL = ContentSearchUtils::findSourceMapURL(script.source);
- if (!sourceMapURL.isEmpty())
- return sourceMapURL;
+ if (!script.url.isEmpty()) {
+ if (InspectorPageAgent* pageAgent = m_instrumentingAgents->inspectorPageAgent()) {
+ CachedResource* resource = pageAgent->cachedResource(pageAgent->mainFrame(), KURL(ParsedURLString, script.url));
+ if (resource) {
+ String sourceMapHeader = resource->response().httpHeaderField(sourceMapHTTPHeader);
+ if (!sourceMapHeader.isEmpty())
+ return sourceMapHeader;
+ }
+ }
+ }
- if (script.url.isEmpty())
- return String();
-
- InspectorPageAgent* pageAgent = m_instrumentingAgents->inspectorPageAgent();
- if (!pageAgent)
- return String();
-
- CachedResource* resource = pageAgent->cachedResource(pageAgent->mainFrame(), KURL(ParsedURLString, script.url));
- if (resource)
- return resource->response().httpHeaderField(sourceMapHttpHeader);
- return String();
+ return ContentSearchUtils::findScriptSourceMapURL(script.source);
}
// _javascript_DebugListener functions
@@ -661,7 +658,7 @@
String* sourceMapURLParam = sourceMapURL.isNull() ? 0 : &sourceMapURL;
String sourceURL;
if (!script.startLine && !script.startColumn)
- sourceURL = ContentSearchUtils::findSourceURL(script.source);
+ sourceURL = ContentSearchUtils::findScriptSourceURL(script.source);
bool hasSourceURL = !sourceURL.isEmpty();
String scriptURL = hasSourceURL ? sourceURL : script.url;
bool* hasSourceURLParam = hasSourceURL ? &hasSourceURL : 0;
Modified: trunk/Source/WebCore/inspector/InspectorPageAgent.cpp (148767 => 148768)
--- trunk/Source/WebCore/inspector/InspectorPageAgent.cpp 2013-04-19 21:02:21 UTC (rev 148767)
+++ trunk/Source/WebCore/inspector/InspectorPageAgent.cpp 2013-04-19 21:06:03 UTC (rev 148768)
@@ -267,6 +267,30 @@
*errorString = "No resource with given URL found";
}
+//static
+String InspectorPageAgent::sourceMapURLForResource(CachedResource* cachedResource)
+{
+ DEFINE_STATIC_LOCAL(String, sourceMapHTTPHeader, (ASCIILiteral("X-SourceMap")));
+
+ if (!cachedResource)
+ return String();
+
+ // Scripts are handled in a separate path.
+ if (cachedResource->type() != CachedResource::CSSStyleSheet)
+ return String();
+
+ String sourceMapHeader = cachedResource->response().httpHeaderField(sourceMapHTTPHeader);
+ if (!sourceMapHeader.isEmpty())
+ return sourceMapHeader;
+
+ String content;
+ bool base64Encoded;
+ if (InspectorPageAgent::cachedResourceContent(cachedResource, &content, &base64Encoded) && !base64Encoded)
+ return ContentSearchUtils::findStylesheetSourceMapURL(content);
+
+ return String();
+}
+
CachedResource* InspectorPageAgent::cachedResource(Frame* frame, const KURL& url)
{
CachedResource* cachedResource = frame->document()->cachedResourceLoader()->cachedResource(url);
@@ -1114,6 +1138,9 @@
resourceObject->setCanceled(true);
else if (cachedResource->status() == CachedResource::LoadError)
resourceObject->setFailed(true);
+ String sourceMappingURL = InspectorPageAgent::sourceMapURLForResource(cachedResource);
+ if (!sourceMappingURL.isEmpty())
+ resourceObject->setSourceMapURL(sourceMappingURL);
subresources->addItem(resourceObject);
}
Modified: trunk/Source/WebCore/inspector/InspectorPageAgent.h (148767 => 148768)
--- trunk/Source/WebCore/inspector/InspectorPageAgent.h 2013-04-19 21:02:21 UTC (rev 148767)
+++ trunk/Source/WebCore/inspector/InspectorPageAgent.h 2013-04-19 21:06:03 UTC (rev 148768)
@@ -86,6 +86,7 @@
static bool cachedResourceContent(CachedResource*, String* result, bool* base64Encoded);
static bool sharedBufferContent(PassRefPtr<SharedBuffer>, const String& textEncodingName, bool withBase64Encode, String* result);
static void resourceContent(ErrorString*, Frame*, const KURL&, String* result, bool* base64Encoded);
+ static String sourceMapURLForResource(CachedResource*);
static PassRefPtr<SharedBuffer> resourceData(Frame*, const KURL&, String* textEncodingName);
static CachedResource* cachedResource(Frame*, const KURL&);
Modified: trunk/Source/WebCore/inspector/InspectorResourceAgent.cpp (148767 => 148768)
--- trunk/Source/WebCore/inspector/InspectorResourceAgent.cpp 2013-04-19 21:02:21 UTC (rev 148767)
+++ trunk/Source/WebCore/inspector/InspectorResourceAgent.cpp 2013-04-19 21:06:03 UTC (rev 148768)
@@ -167,15 +167,21 @@
return responseObject;
}
-static PassRefPtr<TypeBuilder::Network::CachedResource> buildObjectForCachedResource(const CachedResource& cachedResource, DocumentLoader* loader)
+static PassRefPtr<TypeBuilder::Network::CachedResource> buildObjectForCachedResource(CachedResource* cachedResource, DocumentLoader* loader)
{
RefPtr<TypeBuilder::Network::CachedResource> resourceObject = TypeBuilder::Network::CachedResource::create()
- .setUrl(cachedResource.url())
- .setType(InspectorPageAgent::cachedResourceTypeJson(cachedResource))
- .setBodySize(cachedResource.encodedSize());
- RefPtr<TypeBuilder::Network::Response> resourceResponse = buildObjectForResourceResponse(cachedResource.response(), loader);
+ .setUrl(cachedResource->url())
+ .setType(InspectorPageAgent::cachedResourceTypeJson(*cachedResource))
+ .setBodySize(cachedResource->encodedSize());
+
+ RefPtr<TypeBuilder::Network::Response> resourceResponse = buildObjectForResourceResponse(cachedResource->response(), loader);
if (resourceResponse)
resourceObject->setResponse(resourceResponse);
+
+ String sourceMappingURL = InspectorPageAgent::sourceMapURLForResource(cachedResource);
+ if (!sourceMappingURL.isEmpty())
+ resourceObject->setSourceMapURL(sourceMappingURL);
+
return resourceObject;
}
@@ -292,7 +298,12 @@
if (!finishTime)
finishTime = currentTime();
- m_frontend->loadingFinished(requestId, finishTime);
+ String sourceMappingURL;
+ NetworkResourcesData::ResourceData const* resourceData = m_resourcesData->data(requestId);
+ if (resourceData && resourceData->cachedResource())
+ sourceMappingURL = InspectorPageAgent::sourceMapURLForResource(resourceData->cachedResource());
+
+ m_frontend->loadingFinished(requestId, finishTime, !sourceMappingURL.isEmpty() ? &sourceMappingURL : 0);
}
void InspectorResourceAgent::didFailLoading(unsigned long identifier, DocumentLoader* loader, const ResourceError& error)
@@ -327,7 +338,7 @@
RefPtr<TypeBuilder::Network::Initiator> initiatorObject = buildInitiatorObject(loader->frame() ? loader->frame()->document() : 0);
- m_frontend->requestServedFromMemoryCache(requestId, frameId, loaderId, loader->url().string(), currentTime(), initiatorObject, buildObjectForCachedResource(*resource, loader));
+ m_frontend->requestServedFromMemoryCache(requestId, frameId, loaderId, loader->url().string(), currentTime(), initiatorObject, buildObjectForCachedResource(resource, loader));
}
void InspectorResourceAgent::setInitialScriptContent(unsigned long identifier, const String& sourceString)