[SCM] WebKit Debian packaging branch, webkit-1.3, updated. upstream/1.3.7-4207-g178b198

mitz at apple.com mitz at apple.com
Sun Feb 20 22:56:26 UTC 2011


The following commit has been merged in the webkit-1.3 branch:
commit 1c3ad0ea38a35f14bf751b80eb7e3bc615e0887e
Author: mitz at apple.com <mitz at apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date:   Fri Jan 14 05:19:49 2011 +0000

    <rdar://problem/8827065> REGRESSION (r71884): Cross-origin XHR fails if willSendRequest changes the URL
    https://bugs.webkit.org/show_bug.cgi?id=52419
    
    Reviewed by Alexey Proskuryakov.
    
    Source/WebCore:
    
    Test: http/tests/loading/cross-origin-XHR-willLoadRequest.html
    
    * loader/ResourceLoader.cpp:
    (WebCore::ResourceLoader::init): Complete r74453 by ensuring that m_request is only set after
    willSendRequest(). Otherwise, willSendRequest() ends up calling into
    ThreadableDocumentRequest::willSendRequest(), which cancels the request.
    
    Tools:
    
    Allow to further control the behavior of the willSendRequest delegate callback by making it
    set a different URL in the new request.
    
    * DumpRenderTree/LayoutTestController.cpp:
    (addURLToRedirectCallback): Added.
    (LayoutTestController::staticFunctions): Added addURLToRedirect.
    (LayoutTestController::addURLToRedirect): Added. Adds the redirection to the map.
    (LayoutTestController::redirectionDestinationForURL): Added this getter.
    * DumpRenderTree/LayoutTestController.h:
    * DumpRenderTree/mac/ResourceLoadDelegate.mm:
    (-[ResourceLoadDelegate webView:resource:willSendRequest:redirectResponse:fromDataSource:]): Check
    if there is a redirection for the request’s URL, established by addURLToRedirect(), and if so,
    change the URL in the new request to the redirect destination.
    
    LayoutTests:
    
    * http/tests/loading/cross-origin-XHR-willLoadRequest-expected.txt: Added.
    * http/tests/loading/cross-origin-XHR-willLoadRequest.html: Added.
    * platform/gtk/Skipped: Skip the new test.
    * platform/qt/Skipped: Ditto.
    * platform/win/Skipped: Ditto.
    
    
    
    git-svn-id: http://svn.webkit.org/repository/webkit/trunk@75768 268f45cc-cd09-0410-ab3c-d52691b4dbfc

diff --git a/LayoutTests/ChangeLog b/LayoutTests/ChangeLog
index 6c2a223..d48a91a 100644
--- a/LayoutTests/ChangeLog
+++ b/LayoutTests/ChangeLog
@@ -1,3 +1,16 @@
+2011-01-13  Dan Bernstein  <mitz at apple.com>
+
+        Reviewed by Alexey Proskuryakov.
+
+        <rdar://problem/8827065> REGRESSION (r71884): Cross-origin XHR fails if willSendRequest changes the URL
+        https://bugs.webkit.org/show_bug.cgi?id=52419
+
+        * http/tests/loading/cross-origin-XHR-willLoadRequest-expected.txt: Added.
+        * http/tests/loading/cross-origin-XHR-willLoadRequest.html: Added.
+        * platform/gtk/Skipped: Skip the new test.
+        * platform/qt/Skipped: Ditto.
+        * platform/win/Skipped: Ditto.
+
 2011-01-13  Justin Schuh  <jschuh at chromium.org>
 
         Unreviewed chromium expectations update.
