Diff
Modified: trunk/LayoutTests/ChangeLog (90339 => 90340)
--- trunk/LayoutTests/ChangeLog 2011-07-03 15:51:21 UTC (rev 90339)
+++ trunk/LayoutTests/ChangeLog 2011-07-03 15:58:38 UTC (rev 90340)
@@ -1,3 +1,13 @@
+2011-07-03 Vsevolod Vlasov <[email protected]>
+
+ Reviewed by Alexey Proskuryakov.
+
+ Web Inspector: Preflight OPTIONS requests are not shown on network panel for asynchronous XHRs.
+ https://bugs.webkit.org/show_bug.cgi?id=63712
+
+ * http/tests/inspector/network-preflight-options-expected.txt:
+ * http/tests/inspector/network-preflight-options.html:
+
2011-07-03 Robert Hogan <[email protected]>
Add platform-specific results after r90338
Modified: trunk/LayoutTests/http/tests/inspector/network-preflight-options-expected.txt (90339 => 90340)
--- trunk/LayoutTests/http/tests/inspector/network-preflight-options-expected.txt 2011-07-03 15:51:21 UTC (rev 90339)
+++ trunk/LayoutTests/http/tests/inspector/network-preflight-options-expected.txt 2011-07-03 15:58:38 UTC (rev 90340)
@@ -1,9 +1,15 @@
CONSOLE MESSAGE: line 1: XMLHttpRequest cannot load http://localhost:8000/inspector/resources/cors-target.php?deny=yes. Origin http://127.0.0.1:8000 is not allowed by Access-Control-Allow-Origin.
CONSOLE MESSAGE: line 1: XMLHttpRequest cannot load http://localhost:8000/inspector/resources/cors-target.php?deny=yes. Origin http://127.0.0.1:8000 is not allowed by Access-Control-Allow-Origin.
+CONSOLE MESSAGE: line 1: XMLHttpRequest cannot load http://localhost:8000/inspector/resources/cors-target.php?deny=yes. Origin http://127.0.0.1:8000 is not allowed by Access-Control-Allow-Origin.
+CONSOLE MESSAGE: line 1: XMLHttpRequest cannot load http://localhost:8000/inspector/resources/cors-target.php?deny=yes. Origin http://127.0.0.1:8000 is not allowed by Access-Control-Allow-Origin.
Tests that preflight OPTIONS requests appear in Network resources
POST http://localhost:8000/inspector/resources/cors-target.php?deny=yes
OPTIONS http://localhost:8000/inspector/resources/cors-target.php?deny=yes
OPTIONS http://localhost:8000/inspector/resources/cors-target.php
POST http://localhost:8000/inspector/resources/cors-target.php
+POST http://localhost:8000/inspector/resources/cors-target.php?deny=yes
+OPTIONS http://localhost:8000/inspector/resources/cors-target.php?deny=yes
+OPTIONS http://localhost:8000/inspector/resources/cors-target.php?async=yes
+POST http://localhost:8000/inspector/resources/cors-target.php?async=yes
Modified: trunk/LayoutTests/http/tests/inspector/network-preflight-options.html (90339 => 90340)
--- trunk/LayoutTests/http/tests/inspector/network-preflight-options.html 2011-07-03 15:51:21 UTC (rev 90339)
+++ trunk/LayoutTests/http/tests/inspector/network-preflight-options.html 2011-07-03 15:58:38 UTC (rev 90340)
@@ -3,10 +3,10 @@
<script src=""
<script type="text/_javascript_">
-function sendXHR(url, forcePreflight)
+function sendXHR(url, forcePreflight, async)
{
var xhr = new XMLHttpRequest();
- xhr.open("POST", url, false);
+ xhr.open("POST", url, async);
xhr.setRequestHeader("Content-Type", forcePreflight ? "application/xml" : "text/plain");
try {
xhr.send("<xml></xml>"); // Denied requests will cause exceptions.
@@ -17,22 +17,30 @@
function doCrossOriginXHR()
{
var targetURL = "http://localhost:8000/inspector/resources/cors-target.php";
+
// Failed POSTs with no preflight check should result in a POST request being logged
- sendXHR(targetURL + "?deny=yes", false);
+ sendXHR(targetURL + "?deny=yes", false, false);
// Failed POSTs with preflight check should result in an OPTIONS request being logged
- sendXHR(targetURL + "?deny=yes", true);
+ sendXHR(targetURL + "?deny=yes", true, false);
// Successful POSTs with preflight check should result in an OPTIONS request followed by POST request being logged
- // Generate request name based on timestamp to defeat caching (this is only relevant for repeated invocations of the test in signle instance of DRT)
- sendXHR(targetURL + "?date=" + Date.now(), true);
+ // Generate request name based on timestamp to defeat OPTIONS request caching (this is only relevant for repeated invocations of the test in signle instance of DRT)
+ sendXHR(targetURL + "?date=" + Date.now(), true, false);
+
+ // And now send the same requests asynchronously
+ // Add redundant async parameter to ensure this request differs from the one above.
+ sendXHR(targetURL + "?deny=yes", false, true);
+ sendXHR(targetURL + "?deny=yes", true, true);
+ sendXHR(targetURL + "?async=yes&date=" + Date.now(), true, true);
}
var test = function()
{
+ var postRequestsCount = 0;
function onResource(event)
{
var resource = event.data;
InspectorTest.addResult(resource.requestMethod + " " + resource.url.replace(/[&?]date=\d+/, ""));
- if (resource.requestMethod === "POST" && !/\?deny=yes/.test(resource.url))
+ if (resource.requestMethod === "POST" && ++postRequestsCount == 4)
InspectorTest.completeTest();
}
WebInspector.networkManager.addEventListener(WebInspector.NetworkManager.EventTypes.ResourceFinished, onResource);
Modified: trunk/Source/WebCore/ChangeLog (90339 => 90340)
--- trunk/Source/WebCore/ChangeLog 2011-07-03 15:51:21 UTC (rev 90339)
+++ trunk/Source/WebCore/ChangeLog 2011-07-03 15:58:38 UTC (rev 90340)
@@ -1,3 +1,21 @@
+2011-07-03 Vsevolod Vlasov <[email protected]>
+
+ Reviewed by Alexey Proskuryakov.
+
+ Web Inspector: Preflight OPTIONS requests are not shown on network panel for asynchronous XHRs.
+ https://bugs.webkit.org/show_bug.cgi?id=63712
+
+ Added InspectorInstrumentation calls to preflight OPTIONS requests callbacks in DocumentThreadableLoader.
+
+ * loader/DocumentThreadableLoader.cpp:
+ (WebCore::DocumentThreadableLoader::DocumentThreadableLoader):
+ (WebCore::DocumentThreadableLoader::didReceiveResponse):
+ (WebCore::DocumentThreadableLoader::didReceiveData):
+ (WebCore::DocumentThreadableLoader::didFinishLoading):
+ (WebCore::DocumentThreadableLoader::didFail):
+ (WebCore::DocumentThreadableLoader::loadRequest):
+ * loader/DocumentThreadableLoader.h:
+
2011-06-23 Robert Hogan <[email protected]>
Reviewed by Simon Hausmann.
Modified: trunk/Source/WebCore/loader/DocumentThreadableLoader.cpp (90339 => 90340)
--- trunk/Source/WebCore/loader/DocumentThreadableLoader.cpp 2011-07-03 15:51:21 UTC (rev 90339)
+++ trunk/Source/WebCore/loader/DocumentThreadableLoader.cpp 2011-07-03 15:58:38 UTC (rev 90340)
@@ -46,6 +46,11 @@
#include "ThreadableLoaderClient.h"
#include <wtf/UnusedParam.h>
+#if ENABLE(INSPECTOR)
+#include "InspectorInstrumentation.h"
+#include "ProgressTracker.h"
+#endif
+
namespace WebCore {
void DocumentThreadableLoader::loadResourceSynchronously(Document* document, const ResourceRequest& request, ThreadableLoaderClient& client, const ThreadableLoaderOptions& options)
@@ -69,6 +74,9 @@
, m_options(options)
, m_sameOriginRequest(securityOrigin()->canRequest(request.url()))
, m_async(blockingBehavior == LoadAsynchronously)
+#if ENABLE(INSPECTOR)
+ , m_preflightRequestIdentifier(0)
+#endif
{
ASSERT(document);
ASSERT(client);
@@ -178,6 +186,14 @@
{
ASSERT(m_client);
+#if ENABLE(INSPECTOR)
+ if (m_preflightRequestIdentifier) {
+ DocumentLoader* loader = m_document->frame()->loader()->documentLoader();
+ InspectorInstrumentationCookie cookie = InspectorInstrumentation::willReceiveResourceResponse(m_document->frame(), m_preflightRequestIdentifier, response);
+ InspectorInstrumentation::didReceiveResourceResponse(cookie, m_preflightRequestIdentifier, loader, response);
+ }
+#endif
+
String accessControlErrorDescription;
if (m_actualRequest) {
if (!passesAccessControlCheck(response, m_options.allowCredentials, securityOrigin(), accessControlErrorDescription)) {
@@ -211,6 +227,11 @@
ASSERT(m_client);
ASSERT_UNUSED(loader, loader == m_loader);
+#if ENABLE(INSPECTOR)
+ if (m_preflightRequestIdentifier)
+ InspectorInstrumentation::didReceiveContentLength(m_document->frame(), m_preflightRequestIdentifier, 0, dataLength);
+#endif
+
// Preflight data should be invisible to clients.
if (m_actualRequest)
return;
@@ -239,6 +260,11 @@
void DocumentThreadableLoader::didFinishLoading(unsigned long identifier, double finishTime)
{
+#if ENABLE(INSPECTOR)
+ if (m_preflightRequestIdentifier)
+ InspectorInstrumentation::didFinishLoading(m_document->frame(), m_document->frame()->loader()->documentLoader(), m_preflightRequestIdentifier, finishTime);
+#endif
+
if (m_actualRequest) {
ASSERT(!m_sameOriginRequest);
ASSERT(m_options.crossOriginRequestPolicy == UseAccessControl);
@@ -253,6 +279,11 @@
// m_loader may be null if we arrive here via SubresourceLoader::create in the ctor
ASSERT_UNUSED(loader, loader == m_loader || !m_loader);
+#if ENABLE(INSPECTOR)
+ if (m_preflightRequestIdentifier)
+ InspectorInstrumentation::didFailLoading(m_document->frame(), m_document->frame()->loader()->documentLoader(), m_preflightRequestIdentifier, error);
+#endif
+
m_client->didFail(error);
}
@@ -323,6 +354,16 @@
// Keep buffering the data for the preflight request.
bool shouldBufferData = m_options.shouldBufferData || m_actualRequest;
+#if ENABLE(INSPECTOR)
+ if (m_actualRequest) {
+ ResourceRequest newRequest(request);
+ // Because willSendRequest only gets called during redirects, we initialize the identifier and the first willSendRequest here.
+ m_preflightRequestIdentifier = m_document->frame()->page()->progress()->createUniqueIdentifier();
+ ResourceResponse redirectResponse = ResourceResponse();
+ InspectorInstrumentation::willSendRequest(m_document->frame(), m_preflightRequestIdentifier, m_document->frame()->loader()->documentLoader(), newRequest, redirectResponse);
+ }
+#endif
+
// Clear the loader so that any callbacks from SubresourceLoader::create will not have the old loader.
m_loader = 0;
m_loader = resourceLoadScheduler()->scheduleSubresourceLoad(m_document->frame(), this, request, ResourceLoadPriorityMedium, securityCheck, sendLoadCallbacks,
Modified: trunk/Source/WebCore/loader/DocumentThreadableLoader.h (90339 => 90340)
--- trunk/Source/WebCore/loader/DocumentThreadableLoader.h 2011-07-03 15:51:21 UTC (rev 90339)
+++ trunk/Source/WebCore/loader/DocumentThreadableLoader.h 2011-07-03 15:58:38 UTC (rev 90340)
@@ -105,6 +105,10 @@
bool m_sameOriginRequest;
bool m_async;
OwnPtr<ResourceRequest> m_actualRequest; // non-null during Access Control preflight checks
+
+#if ENABLE(INSPECTOR)
+ unsigned long m_preflightRequestIdentifier;
+#endif
};
} // namespace WebCore