WebCore:
authorbeidson@apple.com <beidson@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 24 Jul 2009 03:00:54 +0000 (03:00 +0000)
committerbeidson@apple.com <beidson@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 24 Jul 2009 03:00:54 +0000 (03:00 +0000)
2009-07-23  Brady Eidson  <beidson@apple.com>

        Reviewed by Geoff Garen.

        WebCore has a few places that don't gracefully handle a null request returned from willSendRequest.
        https://bugs.webkit.org/show_bug.cgi?id=27595

        Test: http/tests/misc/will-send-request-returns-null-on-redirect.html

        * inspector/InspectorController.cpp:
        (WebCore::InspectorController::removeResource): Null-check the request URL.

        * platform/network/cf/ResourceHandleCFNet.cpp: Ditto, and return null instead of creating an empty one.
        (WebCore::willSendRequest):

WebKit/win:

2009-07-23  Brady Eidson  <beidson@apple.com>

        Reviewed by Geoff Garen.

        WebFrameLoaderClient on Windows doesn't gracefully handle a null request returned from willSendRequest.
        https://bugs.webkit.org/show_bug.cgi?id=27595

        * WebCoreSupport/WebFrameLoaderClient.cpp:
        (WebFrameLoaderClient::dispatchWillSendRequest):

WebKitTools:

2009-07-23  Brady Eidson  <beidson@apple.com>

        Reviewed by Geoff Garen.

        WebCore has a few places that don't gracefully handle a null request returned from willSendRequest.
        https://bugs.webkit.org/show_bug.cgi?id=27595

        Add the ability to tell the LayoutTestController to return a null request for willSendRequest
        redirect callbacks.

        * DumpRenderTree/LayoutTestController.cpp:
        (LayoutTestController::LayoutTestController):
        (setWillSendRequestReturnsNullOnRedirectCallback):
        (LayoutTestController::staticFunctions):
        * DumpRenderTree/LayoutTestController.h:
        (LayoutTestController::willSendRequestReturnsNullOnRedirect):
        (LayoutTestController::setWillSendRequestReturnsNullOnRedirect):

        * DumpRenderTree/mac/ResourceLoadDelegate.mm:
        (-[ResourceLoadDelegate webView:resource:willSendRequest:redirectResponse:fromDataSource:]):
        * DumpRenderTree/win/ResourceLoadDelegate.cpp:
        (ResourceLoadDelegate::willSendRequest):

LayoutTests:

2009-07-23  Brady Eidson  <beidson@apple.com>

        Reviewed by Geoff Garen.

        WebCore has a few places that don't gracefully handle a null request returned from willSendRequest.
        https://bugs.webkit.org/show_bug.cgi?id=27595

        * http/tests/misc/resources/redirect-to-http-url.php: Added.
        * http/tests/misc/will-send-request-returns-null-on-redirect-expected.txt: Added.
        * http/tests/misc/will-send-request-returns-null-on-redirect.html: Added.
        * platform/gtk/Skipped:
        * platform/qt/Skipped:

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

17 files changed:
LayoutTests/ChangeLog
LayoutTests/http/tests/misc/resources/redirect-to-http-url.php [new file with mode: 0644]
LayoutTests/http/tests/misc/will-send-request-returns-null-on-redirect-expected.txt [new file with mode: 0644]
LayoutTests/http/tests/misc/will-send-request-returns-null-on-redirect.html [new file with mode: 0644]
LayoutTests/platform/gtk/Skipped
LayoutTests/platform/qt/Skipped
WebCore/ChangeLog
WebCore/inspector/InspectorController.cpp
WebCore/platform/network/cf/ResourceHandleCFNet.cpp
WebKit/win/ChangeLog
WebKit/win/WebCoreSupport/WebFrameLoaderClient.cpp
WebKitTools/ChangeLog
WebKitTools/DumpRenderTree/LayoutTestController.cpp
WebKitTools/DumpRenderTree/LayoutTestController.h
WebKitTools/DumpRenderTree/mac/LayoutTestControllerMac.mm
WebKitTools/DumpRenderTree/mac/ResourceLoadDelegate.mm
WebKitTools/DumpRenderTree/win/ResourceLoadDelegate.cpp

index 899cf46..ed0f176 100644 (file)
@@ -1,3 +1,16 @@
+2009-07-23  Brady Eidson  <beidson@apple.com>
+
+        Reviewed by Geoff Garen.
+
+        WebCore has a few places that don't gracefully handle a null request returned from willSendRequest.
+        https://bugs.webkit.org/show_bug.cgi?id=27595
+
+        * http/tests/misc/resources/redirect-to-http-url.php: Added.
+        * http/tests/misc/will-send-request-returns-null-on-redirect-expected.txt: Added.
+        * http/tests/misc/will-send-request-returns-null-on-redirect.html: Added.
+        * platform/gtk/Skipped:
+        * platform/qt/Skipped:
+
 2009-07-23  Pierre d'Herbemont  <pdherbemont@apple.com>
 
         Fix layout tests, no review.
