Title: [124567] trunk/Tools
Revision
124567
Author
kbal...@webkit.org
Date
2012-08-03 00:28:41 -0700 (Fri, 03 Aug 2012)

Log Message

WTR should be able to load external resources
https://bugs.webkit.org/show_bug.cgi?id=89382

Reviewed by Ryosuke Niwa.

Allow to load an external resource as the main frame
and allow all subsequent external loads for such a main
frame. This behavior is necessary for being able to run
performance tests (wkb.ug/84008).

* WebKitTestRunner/InjectedBundle/InjectedBundlePage.cpp:
(WTR::isLocalHost):
(WTR):
(WTR::isHTTPOrHTTPSScheme):
(WTR::InjectedBundlePage::willSendRequestForFrame):

Modified Paths

Diff

Modified: trunk/Tools/ChangeLog (124566 => 124567)


--- trunk/Tools/ChangeLog	2012-08-03 07:23:45 UTC (rev 124566)
+++ trunk/Tools/ChangeLog	2012-08-03 07:28:41 UTC (rev 124567)
@@ -1,3 +1,21 @@
+2012-08-03  Balazs Kelemen  <kbal...@webkit.org>
+
+        WTR should be able to load external resources
+        https://bugs.webkit.org/show_bug.cgi?id=89382
+
+        Reviewed by Ryosuke Niwa.
+
+        Allow to load an external resource as the main frame
+        and allow all subsequent external loads for such a main
+        frame. This behavior is necessary for being able to run
+        performance tests (wkb.ug/84008).
+
+        * WebKitTestRunner/InjectedBundle/InjectedBundlePage.cpp:
+        (WTR::isLocalHost):
+        (WTR):
+        (WTR::isHTTPOrHTTPSScheme):
+        (WTR::InjectedBundlePage::willSendRequestForFrame):
+
 2012-08-02  Joone Hur  <joone....@intel.com>
 
         [GTK] Build break when building DumpRenderTree/gtk/EditingCallbacks.cpp

Modified: trunk/Tools/WebKitTestRunner/InjectedBundle/InjectedBundlePage.cpp (124566 => 124567)


--- trunk/Tools/WebKitTestRunner/InjectedBundle/InjectedBundlePage.cpp	2012-08-03 07:23:45 UTC (rev 124566)
+++ trunk/Tools/WebKitTestRunner/InjectedBundle/InjectedBundlePage.cpp	2012-08-03 07:28:41 UTC (rev 124567)
@@ -944,8 +944,18 @@
 
 // Resource Load Client Callbacks
 
-WKURLRequestRef InjectedBundlePage::willSendRequestForFrame(WKBundlePageRef, WKBundleFrameRef, uint64_t, WKURLRequestRef request, WKURLResponseRef)
+static inline bool isLocalHost(WKStringRef host)
 {
+    return WKStringIsEqualToUTF8CString(host, "127.0.0.1") || WKStringIsEqualToUTF8CString(host, "localhost");
+}
+
+static inline bool isHTTPOrHTTPSScheme(WKStringRef scheme)
+{
+    return WKStringIsEqualToUTF8CStringIgnoringCase(scheme, "http") || WKStringIsEqualToUTF8CStringIgnoringCase(scheme, "https");
+}
+
+WKURLRequestRef InjectedBundlePage::willSendRequestForFrame(WKBundlePageRef, WKBundleFrameRef frame, uint64_t, WKURLRequestRef request, WKURLResponseRef)
+{
     if (InjectedBundle::shared().isTestRunning() && InjectedBundle::shared().layoutTestController()->willSendRequestReturnsNull())
         return 0;
 
@@ -954,14 +964,23 @@
     WKRetainPtr<WKStringRef> scheme = adoptWK(WKURLCopyScheme(url.get()));
     WKRetainPtr<WKStringRef> urlString = adoptWK(WKURLCopyString(url.get()));
     if (host && !WKStringIsEmpty(host.get())
-        && (WKStringIsEqualToUTF8CStringIgnoringCase(scheme.get(), "http") || WKStringIsEqualToUTF8CStringIgnoringCase(scheme.get(), "https"))
-        && !WKStringIsEqualToUTF8CString(host.get(), "127.0.0.1")
+        && isHTTPOrHTTPSScheme(scheme.get())
         && !WKStringIsEqualToUTF8CString(host.get(), "255.255.255.255") // Used in some tests that expect to get back an error.
-        && !WKStringIsEqualToUTF8CStringIgnoringCase(host.get(), "localhost")) {
-        InjectedBundle::shared().stringBuilder()->append("Blocked access to external URL ");
-        InjectedBundle::shared().stringBuilder()->append(toWTFString(urlString));
-        InjectedBundle::shared().stringBuilder()->append("\n");
-        return 0;
+        && !isLocalHost(host.get())) {
+        WKBundleFrameRef mainFrame = WKBundlePageGetMainFrame(m_page);
+        if (mainFrame != frame) {
+            WKRetainPtr<WKURLRef> mainFrameURL = adoptWK(WKBundleFrameCopyURL(mainFrame));
+            WKRetainPtr<WKStringRef> mainFrameHost = WKURLCopyHostName(mainFrameURL.get());
+            WKRetainPtr<WKStringRef> mainFrameScheme = WKURLCopyScheme(mainFrameURL.get());
+
+            bool mainFrameIsExternal = isHTTPOrHTTPSScheme(mainFrameScheme.get()) && !isLocalHost(mainFrameHost.get());
+            if (!mainFrameIsExternal) {
+                InjectedBundle::shared().stringBuilder()->append("Blocked access to external URL ");
+                InjectedBundle::shared().stringBuilder()->append(toWTFString(urlString));
+                InjectedBundle::shared().stringBuilder()->append("\n");
+                return 0;
+            }
+        }
     }
 
     WKRetain(request);
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
http://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to