diff --git a/LayoutTests/http/tests/loading/cross-origin-XHR-willLoadRequest-expected.txt b/LayoutTests/http/tests/loading/cross-origin-XHR-willLoadRequest-expected.txt
new file mode 100644
index 0000000..2397283
--- /dev/null
+++ b/LayoutTests/http/tests/loading/cross-origin-XHR-willLoadRequest-expected.txt
@@ -0,0 +1,7 @@
+main frame - didStartProvisionalLoadForFrame
+main frame - didCommitLoadForFrame
+main frame - didFinishDocumentLoadForFrame
+main frame - didHandleOnloadEventsForFrame
+CONSOLE MESSAGE: line 1: XMLHttpRequest cannot load http://localhost:8000/loading/resources/foo.txt. Origin http://127.0.0.1:8000 is not allowed by Access-Control-Allow-Origin.
+main frame - didFinishLoadForFrame
+The console message above should report failure to load foo.txt due to cross-origin access, not a network error.
diff --git a/LayoutTests/http/tests/loading/cross-origin-XHR-willLoadRequest.html b/LayoutTests/http/tests/loading/cross-origin-XHR-willLoadRequest.html
new file mode 100644
index 0000000..05f3bea
--- /dev/null
+++ b/LayoutTests/http/tests/loading/cross-origin-XHR-willLoadRequest.html
@@ -0,0 +1,11 @@
+<script>
+    layoutTestController.dumpAsText();
+    layoutTestController.addURLToRedirect("http:/localhost:8000/loading/resources/bar.txt", "http://localhost:8000/loading/resources/foo.txt");
+
+    var request = new XMLHttpRequest();
+    request.open("GET", "http:/localhost:8000/loading/resources/bar.txt");
+    request.send();
+</script>
+<p>
+    The console message above should report failure to load foo.txt due to cross-origin access, not a network error.
+</p>
diff --git a/LayoutTests/platform/gtk/Skipped b/LayoutTests/platform/gtk/Skipped
index 16df6c2..a00e548 100644
--- a/LayoutTests/platform/gtk/Skipped
+++ b/LayoutTests/platform/gtk/Skipped
@@ -5593,3 +5593,6 @@ http/tests/xmlhttprequest/basic-auth-nopassword.html
 
 # https://bugs.webkit.org/show_bug.cgi?id=52297
 editing/input/page-up-down-scrolls.html
+
+# DRT does not obey layoutTestController.addURLToRedirect()
+http/tests/loading/cross-origin-XHR-willLoadRequest
diff --git a/LayoutTests/platform/qt/Skipped b/LayoutTests/platform/qt/Skipped
index 2679963..66aac98 100644
--- a/LayoutTests/platform/qt/Skipped
+++ b/LayoutTests/platform/qt/Skipped
@@ -764,6 +764,9 @@ fast/ruby/rubyDOM-remove-rt2.html
 fast/ruby/rubyDOM-remove-text1.html
 fast/ruby/rubyDOM-remove-text2.html
 
+# ------- not obeying layoutTestController.addURLToRedirect()
+http/tests/loading/cross-origin-XHR-willLoadRequest
+
 # ============================================================================= #
 # Failing SVG tests
 # ============================================================================= #
diff --git a/LayoutTests/platform/win/Skipped b/LayoutTests/platform/win/Skipped
index a3ffa59..1a60af3 100644
--- a/LayoutTests/platform/win/Skipped
+++ b/LayoutTests/platform/win/Skipped
@@ -1,5 +1,5 @@
 #
-# Copyright (C) 2007, 2008, 2009, 2010 Apple Inc. All rights reserved.
+# Copyright (C) 2007, 2008, 2009, 2010, 2011 Apple Inc. All rights reserved.
 #
 # Redistribution and use in source and binary forms, with or without
 # modification, are permitted provided that the following conditions
@@ -1117,3 +1117,6 @@ fast/loader/user-stylesheet-fast-path.html
 
 # DRT does not support toggling caret browsing on / off
 editing/selection/caret-mode-paragraph-keys-navigation.html
+
+# DRT does not obey addURLToRedirect
+http/tests/loading/cross-origin-XHR-willLoadRequest
diff --git a/Source/WebCore/ChangeLog b/Source/WebCore/ChangeLog
index 964c53c..1967f9b 100644
--- a/Source/WebCore/ChangeLog
+++ b/Source/WebCore/ChangeLog
@@ -1,5 +1,19 @@
 2011-01-13  Dan Bernstein  <mitz at apple.com>
 
+        Reviewed by Alexey Proskuryakov.
+
+        <rdar://problem/8827065> REGRESSION (r71884): Cross-origin XHR fails if willSendRequest changes the URL
+        https://bugs.webkit.org/show_bug.cgi?id=52419
+
+        Test: http/tests/loading/cross-origin-XHR-willLoadRequest.html
+
+        * loader/ResourceLoader.cpp:
+        (WebCore::ResourceLoader::init): Complete r74453 by ensuring that m_request is only set after
+        willSendRequest(). Otherwise, willSendRequest() ends up calling into
+        ThreadableDocumentRequest::willSendRequest(), which cancels the request.
+
+2011-01-13  Dan Bernstein  <mitz at apple.com>
+
         Reviewed by Mark Rowe.
 
         Don’t try to compile InjectedScriptSource.js into WebCore.