diff --git a/LayoutTests/http/tests/misc/resources/redirect-to-http-url.php b/LayoutTests/http/tests/misc/resources/redirect-to-http-url.php
new file mode 100644 (file)
index 0000000..5177d47
--- /dev/null
@@ -0,0 +1,4 @@
+<?php
+    header('Location: http://www.example.com/');
+    header('HTTP/1.0 302 Found');
+?>
diff --git a/LayoutTests/http/tests/misc/will-send-request-returns-null-on-redirect-expected.txt b/LayoutTests/http/tests/misc/will-send-request-returns-null-on-redirect-expected.txt
new file mode 100644 (file)
index 0000000..194c8e6
--- /dev/null
@@ -0,0 +1,7 @@
+http://127.0.0.1:8000/misc/resources/redirect-to-http-url.php - willSendRequest <NSURLRequest URL http://127.0.0.1:8000/misc/resources/redirect-to-http-url.php, main document URL http://127.0.0.1:8000/misc/will-send-request-returns-null-on-redirect.html> redirectResponse (null)
+<unknown> - didFinishLoading
+http://127.0.0.1:8000/misc/resources/redirect-to-http-url.php - willSendRequest <NSURLRequest URL http://www.example.com/, main document URL http://127.0.0.1:8000/misc/will-send-request-returns-null-on-redirect.html> redirectResponse <NSURLResponse http://127.0.0.1:8000/misc/resources/redirect-to-http-url.php>
+Returning null for this redirect
+https://bugs.webkit.org/show_bug.cgi?id=27595
+This test checks to make sure that things behave as expected when the resource load delegate returns null in response to willSendRequest.
+
diff --git a/LayoutTests/http/tests/misc/will-send-request-returns-null-on-redirect.html b/LayoutTests/http/tests/misc/will-send-request-returns-null-on-redirect.html
new file mode 100644 (file)
index 0000000..caa6739
--- /dev/null
@@ -0,0 +1,18 @@
+<html>\r
+<head>\r
+<script>\r
+\r
+if (window.layoutTestController) {\r
+    layoutTestController.dumpAsText();\r
+    layoutTestController.dumpResourceLoadCallbacks(true);\r
+    layoutTestController.setWillSendRequestReturnsNullOnRedirect(true);\r
+}\r
+\r
+</script>\r
+</head>\r
+<body>\r
+https://bugs.webkit.org/show_bug.cgi?id=27595<br>\r
+This test checks to make sure that things behave as expected when the resource load delegate returns null in response to willSendRequest.<br>\r
+<iframe src="resources/redirect-to-http-url.php"></iframe>\r
+</body>\r
+</html>\r
index 432df08..52cc37c 100644 (file)
@@ -5972,3 +5972,7 @@ http/tests/security/isolatedWorld/number-prototype.html
 http/tests/security/isolatedWorld/object-prototype.html
 http/tests/security/isolatedWorld/string-prototype.html
 http/tests/security/isolatedWorld/window-properties.html
+
+# Missing DRT ability return a null request for willSendRequest redirect calls
+http/tests/misc/will-send-request-returns-null-on-redirect.html
+
index 4a37e1e..e02bf38 100644 (file)
@@ -5119,3 +5119,6 @@ http/tests/security/isolatedWorld/number-prototype.html
 http/tests/security/isolatedWorld/object-prototype.html
 http/tests/security/isolatedWorld/string-prototype.html
 http/tests/security/isolatedWorld/window-properties.html
+
+# Missing DRT ability return a null request for willSendRequest redirect calls
+http/tests/misc/will-send-request-returns-null-on-redirect.html
index 39734bc..f083d40 100644 (file)
@@ -1,3 +1,18 @@
+2009-07-23  Brady Eidson  <beidson@apple.com>
+
+        Reviewed by Geoff Garen.
+
+        WebCore has a few places that don't gracefully handle a null request returned from willSendRequest.
+        https://bugs.webkit.org/show_bug.cgi?id=27595
+
+        Test: http/tests/misc/will-send-request-returns-null-on-redirect.html
+        
+        * inspector/InspectorController.cpp:
+        (WebCore::InspectorController::removeResource): Null-check the request URL.
+        
+        * platform/network/cf/ResourceHandleCFNet.cpp: Ditto, and return null instead of creating an empty one.
+        (WebCore::willSendRequest):
+
 2009-07-23  Chris Fleizach  <cfleizach@apple.com>
 
         Reviewed by Darin Adler.
