Web Inspector: Null ResourceResponse Preflight requests cause crash
authorcommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 30 Nov 2016 18:01:36 +0000 (18:01 +0000)
committercommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 30 Nov 2016 18:01:36 +0000 (18:01 +0000)
https://bugs.webkit.org/show_bug.cgi?id=165120
<rdar://problem/27911350>

Patch by Joseph Pecoraro <pecoraro@apple.com> on 2016-11-30
Reviewed by Brian Burg.

* loader/CrossOriginPreflightChecker.cpp:
(WebCore::CrossOriginPreflightChecker::validatePreflightResponse):
Only inform Web Inspector about successful responses. Informing with a
null response would break the expected Inspector API contract when
notifying about did receive response. Also, when informing Web Inspector
include a didFinishLoading event so the frontend knows this pre-flight
request is complete.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@209134 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Source/WebCore/ChangeLog
Source/WebCore/loader/CrossOriginPreflightChecker.cpp

index e4d0061..fe23248 100644 (file)
@@ -1,3 +1,19 @@
+2016-11-30  Joseph Pecoraro  <pecoraro@apple.com>
+
+        Web Inspector: Null ResourceResponse Preflight requests cause crash
+        https://bugs.webkit.org/show_bug.cgi?id=165120
+        <rdar://problem/27911350>
+
+        Reviewed by Brian Burg.
+
+        * loader/CrossOriginPreflightChecker.cpp:
+        (WebCore::CrossOriginPreflightChecker::validatePreflightResponse):
+        Only inform Web Inspector about successful responses. Informing with a
+        null response would break the expected Inspector API contract when
+        notifying about did receive response. Also, when informing Web Inspector
+        include a didFinishLoading event so the frontend knows this pre-flight
+        request is complete.
+
 2016-11-30  Brady Eidson  <beidson@apple.com>
 
         REGRESSION (209086): IDB tests crash under GuardMalloc.
index 0c8a98a..d7a5a35 100644 (file)
@@ -60,8 +60,6 @@ void CrossOriginPreflightChecker::validatePreflightResponse(DocumentThreadableLo
 {
     Frame* frame = loader.document().frame();
     ASSERT(frame);
-    auto cookie = InspectorInstrumentation::willReceiveResourceResponse(frame);
-    InspectorInstrumentation::didReceiveResourceResponse(cookie, identifier, frame->loader().documentLoader(), response, 0);
 
     if (!response.isSuccessful()) {
         loader.preflightFailure(identifier, ResourceError(errorDomainWebKitInternal, 0, request.url(), ASCIILiteral("Preflight response is not successful"), ResourceError::Type::AccessControl));
@@ -82,6 +80,13 @@ void CrossOriginPreflightChecker::validatePreflightResponse(DocumentThreadableLo
         return;
     }
 
+    // FIXME: <https://webkit.org/b/164889> Web Inspector: Show Preflight Request information in inspector
+    // This is only showing success preflight requests and responses but we should show network events
+    // for preflight failures and distinguish them better from non-preflight requests.
+    auto cookie = InspectorInstrumentation::willReceiveResourceResponse(frame);
+    InspectorInstrumentation::didReceiveResourceResponse(cookie, identifier, frame->loader().documentLoader(), response, nullptr);
+    InspectorInstrumentation::didFinishLoading(frame, frame->loader().documentLoader(), identifier, 0);
+
     CrossOriginPreflightResultCache::singleton().appendEntry(loader.securityOrigin().toString(), request.url(), WTFMove(result));
     loader.preflightSuccess(WTFMove(request));
 }