diff --git a/Source/WebCore/loader/ResourceLoader.cpp b/Source/WebCore/loader/ResourceLoader.cpp
index ea0d02a..42ce016 100644
--- a/Source/WebCore/loader/ResourceLoader.cpp
+++ b/Source/WebCore/loader/ResourceLoader.cpp
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2006, 2007 Apple Inc. All rights reserved.
+ * Copyright (C) 2006, 2007, 2010, 2011 Apple Inc. All rights reserved.
  *           (C) 2007 Graham Dennis (graham.dennis at gmail.com)
  *
  * Redistribution and use in source and binary forms, with or without
@@ -129,14 +129,13 @@ bool ResourceLoader::init(const ResourceRequest& r)
             clientRequest.setFirstPartyForCookies(document->firstPartyForCookies());
     }
 
-    m_request = clientRequest;
-
-    willSendRequest(m_request, ResourceResponse());
-    if (m_request.isNull()) {
+    willSendRequest(clientRequest, ResourceResponse());
+    if (clientRequest.isNull()) {
         didFail(frameLoader()->cancelledError(m_request));
         return false;
     }
 
+    m_request = clientRequest;
     return true;
 }
 
diff --git a/Tools/ChangeLog b/Tools/ChangeLog
index 1ba9ef4..e2a4acc 100644
--- a/Tools/ChangeLog
+++ b/Tools/ChangeLog
@@ -1,3 +1,24 @@
+2011-01-13  Dan Bernstein  <mitz at apple.com>
+
+        Reviewed by Alexey Proskuryakov.
+
+        <rdar://problem/8827065> REGRESSION (r71884): Cross-origin XHR fails if willSendRequest changes the URL
+        https://bugs.webkit.org/show_bug.cgi?id=52419
+
+        Allow to further control the behavior of the willSendRequest delegate callback by making it
+        set a different URL in the new request.
+
+        * DumpRenderTree/LayoutTestController.cpp:
+        (addURLToRedirectCallback): Added.
+        (LayoutTestController::staticFunctions): Added addURLToRedirect.
+        (LayoutTestController::addURLToRedirect): Added. Adds the redirection to the map.
+        (LayoutTestController::redirectionDestinationForURL): Added this getter.
+        * DumpRenderTree/LayoutTestController.h:
+        * DumpRenderTree/mac/ResourceLoadDelegate.mm:
+        (-[ResourceLoadDelegate webView:resource:willSendRequest:redirectResponse:fromDataSource:]): Check
+        if there is a redirection for the request’s URL, established by addURLToRedirect(), and if so,
+        change the URL in the new request to the redirect destination.
+
 2011-01-13  Eric Seidel  <eric at webkit.org>
 
         Reviewed by Mihai Parparita.
diff --git a/Tools/DumpRenderTree/LayoutTestController.cpp b/Tools/DumpRenderTree/LayoutTestController.cpp
index 16a3149..a3d9727 100644
--- a/Tools/DumpRenderTree/LayoutTestController.cpp
+++ b/Tools/DumpRenderTree/LayoutTestController.cpp
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2007, 2008, 2009 Apple Inc. All rights reserved.
+ * Copyright (C) 2007, 2008, 2009, 2011 Apple Inc. All rights reserved.
  * Copyright (C) 2010 Joone Hur <joone at kldp.org>
  *
  * Redistribution and use in source and binary forms, with or without
@@ -335,6 +335,31 @@ static JSValueRef addDisallowedURLCallback(JSContextRef context, JSObjectRef fun
     return JSValueMakeUndefined(context);
 }
 