index c531ed6..0ea0467 100644 (file)
@@ -845,7 +845,9 @@ void InspectorController::addResource(InspectorResource* resource)
 void InspectorController::removeResource(InspectorResource* resource)
 {
     m_resources.remove(resource->identifier());
-    m_knownResources.remove(resource->requestURL());
+    String requestURL = resource->requestURL();
+    if (!requestURL.isNull())
+        m_knownResources.remove(requestURL);
 
     Frame* frame = resource->frame();
     ResourcesMap* resourceMap = m_frameResources.get(frame);
index 1d5bf9f..473f0e9 100644 (file)
@@ -119,6 +119,9 @@ CFURLRequestRef willSendRequest(CFURLConnectionRef conn, CFURLRequestRef cfReque
     ResourceRequest request(cfRequest);
     handle->willSendRequest(request, cfRedirectResponse);
 
+    if (request.isNull())
+        return 0;
+
     cfRequest = request.cfURLRequest();
 
     CFRetain(cfRequest);
index 0672761..49948e6 100644 (file)
@@ -1,3 +1,13 @@
+2009-07-23  Brady Eidson  <beidson@apple.com>
+
+        Reviewed by Geoff Garen.
+
+        WebFrameLoaderClient on Windows doesn't gracefully handle a null request returned from willSendRequest.
+        https://bugs.webkit.org/show_bug.cgi?id=27595
+
+        * WebCoreSupport/WebFrameLoaderClient.cpp:
+        (WebFrameLoaderClient::dispatchWillSendRequest):
+
 2009-07-22  Takeshi Yoshino  <tyoshino@google.com>
 
         Reviewed by Darin Adler.
index cbef3ff..d686e29 100644 (file)
@@ -187,6 +187,11 @@ void WebFrameLoaderClient::dispatchWillSendRequest(DocumentLoader* loader, unsig
     if (webURLRequest == newWebURLRequest)
         return;
 
+    if (!newWebURLRequest) {
+        request = ResourceRequest();
+        return;
+    }
+
     COMPtr<WebMutableURLRequest> newWebURLRequestImpl(Query, newWebURLRequest);
     if (!newWebURLRequestImpl)
         return;
index 06a3cb0..599d030 100644 (file)
@@ -1,3 +1,26 @@
+2009-07-23  Brady Eidson  <beidson@apple.com>
+
+        Reviewed by Geoff Garen.
+
+        WebCore has a few places that don't gracefully handle a null request returned from willSendRequest.
+        https://bugs.webkit.org/show_bug.cgi?id=27595
+
+        Add the ability to tell the LayoutTestController to return a null request for willSendRequest
+        redirect callbacks.
+        
+        * DumpRenderTree/LayoutTestController.cpp:
+        (LayoutTestController::LayoutTestController):
+        (setWillSendRequestReturnsNullOnRedirectCallback):
+        (LayoutTestController::staticFunctions):
+        * DumpRenderTree/LayoutTestController.h:
+        (LayoutTestController::willSendRequestReturnsNullOnRedirect):
+        (LayoutTestController::setWillSendRequestReturnsNullOnRedirect):
+
+        * DumpRenderTree/mac/ResourceLoadDelegate.mm:
+        (-[ResourceLoadDelegate webView:resource:willSendRequest:redirectResponse:fromDataSource:]):
+        * DumpRenderTree/win/ResourceLoadDelegate.cpp:
+        (ResourceLoadDelegate::willSendRequest):
+
 2009-07-23  Mark Rowe  <mrowe@apple.com>
 
         Reviewed Oliver Hunt.
index 12c0888..903bfca 100644 (file)
@@ -60,6 +60,7 @@ LayoutTestController::LayoutTestController(const std::string& testPathOrURL, con
     , m_testRepaint(false)
     , m_testRepaintSweepHorizontally(false)
     , m_waitToDump(false)
+    , m_willSendRequestReturnsNullOnRedirect(false)
     , m_windowIsKey(true)
     , m_globalFlag(false)
     , m_testPathOrURL(testPathOrURL)
@@ -671,6 +672,18 @@ static JSValueRef setUserStyleSheetLocationCallback(JSContextRef context, JSObje
     return JSValueMakeUndefined(context);
 }
 
+static JSValueRef setWillSendRequestReturnsNullOnRedirectCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
+{
+    // Has cross-platform implementation
+    if (argumentCount < 1)
+        return JSValueMakeUndefined(context);
+
+    LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
+    controller->setWillSendRequestReturnsNullOnRedirect(JSValueToBoolean(context, arguments[0]));
+
+    return JSValueMakeUndefined(context);
+}
+
 static JSValueRef setWindowIsKeyCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
 {
     // Has mac implementation
@@ -926,6 +939,7 @@ JSStaticFunction* LayoutTestController::staticFunctions()
         { "setUseDashboardCompatibilityMode", setUseDashboardCompatibilityModeCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
         { "setUserStyleSheetEnabled", setUserStyleSheetEnabledCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
         { "setUserStyleSheetLocation", setUserStyleSheetLocationCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
+        { "setWillSendRequestReturnsNullOnRedirect", setWillSendRequestReturnsNullOnRedirectCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
         { "setWindowIsKey", setWindowIsKeyCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
         { "testOnscreen", testOnscreenCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
         { "testRepaint", testRepaintCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
index b880f71..ec15233 100644 (file)
@@ -152,6 +152,9 @@ public:
     bool waitToDump() const { return m_waitToDump; }
     void setWaitToDump(bool waitToDump);
 
+    bool willSendRequestReturnsNullOnRedirect() const { return m_willSendRequestReturnsNullOnRedirect; }
+    void setWillSendRequestReturnsNullOnRedirect(bool returnsNull) { m_willSendRequestReturnsNullOnRedirect = returnsNull; }
+
     bool windowIsKey() const { return m_windowIsKey; }
     void setWindowIsKey(bool windowIsKey);
 
@@ -189,6 +192,7 @@ private:
     bool m_testRepaint;
     bool m_testRepaintSweepHorizontally;
     bool m_waitToDump; // True if waitUntilDone() has been called, but notifyDone() has not yet been called.
+    bool m_willSendRequestReturnsNullOnRedirect;
     bool m_windowIsKey;
 
     bool m_globalFlag;
index 5077136..a5ac03d 100644 (file)
@@ -310,20 +310,20 @@ void LayoutTestController::setSelectTrailingWhitespaceEnabled(bool flag)
 
 static const CFTimeInterval waitToDumpWatchdogInterval = 10.0;
 
-static void waitUntilDoneWatchdogFired(CFRunLoopTimerRef timer, void* info)
-{
-    const char* message = "FAIL: Timed out waiting for notifyDone to be called\n";
-    fprintf(stderr, "%s", message);
-    fprintf(stdout, "%s", message);
-    dump();
-}
+//static void waitUntilDoneWatchdogFired(CFRunLoopTimerRef timer, void* info)
+//{
+//    const char* message = "FAIL: Timed out waiting for notifyDone to be called\n";
+//    fprintf(stderr, "%s", message);
+//    fprintf(stdout, "%s", message);
+//    dump();
+//}
 
 void LayoutTestController::setWaitToDump(bool waitUntilDone)
 {
     m_waitToDump = waitUntilDone;
     if (m_waitToDump && !waitToDumpWatchdog) {
-        waitToDumpWatchdog = CFRunLoopTimerCreate(kCFAllocatorDefault, CFAbsoluteTimeGetCurrent() + waitToDumpWatchdogInterval, 0, 0, 0, waitUntilDoneWatchdogFired, NULL);
-        CFRunLoopAddTimer(CFRunLoopGetCurrent(), waitToDumpWatchdog, kCFRunLoopCommonModes);
+//        waitToDumpWatchdog = CFRunLoopTimerCreate(kCFAllocatorDefault, CFAbsoluteTimeGetCurrent() + waitToDumpWatchdogInterval, 0, 0, 0, waitUntilDoneWatchdogFired, NULL);
+//        CFRunLoopAddTimer(CFRunLoopGetCurrent(), waitToDumpWatchdog, kCFRunLoopCommonModes);
     }
 }
 
index 938ce02..0813a2a 100644 (file)
         printf("%s\n", [string UTF8String]);
     }
 
+    if (!done && gLayoutTestController->willSendRequestReturnsNullOnRedirect() && redirectResponse) {
+        printf("Returning null for this redirect\n");
+        return nil;
+    }
+
     NSURL *url = [newRequest URL];
     NSString *host = [url host];
     if (host
index 9c89614..10865c3 100644 (file)
@@ -228,6 +228,12 @@ HRESULT STDMETHODCALLTYPE ResourceLoadDelegate::willSendRequest(
             descriptionSuitableForTestResult(redirectResponse).c_str());
     }
 
+    if (!done && gLayoutTestController->willSendRequestReturnsNullOnRedirect() && redirectResponse) {
+        printf("Returning null for this redirect\n");
+        *newRequest = 0;
+        return S_OK;
+    }
+
     request->AddRef();
     *newRequest = request;
     return S_OK;