2013-12-16 04:58:10 +00:00
|
|
|
/*
|
|
|
|
* Copyright (C) 2013 University of Szeged. All rights reserved.
|
|
|
|
* Copyright (C) 2013 Samsung Electronics. All rights reserved.
|
2018-04-02 18:09:04 +00:00
|
|
|
* Copyright (C) 2015-2018 Apple Inc. All rights reserved.
|
2013-12-16 04:58:10 +00:00
|
|
|
*
|
|
|
|
* Redistribution and use in source and binary forms, with or without
|
|
|
|
* modification, are permitted provided that the following conditions
|
|
|
|
* are met:
|
|
|
|
* 1. Redistributions of source code must retain the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer.
|
|
|
|
* 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.
|
|
|
|
*
|
|
|
|
* THIS SOFTWARE IS PROVIDED BY UNIVERSITY OF SZEGED ``AS IS'' AND ANY
|
|
|
|
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
|
|
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
|
|
|
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL UNIVERSITY OF SZEGED OR
|
|
|
|
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
|
|
|
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
|
|
|
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
|
|
|
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
|
|
|
|
* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
|
|
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
|
|
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
|
|
*/
|
|
|
|
|
2018-04-02 18:09:04 +00:00
|
|
|
#pragma once
|
2013-12-16 04:58:10 +00:00
|
|
|
|
2020-11-04 22:22:03 +00:00
|
|
|
#include "TestFeatures.h"
|
2013-12-16 04:58:10 +00:00
|
|
|
#include <functional>
|
2018-04-02 23:12:12 +00:00
|
|
|
#include <set>
|
2013-12-16 04:58:10 +00:00
|
|
|
#include <stdio.h>
|
|
|
|
#include <string>
|
Refactor TestOptions code in WebKitTestRunner to make it easier to rationalize and extend
https://bugs.webkit.org/show_bug.cgi?id=217390
Reviewed by Darin Adler.
Refactors TestOptions code in WebKitTestRunner to make it clear how options coming in at
different levels are treated and what precedence each has. The order is (from least to most):
- Global features passed to WebKitTestRunner via the command line (e.g. --show-touches)
- Hardcoded features based on the path of the test being run (hopefully we can remove all soon)
- Hardcoded platform specific defaults (currently only used by macOS for useThreadedScrolling).
- Features from the test headers within the test itself.
- Finally, a second chance for more platform specific defaults (currenly only used the Cocoa ports
for setting enableProcessSwapOnNavigation and enableProcessSwapOnWindowOpen based on NSUserDefaults.)
To make this change work, and pave the way for future autogeneration of some of these test options,
the TestOptions struct (now class) was overhauled. Instead of storing the state itself, TestOptions
is now an immutable owner of a TestFeatures object. TestFeatures is a simple struct that contains maps
of option keys to values and can be merged with other TestFeatures objects. TestOptions takes a
TestFeatures at construction, and exposes getters for all keys, as well as defaults for when they are
not in the maps. In future changes, I would like to remove many of these (the ones that correspond
with WebKit preferences anyway) and have the keys and values automatically dealt with by WKPreferences.
* WebKitTestRunner/Options.cpp:
* WebKitTestRunner/Options.h:
Switch to std::unordered_map for consistency and ease of conversion.
* WebKitTestRunner/PlatformWebView.h:
(WTR::PlatformWebView::viewSupportsOptions const):
Update to call new TestOptions functions.
* WebKitTestRunner/StringFunctions.h:
(WTR::toWK):
(WTR::toWTFString):
Add conversions for std::string.
* WebKitTestRunner/TestController.h:
* WebKitTestRunner/TestController.cpp:
(WTR::TestController::initialize):
Replace some bools with a new global TestFeatures instance that forms the base of
all TestFeatures merges.
(WTR::TestController::generateContextConfiguration const):
(WTR::TestController::generatePageConfiguration):
(WTR::TestController::createWebViewWithOptions):
(WTR::TestController::ensureViewSupportsOptionsForTest):
(WTR::TestController::resetPreferencesToConsistentValues):
(WTR::TestController::resetStateToConsistentValues):
Update to call new TestOptions functions.
(WTR::TestController::createTestURL):
Expose as a static member function on TestController for use in other files.
(WTR::TestController::testOptionsForTest const):
Rework to be a sequence of TestFeatures merges.
(WTR::TestController::updateWebViewSizeForTest):
(WTR::TestController::updateWindowScaleForTest):
Update to call new TestOptions functions.
(WTR::createTestURL): Deleted.
(WTR::parseBooleanTestHeaderValue): Deleted.
(WTR::parseStringTestHeaderValueAsRelativePath): Deleted.
(WTR::parseStringTestHeaderValueAsURL): Deleted.
(WTR::updateTestOptionsFromTestHeader): Deleted.
(WTR::TestController::platformAddTestOptions const): Deleted.
Moved TestOptions parsing to TestOptions.cpp
* WebKitTestRunner/TestInvocation.cpp:
(WTR::TestInvocation::createTestSettingsDictionary):
Update to call new TestOptions functions.
* WebKitTestRunner/TestOptions.h:
Reworks TestOptions to be an immutable owner of a TestFeatures struct, which is a set
of maps that map feature string keys, to values of type bool, double, string or string vector.
* WebKitTestRunner/TestOptions.cpp:
(WTR::merge):
Merges two TestFeatures objects. If both contain the same key, the 'additional'
TestFeatures overrides the 'base' TestFeatures.
(WTR::dumpFeatures):
Helper to dump features to stderr, useful for debugging.
(WTR::keyType):
Helper for parser to know which value parser to use.
(WTR::parseBooleanTestHeaderValue):
(WTR::parseStringTestHeaderValueAsRelativePath):
(WTR::parseStringTestHeaderValueAsURL):
Value parsers moved from TestController.cpp
(WTR::parseTestHeader):
Header parser moved from TestController.cpp. Update to now return
a TestFeatures object and use keyType to pick value parser rather
than inlining the if statements.
(WTR::hardcodedFeaturesBasedOnPathForTest):
Moved from the TestOptions contructor and reworked to return a TestFeatures
object to be merged by the caller.
(WTR::featureDefaultsFromTestHeaderForTest):
Creates a TestFeatures for the test headers of the current test.
* WebKitTestRunner/cocoa/TestControllerCocoa.mm:
(WTR::TestController::platformSpecificFeatureOverridesDefaultsForTest const):
Reworked to now return a TestFeatures object that will be merged, rather than updating
a TestOptions. Moves enableInAppBrowserPrivacy work to TestController::platformWillRunTest
where it is more appropriate.
(WTR::TestController::platformInitializeDataStore):
(WTR::TestController::platformCreateWebView):
(WTR::TestController::finishCreatingPlatformWebView):
(WTR::TestController::setApplicationBundleIdentifier):
(WTR::TestController::cocoaResetStateToConsistentValues):
(WTR::contentMode):
Update to call new TestOptions functions.
* WebKitTestRunner/ios/TestControllerIOS.mm:
(WTR::TestController::platformResetStateToConsistentValues):
(WTR::TestController::platformConfigureViewForTest):
Update to call new TestOptions functions.
(WTR::TestController::platformSpecificFeatureDefaultsForTest const):
(WTR::TestController::updatePlatformSpecificTestOptionsForTest const): Deleted.
Moved GeneratedTouchesDebugWindow work to TestController::platformConfigureViewForTest
where it is more appropriate and removed shouldShowTouches setting as that is done
globally now.
* WebKitTestRunner/mac/PlatformWebViewMac.mm:
(WTR::PlatformWebView::PlatformWebView):
Update to call new TestOptions functions.
* WebKitTestRunner/mac/TestControllerMac.mm:
(WTR::TestController::platformSpecificFeatureDefaultsForTest const):
(WTR::TestController::updatePlatformSpecificTestOptionsForTest const): Deleted.
Remove shouldUseRemoteLayerTree and shouldShowWebView, as those are now done globally,
and re-implemented useThreadedScrolling to use boolFeatures.
* WebKitTestRunner/win/TestControllerWin.cpp:
(WTR::TestController::platformSpecificFeatureDefaultsForTest const):
(WTR::TestController::updatePlatformSpecificTestOptionsForTest const): Deleted.
Updated for new signature.
* WebKitTestRunner/wpe/TestControllerWPE.cpp:
(WTR::TestController::platformSpecificFeatureDefaultsForTest const):
(WTR::TestController::updatePlatformSpecificTestOptionsForTest const): Deleted.
Updated for new signature.
* WebKitTestRunner/gtk/TestControllerGTK.cpp:
(WTR::TestController::platformSpecificFeatureDefaultsForTest const):
(WTR::TestController::updatePlatformSpecificTestOptionsForTest const): Deleted.
Updated for new signature.
Canonical link: https://commits.webkit.org/230271@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@268238 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2020-10-09 00:45:29 +00:00
|
|
|
#include <unordered_map>
|
2013-12-16 04:58:10 +00:00
|
|
|
#include <vector>
|
|
|
|
#include <wtf/Vector.h>
|
2019-12-28 21:42:32 +00:00
|
|
|
#include <wtf/text/StringHash.h>
|
|
|
|
#include <wtf/text/WTFString.h>
|
2013-12-16 04:58:10 +00:00
|
|
|
|
|
|
|
namespace WTR {
|
|
|
|
|
|
|
|
struct Options {
|
2018-04-02 18:09:04 +00:00
|
|
|
bool useWaitToDumpWatchdogTimer { true };
|
|
|
|
bool forceNoTimeout { false };
|
|
|
|
bool verbose { false };
|
|
|
|
bool gcBetweenTests { false };
|
|
|
|
bool shouldDumpPixelsForAllTests { false };
|
|
|
|
bool forceComplexText { false };
|
Teach WebKitTestRunner and DumpRenderTree about detecting world leaks
https://bugs.webkit.org/show_bug.cgi?id=188994
Reviewed by Tim Horton.
Source/WebCore:
Export Document::postTask() for use by WTR's injected bundle.
* dom/Document.h:
Source/WebKit:
This patch adds the notion of a "control command" in the protocol between webkitpy and
WebKitTestRunner/DumpRenderTree. A command is simply an input string starting with a #
that is checked for before trying to parse the input as test URL. For now, just one
commmand is supported, which is "#CHECK FOR WORLD LEAKS".
In response to the command, the tool dumps an output block in the usual pseudo-MIME-style,
with a trailing "#EOF". Future patches will add support to webkitpy to parse this output.
DumpRenderTree stubs out the command, returning an empty block.
WebKitTestRunner responds to the command by dumping the list of live documents, if it was
run with the --check-for-world-leaks option.
When run with --check-for-world-leaks, WebKitTestRunner gets the list of live documents via
WKBundleGetLiveDocumentURLs() after every test (this allows it to detect the first test
that leaked a document), and keeps them in a map of document identifier to test and live document URL.
Then when it receives the "#CHECK FOR WORLD LEAKS" command, it calls into the bundle to
clear the page and memory caches, runs a GC, then posts a task (in the Document::postTaks() sense)
after which it requests the list of live documents for a final time, excluding any that are loaded
in live Frames (thus omitting the about:blank that will be loaded at this point). Documents in this
list are therefore leaked (or abandoned).
Future patches will hook up webkitpy reporting for leaked documents.
* WebProcess/InjectedBundle/API/c/WKBundle.cpp:
(WKBundleGetLiveDocumentURLs):
(WKBundleClearPageCache):
(WKBundleClearMemoryCache):
* WebProcess/InjectedBundle/API/c/WKBundlePage.cpp:
(WKBundlePagePostTask):
* WebProcess/InjectedBundle/API/c/WKBundlePage.h:
* WebProcess/InjectedBundle/API/c/WKBundlePrivate.h:
* WebProcess/InjectedBundle/InjectedBundle.cpp:
(WebKit::InjectedBundle::liveDocumentURLs):
* WebProcess/InjectedBundle/InjectedBundle.h:
Tools:
This patch adds the notion of a "control command" in the protocol between webkitpy and
WebKitTestRunner/DumpRenderTree. A command is simply an input string starting with a #
that is checked for before trying to parse the input as test URL. For now, just one
commmand is supported, which is "#CHECK FOR WORLD LEAKS".
In response to the command, the tool dumps an output block in the usual pseudo-MIME-style,
with a trailing "#EOF". Future patches will add support to webkitpy to parse this output.
DumpRenderTree stubs out the command, returning an empty block.
WebKitTestRunner responds to the command by dumping the list of live documents, if it was
run with the --check-for-world-leaks option.
When run with --check-for-world-leaks, WebKitTestRunner gets the list of live documents via
WKBundleGetLiveDocumentURLs() after every test (this allows it to detect the first test
that leaked a document), and keeps them in a map of document identifier to test and live document URL.
Then when it receives the "#CHECK FOR WORLD LEAKS" command, it calls into the bundle to
clear the page and memory caches, runs a GC, then posts a task (in the Document::postTaks() sense)
after which it requests the list of live documents for a final time, excluding any that are loaded
in live Frames (thus omitting the about:blank that will be loaded at this point). Documents in this
list are therefore leaked (or abandoned).
Future patches will hook up webkitpy reporting for leaked documents.
* DumpRenderTree/mac/DumpRenderTree.mm:
(initializeGlobalsFromCommandLineOptions):
(handleControlCommand):
(runTestingServerLoop):
* DumpRenderTree/win/DumpRenderTree.cpp:
(handleControlCommand):
(main):
* WebKitTestRunner/InjectedBundle/InjectedBundle.cpp:
(WTR::postGCTask):
(WTR::InjectedBundle::reportLiveDocuments):
(WTR::InjectedBundle::didReceiveMessageToPage):
* WebKitTestRunner/InjectedBundle/InjectedBundle.h:
* WebKitTestRunner/Options.cpp:
(WTR::handleOptionCheckForWorldLeaks):
(WTR::OptionsHandler::OptionsHandler):
* WebKitTestRunner/Options.h:
* WebKitTestRunner/TestController.cpp:
(WTR::AsyncTask::run):
(WTR::AsyncTask::currentTask):
(WTR::TestController::initialize):
(WTR::TestController::ensureViewSupportsOptionsForTest):
(WTR::TestController::resetStateToConsistentValues):
(WTR::TestController::updateLiveDocumentsAfterTest):
(WTR::TestController::checkForWorldLeaks):
(WTR::TestController::findAndDumpWorldLeaks):
(WTR::TestController::willDestroyWebView):
(WTR::parseInputLine):
(WTR::TestController::waitForCompletion):
(WTR::TestController::handleControlCommand):
(WTR::TestController::runTestingServerLoop):
(WTR::TestController::run):
(WTR::TestController::didReceiveLiveDocumentsList):
(WTR::TestController::didReceiveMessageFromInjectedBundle):
* WebKitTestRunner/TestController.h:
(WTR::AsyncTask::AsyncTask):
(WTR::AsyncTask::taskComplete):
(WTR::TestController::AbandonedDocumentInfo::AbandonedDocumentInfo):
* WebKitTestRunner/TestInvocation.cpp:
(WTR::TestInvocation::invoke):
* WebKitTestRunner/TestOptions.h:
(WTR::TestOptions::hasSameInitializationOptions const):
Canonical link: https://commits.webkit.org/204062@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@235408 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2018-08-27 23:31:15 +00:00
|
|
|
bool checkForWorldLeaks { false };
|
2018-04-02 23:12:12 +00:00
|
|
|
bool allowAnyHTTPSCertificateForAllowedHosts { false };
|
2021-04-25 00:39:43 +00:00
|
|
|
bool enableAllExperimentalFeatures { true };
|
2013-12-16 04:58:10 +00:00
|
|
|
std::vector<std::string> paths;
|
2018-04-02 23:12:12 +00:00
|
|
|
std::set<std::string> allowedHosts;
|
2020-11-04 22:22:03 +00:00
|
|
|
TestFeatures features;
|
2013-12-16 04:58:10 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
class Option {
|
|
|
|
public:
|
|
|
|
Option(const char* name, const char* description, std::function<bool(Options&, const char*, const char*)> parameterHandler, bool hasArgument = false);
|
|
|
|
bool matches(const char*);
|
|
|
|
const char* name;
|
|
|
|
const char* description;
|
|
|
|
std::function<bool(Options&, const char*, const char*)> parameterHandler;
|
|
|
|
bool hasArgument;
|
|
|
|
};
|
|
|
|
|
|
|
|
class OptionsHandler {
|
|
|
|
public:
|
|
|
|
explicit OptionsHandler(Options&);
|
|
|
|
bool parse(int argc, const char* argv[]);
|
|
|
|
void printHelp(FILE* channel = stderr);
|
|
|
|
private:
|
|
|
|
Vector<Option> optionList;
|
|
|
|
Options& options;
|
|
|
|
static const char* usage;
|
|
|
|
static const char* help;
|
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace WTR
|
|
|
|
|