diff options
Diffstat (limited to 'Tools/WebKitTestRunner/InjectedBundle')
8 files changed, 85 insertions, 51 deletions
diff --git a/Tools/WebKitTestRunner/InjectedBundle/Bindings/LayoutTestController.idl b/Tools/WebKitTestRunner/InjectedBundle/Bindings/LayoutTestController.idl index 768e89fe1..df608da3a 100644 --- a/Tools/WebKitTestRunner/InjectedBundle/Bindings/LayoutTestController.idl +++ b/Tools/WebKitTestRunner/InjectedBundle/Bindings/LayoutTestController.idl @@ -44,6 +44,7 @@ module WTR { void dumpFullScreenCallbacks(); void dumpFrameLoadCallbacks(); void dumpProgressFinishedCallback(); + void dumpResourceResponseMIMETypes(); // Special options. void keepWebHistory(); @@ -62,6 +63,8 @@ module WTR { void setAuthorAndUserStylesEnabled(in boolean value); void addOriginAccessWhitelistEntry(in DOMString sourceOrigin, in DOMString destinationProtocol, in DOMString destinationHost, in boolean allowDestinationSubdomains); void removeOriginAccessWhitelistEntry(in DOMString sourceOrigin, in DOMString destinationProtocol, in DOMString destinationHost, in boolean allowDestinationSubdomains); + void setUserStyleSheetEnabled(in boolean value); + void setUserStyleSheetLocation(in DOMString location); // Special DOM functions. void clearBackForwardList(); diff --git a/Tools/WebKitTestRunner/InjectedBundle/InjectedBundle.cpp b/Tools/WebKitTestRunner/InjectedBundle/InjectedBundle.cpp index 2a940caa6..002e7f901 100644 --- a/Tools/WebKitTestRunner/InjectedBundle/InjectedBundle.cpp +++ b/Tools/WebKitTestRunner/InjectedBundle/InjectedBundle.cpp @@ -34,7 +34,7 @@ #include <WebKit2/WKBundlePagePrivate.h> #include <WebKit2/WKBundlePrivate.h> #include <WebKit2/WKRetainPtr.h> -#include <WebKit2/WebKit2.h> +#include <WebKit2/WebKit2_C.h> #include <wtf/PassOwnPtr.h> #include <wtf/text/CString.h> #include <wtf/text/StringBuilder.h> diff --git a/Tools/WebKitTestRunner/InjectedBundle/InjectedBundlePage.cpp b/Tools/WebKitTestRunner/InjectedBundle/InjectedBundlePage.cpp index 16371d1bc..de32cb08d 100644 --- a/Tools/WebKitTestRunner/InjectedBundle/InjectedBundlePage.cpp +++ b/Tools/WebKitTestRunner/InjectedBundle/InjectedBundlePage.cpp @@ -944,7 +944,17 @@ void InjectedBundlePage::didInitiateLoadForResource(WKBundlePageRef, WKBundleFra // 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,22 +964,48 @@ WKURLRequestRef InjectedBundlePage::willSendRequestForFrame(WKBundlePageRef, WKB 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())) { + bool mainFrameIsExternal = false; + if (InjectedBundle::shared().isTestRunning()) { + WKBundleFrameRef mainFrame = InjectedBundle::shared().topLoadingFrame(); + WKRetainPtr<WKURLRef> mainFrameURL = adoptWK(WKBundleFrameCopyURL(mainFrame)); + if (!mainFrameURL || WKStringIsEqualToUTF8CString(adoptWK(WKURLCopyString(mainFrameURL.get())).get(), "about:blank")) + mainFrameURL = adoptWK(WKBundleFrameCopyProvisionalURL(mainFrame)); + + WKRetainPtr<WKStringRef> mainFrameHost = WKURLCopyHostName(mainFrameURL.get()); + WKRetainPtr<WKStringRef> mainFrameScheme = WKURLCopyScheme(mainFrameURL.get()); + 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); return request; } -void InjectedBundlePage::didReceiveResponseForResource(WKBundlePageRef, WKBundleFrameRef, uint64_t, WKURLResponseRef) +void InjectedBundlePage::didReceiveResponseForResource(WKBundlePageRef, WKBundleFrameRef, uint64_t, WKURLResponseRef response) { + if (!InjectedBundle::shared().isTestRunning()) + return; + + if (!InjectedBundle::shared().layoutTestController()->shouldDumpResourceResponseMIMETypes()) + return; + + WKRetainPtr<WKURLRef> url = adoptWK(WKURLResponseCopyURL(response)); + WKRetainPtr<WKStringRef> urlString = adoptWK(WKURLCopyLastPathComponent(url.get())); + WKRetainPtr<WKStringRef> mimeTypeString = adoptWK(WKURLResponseCopyMIMEType(response)); + + InjectedBundle::shared().stringBuilder()->append(toWTFString(urlString)); + InjectedBundle::shared().stringBuilder()->append(" has MIME type "); + InjectedBundle::shared().stringBuilder()->append(toWTFString(mimeTypeString)); + InjectedBundle::shared().stringBuilder()->append("\n"); } void InjectedBundlePage::didReceiveContentLengthForResource(WKBundlePageRef, WKBundleFrameRef, uint64_t, uint64_t) diff --git a/Tools/WebKitTestRunner/InjectedBundle/LayoutTestController.cpp b/Tools/WebKitTestRunner/InjectedBundle/LayoutTestController.cpp index 4981b3c58..cdffcae08 100644 --- a/Tools/WebKitTestRunner/InjectedBundle/LayoutTestController.cpp +++ b/Tools/WebKitTestRunner/InjectedBundle/LayoutTestController.cpp @@ -43,7 +43,7 @@ #include <WebKit2/WKBundleScriptWorld.h> #include <WebKit2/WKRetainPtr.h> #include <WebKit2/WKSerializedScriptValue.h> -#include <WebKit2/WebKit2.h> +#include <WebKit2/WebKit2_C.h> #include <wtf/CurrentTime.h> #include <wtf/HashMap.h> #include <wtf/text/StringBuilder.h> @@ -77,6 +77,7 @@ LayoutTestController::LayoutTestController() , m_dumpFullScreenCallbacks(false) , m_dumpFrameLoadCallbacks(false) , m_dumpProgressFinishedCallback(false) + , m_dumpResourceResponseMIMETypes(false) , m_waitToDump(false) , m_testRepaint(false) , m_testRepaintSweepHorizontally(false) @@ -85,6 +86,8 @@ LayoutTestController::LayoutTestController() , m_policyDelegatePermissive(false) , m_globalFlag(false) , m_customFullScreenBehavior(false) + , m_userStyleSheetEnabled(false) + , m_userStyleSheetLocation(adoptWK(WKStringCreateWithUTF8CString(""))) { platformInitialize(); } @@ -415,7 +418,6 @@ void LayoutTestController::clearBackForwardList() void LayoutTestController::makeWindowObject(JSContextRef context, JSObjectRef windowObject, JSValueRef* exception) { - setProperty(context, windowObject, "layoutTestController", this, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete, exception); setProperty(context, windowObject, "testRunner", this, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete, exception); } @@ -664,4 +666,21 @@ double LayoutTestController::preciseTime() return currentTime(); } +void LayoutTestController::setUserStyleSheetEnabled(bool enabled) +{ + m_userStyleSheetEnabled = enabled; + + WKRetainPtr<WKStringRef> emptyUrl = adoptWK(WKStringCreateWithUTF8CString("")); + WKStringRef location = enabled ? m_userStyleSheetLocation.get() : emptyUrl.get(); + WKBundleSetUserStyleSheetLocation(InjectedBundle::shared().bundle(), InjectedBundle::shared().pageGroup(), location); +} + +void LayoutTestController::setUserStyleSheetLocation(JSStringRef location) +{ + m_userStyleSheetLocation = adoptWK(WKStringCreateWithJSString(location)); + + if (m_userStyleSheetEnabled) + setUserStyleSheetEnabled(true); +} + } // namespace WTR diff --git a/Tools/WebKitTestRunner/InjectedBundle/LayoutTestController.h b/Tools/WebKitTestRunner/InjectedBundle/LayoutTestController.h index 304396343..517a5160a 100644 --- a/Tools/WebKitTestRunner/InjectedBundle/LayoutTestController.h +++ b/Tools/WebKitTestRunner/InjectedBundle/LayoutTestController.h @@ -29,6 +29,7 @@ #include "JSWrappable.h" #include <JavaScriptCore/JSRetainPtr.h> #include <WebKit2/WKBundleScriptWorld.h> +#include <WebKit2/WKRetainPtr.h> #include <string> #include <wtf/PassRefPtr.h> @@ -78,6 +79,7 @@ public: void dumpFullScreenCallbacks() { m_dumpFullScreenCallbacks = true; } void dumpFrameLoadCallbacks() { setShouldDumpFrameLoadCallbacks(true); } void dumpProgressFinishedCallback() { setShouldDumpProgressFinishedCallback(true); } + void dumpResourceResponseMIMETypes() { m_dumpResourceResponseMIMETypes = true; } void setShouldDumpFrameLoadCallbacks(bool value) { m_dumpFrameLoadCallbacks = value; } void setShouldDumpProgressFinishedCallback(bool value) { m_dumpProgressFinishedCallback = value; } @@ -100,6 +102,8 @@ public: void setCustomPolicyDelegate(bool enabled, bool permissive = false); void addOriginAccessWhitelistEntry(JSStringRef sourceOrigin, JSStringRef destinationProtocol, JSStringRef destinationHost, bool allowDestinationSubdomains); void removeOriginAccessWhitelistEntry(JSStringRef sourceOrigin, JSStringRef destinationProtocol, JSStringRef destinationHost, bool allowDestinationSubdomains); + void setUserStyleSheetEnabled(bool); + void setUserStyleSheetLocation(JSStringRef); // Special DOM functions. JSValueRef computedStyleIncludingVisitedInfo(JSValueRef element); @@ -158,7 +162,9 @@ public: bool shouldDumpPixels() const { return m_dumpPixels; } bool shouldDumpFullScreenCallbacks() const { return m_dumpFullScreenCallbacks; } bool shouldDumpFrameLoadCallbacks() const { return m_dumpFrameLoadCallbacks; } - bool shouldDumpProgressFinishedCallback() { return m_dumpProgressFinishedCallback; } + bool shouldDumpProgressFinishedCallback() const { return m_dumpProgressFinishedCallback; } + bool shouldDumpResourceResponseMIMETypes() const { return m_dumpResourceResponseMIMETypes; } + bool isPolicyDelegateEnabled() const { return m_policyDelegateEnabled; } bool isPolicyDelegatePermissive() const { return m_policyDelegatePermissive; } @@ -243,6 +249,7 @@ private: bool m_dumpFullScreenCallbacks; bool m_dumpFrameLoadCallbacks; bool m_dumpProgressFinishedCallback; + bool m_dumpResourceResponseMIMETypes; bool m_waitToDump; // True if waitUntilDone() has been called, but notifyDone() has not yet been called. bool m_testRepaint; bool m_testRepaintSweepHorizontally; @@ -255,6 +262,9 @@ private: bool m_globalFlag; bool m_customFullScreenBehavior; + bool m_userStyleSheetEnabled; + WKRetainPtr<WKStringRef> m_userStyleSheetLocation; + PlatformTimerRef m_waitToDumpWatchdogTimer; }; diff --git a/Tools/WebKitTestRunner/InjectedBundle/efl/InjectedBundleEfl.cpp b/Tools/WebKitTestRunner/InjectedBundle/efl/InjectedBundleEfl.cpp index 961d043f7..119832095 100644 --- a/Tools/WebKitTestRunner/InjectedBundle/efl/InjectedBundleEfl.cpp +++ b/Tools/WebKitTestRunner/InjectedBundle/efl/InjectedBundleEfl.cpp @@ -20,13 +20,13 @@ #include "config.h" #include "InjectedBundle.h" -#include <WebCore/NotImplemented.h> +#include <wtf/Assertions.h> namespace WTR { void InjectedBundle::platformInitialize(WKTypeRef) { - notImplemented(); + WTFInstallReportBacktraceOnCrashHook(); } } // namespace WTR diff --git a/Tools/WebKitTestRunner/InjectedBundle/mac/ActivateFonts.mm b/Tools/WebKitTestRunner/InjectedBundle/mac/ActivateFonts.mm index 01d790bc8..57a08ca47 100644 --- a/Tools/WebKitTestRunner/InjectedBundle/mac/ActivateFonts.mm +++ b/Tools/WebKitTestRunner/InjectedBundle/mac/ActivateFonts.mm @@ -139,6 +139,7 @@ static NSSet *allowedFontFamilySet() @"Skia", @"STFangsong", @"STHeiti", + @"STIXGeneral", @"STKaiti", @"STSong", @"Symbol", diff --git a/Tools/WebKitTestRunner/InjectedBundle/qt/InjectedBundleQt.cpp b/Tools/WebKitTestRunner/InjectedBundle/qt/InjectedBundleQt.cpp index 7164b70d2..845097307 100644 --- a/Tools/WebKitTestRunner/InjectedBundle/qt/InjectedBundleQt.cpp +++ b/Tools/WebKitTestRunner/InjectedBundle/qt/InjectedBundleQt.cpp @@ -34,40 +34,8 @@ #include <wtf/AlwaysInline.h> #include <wtf/Assertions.h> -#if HAVE(SIGNAL_H) -#include <signal.h> -#endif - namespace WTR { -#if HAVE(SIGNAL_H) -typedef void (*SignalHandler)(int); - -static NO_RETURN void crashHandler(int sig) -{ - WTFReportBacktrace(); - exit(128 + sig); -} - -static void setupSignalHandlers(SignalHandler handler) -{ - signal(SIGILL, handler); /* 4: illegal instruction (not reset when caught) */ - signal(SIGTRAP, handler); /* 5: trace trap (not reset when caught) */ - signal(SIGFPE, handler); /* 8: floating point exception */ - signal(SIGBUS, handler); /* 10: bus error */ - signal(SIGSEGV, handler); /* 11: segmentation violation */ - signal(SIGSYS, handler); /* 12: bad argument to system call */ - signal(SIGPIPE, handler); /* 13: write on a pipe with no reader */ - signal(SIGXCPU, handler); /* 24: exceeded CPU time limit */ - signal(SIGXFSZ, handler); /* 25: exceeded file size limit */ -} - -static void crashHook() -{ - setupSignalHandlers(SIG_DFL); -} -#endif - void InjectedBundle::platformInitialize(WKTypeRef) { QWindowsStyle* styleForTests = new QWindowsStyle; @@ -79,10 +47,7 @@ void InjectedBundle::platformInitialize(WKTypeRef) if (qgetenv("QT_WEBKIT2_DEBUG") == "1") return; -#if HAVE(SIGNAL_H) - setupSignalHandlers(&crashHandler); - WTFSetCrashHook(&crashHook); -#endif + WTFInstallReportBacktraceOnCrashHook(); } } // namespace WTR |