+static JSValueRef addURLToRedirectCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
+{
+    if (argumentCount < 2)
+        return JSValueMakeUndefined(context);
+
+    JSRetainPtr<JSStringRef> origin(Adopt, JSValueToStringCopy(context, arguments[0], exception));
+    ASSERT(!*exception);
+
+    JSRetainPtr<JSStringRef> destination(Adopt, JSValueToStringCopy(context, arguments[1], exception));
+    ASSERT(!*exception);
+
+    size_t maxLength = JSStringGetMaximumUTF8CStringSize(origin.get());
+    char* originBuffer = new char[maxLength + 1];
+    JSStringGetUTF8CString(origin.get(), originBuffer, maxLength + 1);
+
+    maxLength = JSStringGetMaximumUTF8CStringSize(destination.get());
+    char* destinationBuffer = new char[maxLength + 1];
+    JSStringGetUTF8CString(destination.get(), destinationBuffer, maxLength + 1);
+
+    LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
+    controller->addURLToRedirect(originBuffer, destinationBuffer);
+
+    return JSValueMakeUndefined(context);
+}
+
 static JSValueRef callShouldCloseOnWebViewCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
 {
     // Has mac & windows implementation
@@ -1930,6 +1955,7 @@ JSStaticFunction* LayoutTestController::staticFunctions()
     static JSStaticFunction staticFunctions[] = {
         { "abortModal", abortModalCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
         { "addDisallowedURL", addDisallowedURLCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
+        { "addURLToRedirect", addURLToRedirectCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
         { "addUserScript", addUserScriptCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
         { "addUserStyleSheet", addUserStyleSheetCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
         { "apiTestNewWindowDataLoadBaseURL", apiTestNewWindowDataLoadBaseURLCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
@@ -2140,5 +2166,15 @@ void LayoutTestController::setPOSIXLocale(JSStringRef locale)
     setlocale(LC_ALL, localeBuf);
 }
 
+void LayoutTestController::addURLToRedirect(std::string origin, std::string destination)
+{
+    m_URLsToRedirect[origin] = destination;
+}
+
+const std::string& LayoutTestController::redirectionDestinationForURL(std::string origin)
+{
+    return m_URLsToRedirect[origin];
+}
+
 const unsigned LayoutTestController::maxViewWidth = 800;
 const unsigned LayoutTestController::maxViewHeight = 600;
diff --git a/Tools/DumpRenderTree/LayoutTestController.h b/Tools/DumpRenderTree/LayoutTestController.h
index 026de13..9704128 100644
--- a/Tools/DumpRenderTree/LayoutTestController.h
+++ b/Tools/DumpRenderTree/LayoutTestController.h
@@ -31,6 +31,7 @@
 
 #include <JavaScriptCore/JSObjectRef.h>
 #include <JavaScriptCore/JSRetainPtr.h>
+#include <map>
 #include <set>
 #include <string>
 #include <vector>
@@ -45,6 +46,8 @@ public:
     void makeWindowObject(JSContextRef context, JSObjectRef windowObject, JSValueRef* exception);
 
     void addDisallowedURL(JSStringRef url);
+    void addURLToRedirect(std::string origin, std::string destination);
+    const std::string& redirectionDestinationForURL(std::string);
     void clearAllApplicationCaches();
     void clearAllDatabases();
     void clearBackForwardList();
@@ -361,6 +364,8 @@ private:
     
     // origins which have been granted desktop notification access
     std::vector<JSStringRef> m_desktopNotificationAllowedOrigins;
+
+    std::map<std::string, std::string> m_URLsToRedirect;
     
     static JSClassRef getJSClass();
     static JSStaticValue* staticValues();
diff --git a/Tools/DumpRenderTree/mac/ResourceLoadDelegate.mm b/Tools/DumpRenderTree/mac/ResourceLoadDelegate.mm
index 0855b83..2854ca4 100644
--- a/Tools/DumpRenderTree/mac/ResourceLoadDelegate.mm
+++ b/Tools/DumpRenderTree/mac/ResourceLoadDelegate.mm
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2007, Apple Inc.  All rights reserved.
+ * Copyright (C) 2007, 2011 Apple Inc.  All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
@@ -165,6 +165,9 @@ using namespace std;
         [newRequest setValue:nil forHTTPHeaderField:nsHeader];
         [nsHeader release];
     }
+    const std::string& destination = gLayoutTestController->redirectionDestinationForURL([[url absoluteString] UTF8String]);
+    if (destination.length())
+        [newRequest setURL:[NSURL URLWithString:[NSString stringWithUTF8String:destination.data()]]];
 
     return [newRequest autorelease];
 }

-- 
WebKit Debian packaging



More information about the Pkg-webkit-commits mailing list