Changeset 124567 in webkit


Ignore:
Timestamp:
Aug 3, 2012 12:28:41 AM (12 years ago)
Author:
kbalazs@webkit.org
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):

Location:
trunk/Tools
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/Tools/ChangeLog

    r124559 r124567  
     12012-08-03  Balazs Kelemen  <kbalazs@webkit.org>
     2
     3        WTR should be able to load external resources
     4        https://bugs.webkit.org/show_bug.cgi?id=89382
     5
     6        Reviewed by Ryosuke Niwa.
     7
     8        Allow to load an external resource as the main frame
     9        and allow all subsequent external loads for such a main
     10        frame. This behavior is necessary for being able to run
     11        performance tests (wkb.ug/84008).
     12
     13        * WebKitTestRunner/InjectedBundle/InjectedBundlePage.cpp:
     14        (WTR::isLocalHost):
     15        (WTR):
     16        (WTR::isHTTPOrHTTPSScheme):
     17        (WTR::InjectedBundlePage::willSendRequestForFrame):
     18
    1192012-08-02  Joone Hur  <joone.hur@intel.com>
    220
  • trunk/Tools/WebKitTestRunner/InjectedBundle/InjectedBundlePage.cpp

    r123841 r124567  
    945945// Resource Load Client Callbacks
    946946
    947 WKURLRequestRef InjectedBundlePage::willSendRequestForFrame(WKBundlePageRef, WKBundleFrameRef, uint64_t, WKURLRequestRef request, WKURLResponseRef)
     947static inline bool isLocalHost(WKStringRef host)
     948{
     949    return WKStringIsEqualToUTF8CString(host, "127.0.0.1") || WKStringIsEqualToUTF8CString(host, "localhost");
     950}
     951
     952static inline bool isHTTPOrHTTPSScheme(WKStringRef scheme)
     953{
     954    return WKStringIsEqualToUTF8CStringIgnoringCase(scheme, "http") || WKStringIsEqualToUTF8CStringIgnoringCase(scheme, "https");
     955}
     956
     957WKURLRequestRef InjectedBundlePage::willSendRequestForFrame(WKBundlePageRef, WKBundleFrameRef frame, uint64_t, WKURLRequestRef request, WKURLResponseRef)
    948958{
    949959    if (InjectedBundle::shared().isTestRunning() && InjectedBundle::shared().layoutTestController()->willSendRequestReturnsNull())
     
    955965    WKRetainPtr<WKStringRef> urlString = adoptWK(WKURLCopyString(url.get()));
    956966    if (host && !WKStringIsEmpty(host.get())
    957         && (WKStringIsEqualToUTF8CStringIgnoringCase(scheme.get(), "http") || WKStringIsEqualToUTF8CStringIgnoringCase(scheme.get(), "https"))
    958         && !WKStringIsEqualToUTF8CString(host.get(), "127.0.0.1")
     967        && isHTTPOrHTTPSScheme(scheme.get())
    959968        && !WKStringIsEqualToUTF8CString(host.get(), "255.255.255.255") // Used in some tests that expect to get back an error.
    960         && !WKStringIsEqualToUTF8CStringIgnoringCase(host.get(), "localhost")) {
    961         InjectedBundle::shared().stringBuilder()->append("Blocked access to external URL ");
    962         InjectedBundle::shared().stringBuilder()->append(toWTFString(urlString));
    963         InjectedBundle::shared().stringBuilder()->append("\n");
    964         return 0;
     969        && !isLocalHost(host.get())) {
     970        WKBundleFrameRef mainFrame = WKBundlePageGetMainFrame(m_page);
     971        if (mainFrame != frame) {
     972            WKRetainPtr<WKURLRef> mainFrameURL = adoptWK(WKBundleFrameCopyURL(mainFrame));
     973            WKRetainPtr<WKStringRef> mainFrameHost = WKURLCopyHostName(mainFrameURL.get());
     974            WKRetainPtr<WKStringRef> mainFrameScheme = WKURLCopyScheme(mainFrameURL.get());
     975
     976            bool mainFrameIsExternal = isHTTPOrHTTPSScheme(mainFrameScheme.get()) && !isLocalHost(mainFrameHost.get());
     977            if (!mainFrameIsExternal) {
     978                InjectedBundle::shared().stringBuilder()->append("Blocked access to external URL ");
     979                InjectedBundle::shared().stringBuilder()->append(toWTFString(urlString));
     980                InjectedBundle::shared().stringBuilder()->append("\n");
     981                return 0;
     982            }
     983        }
    965984    }
    966985
Note: See TracChangeset for help on using the changeset viewer.