diff options
Diffstat (limited to 'Tools/DumpRenderTree/TestRunner.h')
-rw-r--r-- | Tools/DumpRenderTree/TestRunner.h | 106 |
1 files changed, 71 insertions, 35 deletions
diff --git a/Tools/DumpRenderTree/TestRunner.h b/Tools/DumpRenderTree/TestRunner.h index 882c0e96c..57c401003 100644 --- a/Tools/DumpRenderTree/TestRunner.h +++ b/Tools/DumpRenderTree/TestRunner.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2007, 2008, 2009, 2012 Apple Inc. All rights reserved. + * Copyright (C) 2007-2016 Apple Inc. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -10,7 +10,7 @@ * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. - * 3. Neither the name of Apple Computer, Inc. ("Apple") nor the names of + * 3. Neither the name of Apple Inc. ("Apple") nor the names of * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * @@ -25,21 +25,23 @@ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ - -#ifndef TestRunner_h -#define TestRunner_h +#pragma once + +#include "UIScriptContext.h" #include <JavaScriptCore/JSObjectRef.h> #include <map> #include <set> #include <string> #include <vector> -#include <wtf/PassRefPtr.h> #include <wtf/RefCounted.h> -class TestRunner : public RefCounted<TestRunner> { +extern FILE* testResult; + +class TestRunner : public WTR::UIScriptContextDelegate, public RefCounted<TestRunner> { + WTF_MAKE_NONCOPYABLE(TestRunner); public: - static PassRefPtr<TestRunner> create(const std::string& testPathOrURL, const std::string& expectedPixelHash); + static Ref<TestRunner> create(const std::string& testURL, const std::string& expectedPixelHash); static const unsigned viewWidth; static const unsigned viewHeight; @@ -47,11 +49,15 @@ public: static const unsigned w3cSVGViewWidth; static const unsigned w3cSVGViewHeight; - ~TestRunner(); + virtual ~TestRunner(); + + void cleanup(); void makeWindowObject(JSContextRef, JSObjectRef windowObject, JSValueRef* exception); void addDisallowedURL(JSStringRef url); + const std::set<std::string>& allowedHosts() const { return m_allowedHosts; } + void setAllowedHosts(std::set<std::string> hosts) { m_allowedHosts = WTFMove(hosts); } void addURLToRedirect(std::string origin, std::string destination); const std::string& redirectionDestinationForURL(std::string); void clearAllApplicationCaches(); @@ -74,6 +80,7 @@ public: void keepWebHistory(); void notifyDone(); int numberOfPendingGeolocationPermissionRequests(); + bool isGeolocationProviderActive(); void overridePreference(JSStringRef key, JSStringRef value); JSStringRef pathToLocalResource(JSContextRef, JSStringRef url); void queueBackNavigation(int howFarBackward); @@ -86,8 +93,10 @@ public: void queueReload(); void removeAllVisitedLinks(); void setAcceptsEditing(bool); + void setFetchAPIEnabled(bool); void setAllowUniversalAccessFromFileURLs(bool); void setAllowFileAccessFromFileURLs(bool); + void setNeedsStorageAccessFromFileURLsQuirk(bool); void setAppCacheMaximumSize(unsigned long long quota); void setAuthorAndUserStylesEnabled(bool); void setCacheModel(int); @@ -102,8 +111,6 @@ public: void setMockDeviceOrientation(bool canProvideAlpha, double alpha, bool canProvideBeta, double beta, bool canProvideGamma, double gamma); void setMockGeolocationPosition(double latitude, double longitude, double accuracy, bool providesAltitude, double altitude, bool providesAltitudeAccuracy, double altitudeAccuracy, bool providesHeading, double heading, bool providesSpeed, double speed); void setMockGeolocationPositionUnavailableError(JSStringRef message); - void addMockSpeechInputResult(JSStringRef result, double confidence, JSStringRef language); - void setMockSpeechInputDumpRect(bool flag); void setPersistentUserStyleSheetLocation(JSStringRef path); void setPluginsEnabled(bool); void setPopupBlockingEnabled(bool); @@ -117,7 +124,6 @@ public: void setXSSAuditorEnabled(bool flag); void setSpatialNavigationEnabled(bool); void setScrollbarPolicy(JSStringRef orientation, JSStringRef policy); - void startSpeechInput(JSContextRef inputElement); #if PLATFORM(IOS) void setTelephoneNumberParsingEnabled(bool enable); void setPagePaused(bool paused); @@ -126,14 +132,20 @@ public: void setPageVisibility(const char*); void resetPageVisibility(); + static void setAllowsAnySSLCertificate(bool); + void waitForPolicyDelegate(); size_t webHistoryItemCount(); int windowCount(); -#if ENABLE(IOS_TEXT_AUTOSIZING) +#if ENABLE(TEXT_AUTOSIZING) void setTextAutosizingEnabled(bool); #endif + void setAccummulateLogsForChannel(JSStringRef); + + void runUIScript(JSContextRef, JSStringRef, JSValueRef callback); + // Legacy here refers to the old TestRunner API for handling web notifications, not the legacy web notification API. void ignoreLegacyWebNotificationPermissionRequests(); // Legacy here refers to the old TestRunner API for handling web notifications, not the legacy web notification API. @@ -209,9 +221,6 @@ public: bool dumpTitleChanges() const { return m_dumpTitleChanges; } void setDumpTitleChanges(bool dumpTitleChanges) { m_dumpTitleChanges = dumpTitleChanges; } - bool dumpIconChanges() const { return m_dumpIconChanges; } - void setDumpIconChanges(bool dumpIconChanges) { m_dumpIconChanges = dumpIconChanges; } - bool dumpVisitedLinksCallback() const { return m_dumpVisitedLinksCallback; } void setDumpVisitedLinksCallback(bool dumpVisitedLinksCallback) { m_dumpVisitedLinksCallback = dumpVisitedLinksCallback; } @@ -258,9 +267,14 @@ public: bool windowIsKey() const { return m_windowIsKey; } void setWindowIsKey(bool); + void setViewSize(double width, double height); + bool alwaysAcceptCookies() const { return m_alwaysAcceptCookies; } void setAlwaysAcceptCookies(bool); + bool rejectsProtectionSpaceAndContinueForAuthenticationChallenges() const { return m_rejectsProtectionSpaceAndContinueForAuthenticationChallenges; } + void setRejectsProtectionSpaceAndContinueForAuthenticationChallenges(bool value) { m_rejectsProtectionSpaceAndContinueForAuthenticationChallenges = value; } + bool handlesAuthenticationChallenges() const { return m_handlesAuthenticationChallenges; } void setHandlesAuthenticationChallenges(bool handlesAuthenticationChallenges) { m_handlesAuthenticationChallenges = handlesAuthenticationChallenges; } @@ -282,13 +296,10 @@ public: double databaseMaxQuota() const { return m_databaseMaxQuota; } void setDatabaseMaxQuota(double quota) { m_databaseMaxQuota = quota; } - bool deferMainResourceDataLoad() const { return m_deferMainResourceDataLoad; } - void setDeferMainResourceDataLoad(bool flag) { m_deferMainResourceDataLoad = flag; } - bool useDeferredFrameLoading() const { return m_useDeferredFrameLoading; } void setUseDeferredFrameLoading(bool flag) { m_useDeferredFrameLoading = flag; } - const std::string& testPathOrURL() const { return m_testPathOrURL; } + const std::string& testURL() const { return m_testURL; } const std::string& expectedPixelHash() const { return m_expectedPixelHash; } const std::vector<char>& audioResult() const { return m_audioResult; } @@ -307,7 +318,9 @@ public: void setDeveloperExtrasEnabled(bool); void showWebInspector(); void closeWebInspector(); - void evaluateInWebInspector(long callId, JSStringRef script); + void evaluateInWebInspector(JSStringRef script); + JSStringRef inspectorTestStubURL(); + void evaluateScriptInIsolatedWorld(unsigned worldID, JSObjectRef globalObject, JSStringRef script); void evaluateScriptInIsolatedWorldAndReturnValue(unsigned worldID, JSObjectRef globalObject, JSStringRef script); @@ -336,13 +349,6 @@ public: // Simulate a request an embedding application could make, populating per-session credential storage. void authenticateSession(JSStringRef url, JSStringRef username, JSStringRef password); - JSValueRef originsWithLocalStorage(JSContextRef); - void deleteAllLocalStorage(); - void deleteLocalStorageForOrigin(JSStringRef originIdentifier); - long long localStorageDiskUsageForOrigin(JSStringRef originIdentifier); - void observeStorageTrackerNotifications(unsigned number); - void syncLocalStorage(); - void setShouldPaintBrokenImage(bool); bool shouldPaintBrokenImage() const { return m_shouldPaintBrokenImage; } @@ -359,8 +365,29 @@ public: bool hasPendingWebNotificationClick() const { return m_hasPendingWebNotificationClick; } + void setCustomTimeout(int duration) { m_timeout = duration; } + double timeout() { return m_timeout; } + + unsigned imageCountInGeneralPasteboard() const; + + void callUIScriptCallback(unsigned callbackID, JSStringRef result); + + void setDumpJSConsoleLogInStdErr(bool inStdErr) { m_dumpJSConsoleLogInStdErr = inStdErr; } + bool dumpJSConsoleLogInStdErr() const { return m_dumpJSConsoleLogInStdErr; } + + void setSpellCheckerLoggingEnabled(bool); + private: - TestRunner(const std::string& testPathOrURL, const std::string& expectedPixelHash); + TestRunner(const std::string& testURL, const std::string& expectedPixelHash); + + JSContextRef mainFrameJSContext(); + + // UIScriptContextDelegate + void uiScriptDidComplete(const String&, unsigned callbackID) override; + + void cacheTestRunnerCallback(unsigned index, JSValueRef); + void callTestRunnerCallback(unsigned index, size_t argumentCount = 0, const JSValueRef arguments[] = nullptr); + void clearTestRunnerCallbacks(); void setGeolocationPermissionCommon(bool allow); @@ -385,7 +412,6 @@ private: bool m_dumpSourceAsWebArchive; bool m_dumpStatusCallbacks; bool m_dumpTitleChanges; - bool m_dumpIconChanges; bool m_dumpVisitedLinksCallback; bool m_dumpWillCacheResponse; bool m_generatePixelResults; @@ -405,9 +431,9 @@ private: bool m_globalFlag; bool m_isGeolocationPermissionSet; bool m_geolocationPermission; + bool m_rejectsProtectionSpaceAndContinueForAuthenticationChallenges; bool m_handlesAuthenticationChallenges; bool m_isPrinting; - bool m_deferMainResourceDataLoad; bool m_useDeferredFrameLoading; bool m_shouldPaintBrokenImage; bool m_shouldStayOnPageAfterHandlingBeforeUnload; @@ -415,25 +441,35 @@ private: bool m_areLegacyWebNotificationPermissionRequestsIgnored; bool m_customFullScreenBehavior; bool m_hasPendingWebNotificationClick; + bool m_dumpJSConsoleLogInStdErr { false }; double m_databaseDefaultQuota; double m_databaseMaxQuota; std::string m_authenticationUsername; std::string m_authenticationPassword; - std::string m_testPathOrURL; + std::string m_testURL; std::string m_expectedPixelHash; // empty string if no hash std::string m_titleTextDirection; std::set<std::string> m_willSendRequestClearHeaders; + std::set<std::string> m_allowedHosts; std::vector<char> m_audioResult; std::map<std::string, std::string> m_URLsToRedirect; - + + struct UIScriptInvocationData { + unsigned callbackID; + String scriptString; + }; + + std::unique_ptr<WTR::UIScriptContext> m_UIScriptContext; + UIScriptInvocationData* m_pendingUIScriptInvocationData { nullptr }; + static JSClassRef getJSClass(); static JSStaticValue* staticValues(); static JSStaticFunction* staticFunctions(); -}; -#endif // TestRunner_h + int m_timeout; +}; |