https://bugs.webkit.org/show_bug.cgi?id=168171
Reviewed by Chris Dumez.
Source/WebCore:
Add an implementation of FileMonitor for GLib based ports.
* PlatformGTK.cmake:
* PlatformWPE.cmake:
* platform/FileMonitor.cpp:
* platform/FileMonitor.h:
* platform/glib/FileMonitorGLib.cpp: Added.
(WebCore::FileMonitor::FileMonitor):
(WebCore::FileMonitor::~FileMonitor):
(WebCore::FileMonitor::fileChangedCallback):
(WebCore::FileMonitor::didChange):
Source/WebKit:
Add C API to handle all resource load statistics requests made by the layout tests.
* UIProcess/API/C/WKWebsiteDataStoreRef.cpp:
(WKWebsiteDataStoreSetStatisticsLastSeen):
(WKWebsiteDataStoreSetStatisticsPrevalentResource):
(WKWebsiteDataStoreIsStatisticsPrevalentResource):
(WKWebsiteDataStoreSetStatisticsHasHadUserInteraction):
(WKWebsiteDataStoreIsStatisticsHasHadUserInteraction):
(WKWebsiteDataStoreSetStatisticsGrandfathered):
(WKWebsiteDataStoreIsStatisticsGrandfathered):
(WKWebsiteDataStoreSetStatisticsSubframeUnderTopFrameOrigin):
(WKWebsiteDataStoreSetStatisticsSubresourceUnderTopFrameOrigin):
(WKWebsiteDataStoreSetStatisticsSubresourceUniqueRedirectTo):
(WKWebsiteDataStoreSetStatisticsTimeToLiveUserInteraction):
(WKWebsiteDataStoreSetStatisticsTimeToLiveCookiePartitionFree):
(WKWebsiteDataStoreStatisticsProcessStatisticsAndDataRecords):
(WKWebsiteDataStoreStatisticsUpdateCookiePartitioning):
(WKWebsiteDataStoreSetStatisticsShouldPartitionCookiesForHost):
(WKWebsiteDataStoreStatisticsSubmitTelemetry):
(WKWebsiteDataStoreSetStatisticsNotifyPagesWhenDataRecordsWereScanned):
(WKWebsiteDataStoreSetStatisticsShouldClassifyResourcesBeforeDataRecordsRemoval):
(WKWebsiteDataStoreSetStatisticsNotifyPagesWhenTelemetryWasCaptured):
(WKWebsiteDataStoreSetStatisticsMinimumTimeBetweenDataRecordsRemoval):
(WKWebsiteDataStoreSetStatisticsGrandfatheringTime):
(WKWebsiteDataStoreSetStatisticsMaxStatisticsEntries):
(WKWebsiteDataStoreSetStatisticsPruneEntriesDownTo):
(WKWebsiteDataStoreStatisticsClearInMemoryAndPersistentStore):
(WKWebsiteDataStoreStatisticsClearInMemoryAndPersistentStoreModifiedSinceHours):
(WKWebsiteDataStoreStatisticsClearThroughWebsiteDataRemoval):
(WKWebsiteDataStoreStatisticsResetToConsistentState):
* UIProcess/API/C/WKWebsiteDataStoreRef.h:
Tools:
Implement all resource load statistics functions in TestController using the C API. Also enable the FileMonitor
unit test. This test requires a platform implementation of Util::run(), so I've added UtilitiesGLib.cpp with an
iplementation common to glib based ports using WTF RunLoop abstraction.
* TestWebKitAPI/PlatformGTK.cmake:
* TestWebKitAPI/PlatformWPE.cmake:
* TestWebKitAPI/Tests/WebCore/FileMonitor.cpp:
* TestWebKitAPI/glib/UtilitiesGLib.cpp: Copied from Source/WebKit/UIProcess/API/C/WKWebsiteDataStoreRef.h.
(TestWebKitAPI::Util::run):
(TestWebKitAPI::Util::spinRunLoop):
(TestWebKitAPI::Util::sleep):
* TestWebKitAPI/gtk/PlatformUtilitiesGtk.cpp:
* TestWebKitAPI/wpe/PlatformUtilitiesWPE.cpp:
* WebKitTestRunner/TestController.cpp:
(WTR::TestController::platformAdjustContext):
(WTR::TestController::setStatisticsLastSeen):
(WTR::TestController::setStatisticsPrevalentResource):
(WTR::ResourceStatisticsCallbackContext::ResourceStatisticsCallbackContext):
(WTR::resourceStatisticsCallback):
(WTR::TestController::isStatisticsPrevalentResource):
(WTR::TestController::setStatisticsHasHadUserInteraction):
(WTR::TestController::isStatisticsHasHadUserInteraction):
(WTR::TestController::setStatisticsGrandfathered):
(WTR::TestController::isStatisticsGrandfathered):
(WTR::TestController::setStatisticsSubframeUnderTopFrameOrigin):
(WTR::TestController::setStatisticsSubresourceUnderTopFrameOrigin):
(WTR::TestController::setStatisticsSubresourceUniqueRedirectTo):
(WTR::TestController::setStatisticsTimeToLiveUserInteraction):
(WTR::TestController::setStatisticsTimeToLiveCookiePartitionFree):
(WTR::TestController::statisticsProcessStatisticsAndDataRecords):
(WTR::TestController::statisticsUpdateCookiePartitioning):
(WTR::TestController::statisticsSetShouldPartitionCookiesForHost):
(WTR::TestController::statisticsSubmitTelemetry):
(WTR::TestController::setStatisticsNotifyPagesWhenDataRecordsWereScanned):
(WTR::TestController::setStatisticsShouldClassifyResourcesBeforeDataRecordsRemoval):
(WTR::TestController::setStatisticsNotifyPagesWhenTelemetryWasCaptured):
(WTR::TestController::setStatisticsMinimumTimeBetweenDataRecordsRemoval):
(WTR::TestController::setStatisticsGrandfatheringTime):
(WTR::TestController::setStatisticsMaxStatisticsEntries):
(WTR::TestController::setStatisticsPruneEntriesDownTo):
(WTR::TestController::statisticsClearInMemoryAndPersistentStore):
(WTR::TestController::statisticsClearInMemoryAndPersistentStoreModifiedSinceHours):
(WTR::TestController::statisticsClearThroughWebsiteDataRemovalCallback):
(WTR::TestController::statisticsClearThroughWebsiteDataRemoval):
(WTR::TestController::statisticsResetToConsistentState):
* WebKitTestRunner/TestController.h:
LayoutTests:
Unskip the tests.
* platform/wpe/TestExpectations:
* platform/wpe/TestExpectations:
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@222962
268f45cc-cd09-0410-ab3c-
d52691b4dbfc
+2017-10-05 Carlos Garcia Campos <cgarcia@igalia.com>
+
+ [GTK][WPE] All resource load statistics tests added in r212183 crash in GTK bots, timeout in GTK and WPE bots since r219049
+ https://bugs.webkit.org/show_bug.cgi?id=168171
+
+ Reviewed by Chris Dumez.
+
+ Unskip the tests.
+
+ * platform/wpe/TestExpectations:
+ * platform/wpe/TestExpectations:
+
2017-10-05 Nikita Vasilyev <nvasilyev@apple.com>
Web Inspector: Styles Redesign: Add support for keyboard navigation (Tab, Shift-Tab, Enter, Esc)
webkit.org/b/172816 media/media-source/media-source-paint-to-canvas.html [ Timeout ]
-webkit.org/b/168171 http/tests/loading/resourceLoadStatistics [ Timeout Failure ]
-
webkit.org/b/174241 media/video-inactive-playback.html [ Timeout ]
webkit.org/b/174242 media/media-fullscreen-pause-inline.html [ Timeout ]
media/encrypted-media/encrypted-media-v2-events.html [ Skip ]
media/encrypted-media/encrypted-media-v2-syntax.html [ Skip ]
-# No support for resource load statistics in test controller.
-webkit.org/b/168171 http/tests/loading/resourceLoadStatistics [ Timeout Failure ]
-
webkit.org/b/172815 imported/w3c/i18n/bidi/bidi-plaintext-011.html [ ImageOnlyFailure ]
webkit.org/b/176174 media/event-queue-crash.html [ Pass Failure ]
+2017-10-05 Carlos Garcia Campos <cgarcia@igalia.com>
+
+ [GTK][WPE] All resource load statistics tests added in r212183 crash in GTK bots, timeout in GTK and WPE bots since r219049
+ https://bugs.webkit.org/show_bug.cgi?id=168171
+
+ Reviewed by Chris Dumez.
+
+ Add an implementation of FileMonitor for GLib based ports.
+
+ * PlatformGTK.cmake:
+ * PlatformWPE.cmake:
+ * platform/FileMonitor.cpp:
+ * platform/FileMonitor.h:
+ * platform/glib/FileMonitorGLib.cpp: Added.
+ (WebCore::FileMonitor::FileMonitor):
+ (WebCore::FileMonitor::~FileMonitor):
+ (WebCore::FileMonitor::fileChangedCallback):
+ (WebCore::FileMonitor::didChange):
+
2017-10-05 Dean Jackson <dino@apple.com>
Lots of missing frames in YouTube360 when fullscreen on MacBook
platform/geoclue/GeolocationProviderGeoclue.cpp
platform/glib/EventLoopGlib.cpp
+ platform/glib/FileMonitorGLib.cpp
platform/glib/FileSystemGlib.cpp
platform/glib/KeyedDecoderGlib.cpp
platform/glib/KeyedEncoderGlib.cpp
platform/audio/glib/AudioBusGLib.cpp
platform/glib/EventLoopGlib.cpp
+ platform/glib/FileMonitorGLib.cpp
platform/glib/FileSystemGlib.cpp
platform/glib/KeyedDecoderGlib.cpp
platform/glib/KeyedEncoderGlib.cpp
namespace WebCore {
-#if !PLATFORM(COCOA)
+#if !PLATFORM(COCOA) && !USE(GLIB)
FileMonitor::FileMonitor(const String&, Ref<WorkQueue>&&, WTF::Function<void(FileChangeType)>&&)
{
#include <wtf/DispatchPtr.h>
#endif
+#if USE(GLIB)
+#include <gio/gio.h>
+#include <wtf/glib/GRefPtr.h>
+#endif
+
namespace WebCore {
class FileMonitor {
#if USE(COCOA_EVENT_LOOP)
DispatchPtr<dispatch_source_t> m_platformMonitor;
#endif
+#if USE(GLIB)
+ static void fileChangedCallback(GFileMonitor*, GFile*, GFile*, GFileMonitorEvent, FileMonitor*);
+ void didChange(FileChangeType);
+ Ref<WorkQueue> m_handlerQueue;
+ Function<void(FileChangeType)> m_modificationHandler;
+ GRefPtr<GFileMonitor> m_platformMonitor;
+ GRefPtr<GCancellable> m_cancellable;
+#endif
};
} // namespace WebCore
-
--- /dev/null
+/*
+ * Copyright (C) 2017 Igalia S.L.
+ *
+ * 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 APPLE AND ITS CONTRIBUTORS "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 APPLE OR ITS 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.
+ */
+
+#include "config.h"
+#include "FileMonitor.h"
+
+#include "FileSystem.h"
+#include <wtf/glib/GUniquePtr.h>
+
+namespace WebCore {
+
+FileMonitor::FileMonitor(const String& path, Ref<WorkQueue>&& handlerQueue, WTF::Function<void(FileChangeType)>&& modificationHandler)
+ : m_handlerQueue(WTFMove(handlerQueue))
+{
+ if (path.isEmpty() || !modificationHandler)
+ return;
+
+ auto file = adoptGRef(g_file_new_for_path(fileSystemRepresentation(path).data()));
+ m_cancellable = adoptGRef(g_cancellable_new());
+ GUniqueOutPtr<GError> error;
+ m_platformMonitor = adoptGRef(g_file_monitor(file.get(), G_FILE_MONITOR_NONE, m_cancellable.get(), &error.outPtr()));
+ if (!m_platformMonitor) {
+ WTFLogAlways("Failed to create a monitor for path %s: %s", path.utf8().data(), error->message);
+ return;
+ }
+
+ m_modificationHandler = WTFMove(modificationHandler);
+ g_signal_connect(m_platformMonitor.get(), "changed", G_CALLBACK(fileChangedCallback), this);
+}
+
+FileMonitor::~FileMonitor()
+{
+ g_cancellable_cancel(m_cancellable.get());
+}
+
+void FileMonitor::fileChangedCallback(GFileMonitor*, GFile*, GFile*, GFileMonitorEvent event, FileMonitor* monitor)
+{
+ switch (event) {
+ case G_FILE_MONITOR_EVENT_DELETED:
+ monitor->didChange(FileChangeType::Removal);
+ break;
+ case G_FILE_MONITOR_EVENT_CHANGES_DONE_HINT:
+ case G_FILE_MONITOR_EVENT_CREATED:
+ monitor->didChange(FileChangeType::Modification);
+ break;
+ default:
+ break;
+ }
+}
+
+void FileMonitor::didChange(FileChangeType type)
+{
+ m_handlerQueue->dispatch([this, cancellable = m_cancellable, type] {
+ if (g_cancellable_is_cancelled(cancellable.get()))
+ return;
+ m_modificationHandler(type);
+ if (type == FileChangeType::Removal) {
+ g_cancellable_cancel(m_cancellable.get());
+ m_platformMonitor = nullptr;
+ }
+ });
+}
+
+} // namespace WebCore
+2017-10-05 Carlos Garcia Campos <cgarcia@igalia.com>
+
+ [GTK][WPE] All resource load statistics tests added in r212183 crash in GTK bots, timeout in GTK and WPE bots since r219049
+ https://bugs.webkit.org/show_bug.cgi?id=168171
+
+ Reviewed by Chris Dumez.
+
+ Add C API to handle all resource load statistics requests made by the layout tests.
+
+ * UIProcess/API/C/WKWebsiteDataStoreRef.cpp:
+ (WKWebsiteDataStoreSetStatisticsLastSeen):
+ (WKWebsiteDataStoreSetStatisticsPrevalentResource):
+ (WKWebsiteDataStoreIsStatisticsPrevalentResource):
+ (WKWebsiteDataStoreSetStatisticsHasHadUserInteraction):
+ (WKWebsiteDataStoreIsStatisticsHasHadUserInteraction):
+ (WKWebsiteDataStoreSetStatisticsGrandfathered):
+ (WKWebsiteDataStoreIsStatisticsGrandfathered):
+ (WKWebsiteDataStoreSetStatisticsSubframeUnderTopFrameOrigin):
+ (WKWebsiteDataStoreSetStatisticsSubresourceUnderTopFrameOrigin):
+ (WKWebsiteDataStoreSetStatisticsSubresourceUniqueRedirectTo):
+ (WKWebsiteDataStoreSetStatisticsTimeToLiveUserInteraction):
+ (WKWebsiteDataStoreSetStatisticsTimeToLiveCookiePartitionFree):
+ (WKWebsiteDataStoreStatisticsProcessStatisticsAndDataRecords):
+ (WKWebsiteDataStoreStatisticsUpdateCookiePartitioning):
+ (WKWebsiteDataStoreSetStatisticsShouldPartitionCookiesForHost):
+ (WKWebsiteDataStoreStatisticsSubmitTelemetry):
+ (WKWebsiteDataStoreSetStatisticsNotifyPagesWhenDataRecordsWereScanned):
+ (WKWebsiteDataStoreSetStatisticsShouldClassifyResourcesBeforeDataRecordsRemoval):
+ (WKWebsiteDataStoreSetStatisticsNotifyPagesWhenTelemetryWasCaptured):
+ (WKWebsiteDataStoreSetStatisticsMinimumTimeBetweenDataRecordsRemoval):
+ (WKWebsiteDataStoreSetStatisticsGrandfatheringTime):
+ (WKWebsiteDataStoreSetStatisticsMaxStatisticsEntries):
+ (WKWebsiteDataStoreSetStatisticsPruneEntriesDownTo):
+ (WKWebsiteDataStoreStatisticsClearInMemoryAndPersistentStore):
+ (WKWebsiteDataStoreStatisticsClearInMemoryAndPersistentStoreModifiedSinceHours):
+ (WKWebsiteDataStoreStatisticsClearThroughWebsiteDataRemoval):
+ (WKWebsiteDataStoreStatisticsResetToConsistentState):
+ * UIProcess/API/C/WKWebsiteDataStoreRef.h:
+
2017-10-05 Tim Horton <timothy_horton@apple.com>
Fix the Mac CMake build
#include "APIWebsiteDataStore.h"
#include "WKAPICast.h"
+#include "WebResourceLoadStatisticsStore.h"
+#include "WebResourceLoadStatisticsTelemetry.h"
+#include "WebsiteData.h"
#include "WebsiteDataType.h"
+#include <WebCore/URL.h>
WKTypeID WKWebsiteDataStoreGetTypeID()
{
return WebKit::toImpl(dataStoreRef)->resourceLoadStatisticsEnabled();
}
+void WKWebsiteDataStoreSetStatisticsLastSeen(WKWebsiteDataStoreRef dataStoreRef, WKStringRef host, double seconds)
+{
+ auto* store = WebKit::toImpl(dataStoreRef)->websiteDataStore().resourceLoadStatistics();
+ if (!store)
+ return;
+
+ store->setLastSeen(WebCore::URL(WebCore::URL(), WebKit::toImpl(host)->string()), Seconds { seconds });
+}
+
+void WKWebsiteDataStoreSetStatisticsPrevalentResource(WKWebsiteDataStoreRef dataStoreRef, WKStringRef host, bool value)
+{
+ auto* store = WebKit::toImpl(dataStoreRef)->websiteDataStore().resourceLoadStatistics();
+ if (!store)
+ return;
+
+ if (value)
+ store->setPrevalentResource(WebCore::URL(WebCore::URL(), WebKit::toImpl(host)->string()));
+ else
+ store->clearPrevalentResource(WebCore::URL(WebCore::URL(), WebKit::toImpl(host)->string()));
+}
+
+void WKWebsiteDataStoreIsStatisticsPrevalentResource(WKWebsiteDataStoreRef dataStoreRef, WKStringRef host, void* context, WKWebsiteDataStoreIsStatisticsPrevalentResourceFunction callback)
+{
+ auto* store = WebKit::toImpl(dataStoreRef)->websiteDataStore().resourceLoadStatistics();
+ if (!store) {
+ callback(false, context);
+ return;
+ }
+
+ store->isPrevalentResource(WebCore::URL(WebCore::URL(), WebKit::toImpl(host)->string()), [context, callback](bool isPrevalentResource) {
+ callback(isPrevalentResource, context);
+ });
+}
+
+void WKWebsiteDataStoreSetStatisticsHasHadUserInteraction(WKWebsiteDataStoreRef dataStoreRef, WKStringRef host, bool value)
+{
+ auto* store = WebKit::toImpl(dataStoreRef)->websiteDataStore().resourceLoadStatistics();
+ if (!store)
+ return;
+
+ if (value)
+ store->logUserInteraction(WebCore::URL(WebCore::URL(), WebKit::toImpl(host)->string()));
+ else
+ store->clearUserInteraction(WebCore::URL(WebCore::URL(), WebKit::toImpl(host)->string()));
+}
+
+void WKWebsiteDataStoreIsStatisticsHasHadUserInteraction(WKWebsiteDataStoreRef dataStoreRef, WKStringRef host, void* context, WKWebsiteDataStoreIsStatisticsHasHadUserInteractionFunction callback)
+{
+ auto* store = WebKit::toImpl(dataStoreRef)->websiteDataStore().resourceLoadStatistics();
+ if (!store) {
+ callback(false, context);
+ return;
+ }
+
+ store->hasHadUserInteraction(WebCore::URL(WebCore::URL(), WebKit::toImpl(host)->string()), [context, callback](bool hasHadUserInteraction) {
+ callback(hasHadUserInteraction, context);
+ });
+}
+
+void WKWebsiteDataStoreSetStatisticsGrandfathered(WKWebsiteDataStoreRef dataStoreRef, WKStringRef host, bool value)
+{
+ auto* store = WebKit::toImpl(dataStoreRef)->websiteDataStore().resourceLoadStatistics();
+ if (!store)
+ return;
+
+ store->setGrandfathered(WebCore::URL(WebCore::URL(), WebKit::toImpl(host)->string()), value);
+}
+
+void WKWebsiteDataStoreIsStatisticsGrandfathered(WKWebsiteDataStoreRef dataStoreRef, WKStringRef host, void* context, WKWebsiteDataStoreIsStatisticsGrandfatheredFunction callback)
+{
+ auto* store = WebKit::toImpl(dataStoreRef)->websiteDataStore().resourceLoadStatistics();
+ if (!store) {
+ callback(false, context);
+ return;
+ }
+
+ store->hasHadUserInteraction(WebCore::URL(WebCore::URL(), WebKit::toImpl(host)->string()), [context, callback](bool isGrandfathered) {
+ callback(isGrandfathered, context);
+ });
+}
+
+void WKWebsiteDataStoreSetStatisticsSubframeUnderTopFrameOrigin(WKWebsiteDataStoreRef dataStoreRef, WKStringRef host, WKStringRef topFrameHost)
+{
+ auto* store = WebKit::toImpl(dataStoreRef)->websiteDataStore().resourceLoadStatistics();
+ if (!store)
+ return;
+
+ store->setSubframeUnderTopFrameOrigin(WebCore::URL(WebCore::URL(), WebKit::toImpl(host)->string()), WebCore::URL(WebCore::URL(), WebKit::toImpl(topFrameHost)->string()));
+}
+
+void WKWebsiteDataStoreSetStatisticsSubresourceUnderTopFrameOrigin(WKWebsiteDataStoreRef dataStoreRef, WKStringRef host, WKStringRef topFrameHost)
+{
+ auto* store = WebKit::toImpl(dataStoreRef)->websiteDataStore().resourceLoadStatistics();
+ if (!store)
+ return;
+
+ store->setSubresourceUnderTopFrameOrigin(WebCore::URL(WebCore::URL(), WebKit::toImpl(host)->string()), WebCore::URL(WebCore::URL(), WebKit::toImpl(topFrameHost)->string()));
+}
+
+void WKWebsiteDataStoreSetStatisticsSubresourceUniqueRedirectTo(WKWebsiteDataStoreRef dataStoreRef, WKStringRef host, WKStringRef hostRedirectedTo)
+{
+ auto* store = WebKit::toImpl(dataStoreRef)->websiteDataStore().resourceLoadStatistics();
+ if (!store)
+ return;
+
+ store->setSubresourceUniqueRedirectTo(WebCore::URL(WebCore::URL(), WebKit::toImpl(host)->string()), WebCore::URL(WebCore::URL(), WebKit::toImpl(hostRedirectedTo)->string()));
+}
+
+void WKWebsiteDataStoreSetStatisticsTimeToLiveUserInteraction(WKWebsiteDataStoreRef dataStoreRef, double seconds)
+{
+ auto* store = WebKit::toImpl(dataStoreRef)->websiteDataStore().resourceLoadStatistics();
+ if (!store)
+ return;
+
+ store->setTimeToLiveUserInteraction(Seconds { seconds });
+}
+
+void WKWebsiteDataStoreSetStatisticsTimeToLiveCookiePartitionFree(WKWebsiteDataStoreRef dataStoreRef, double seconds)
+{
+ auto* store = WebKit::toImpl(dataStoreRef)->websiteDataStore().resourceLoadStatistics();
+ if (!store)
+ return;
+
+ store->setTimeToLiveCookiePartitionFree(Seconds { seconds });
+}
+
+void WKWebsiteDataStoreStatisticsProcessStatisticsAndDataRecords(WKWebsiteDataStoreRef dataStoreRef)
+{
+ auto* store = WebKit::toImpl(dataStoreRef)->websiteDataStore().resourceLoadStatistics();
+ if (!store)
+ return;
+
+ store->scheduleStatisticsAndDataRecordsProcessing();
+}
+
+void WKWebsiteDataStoreStatisticsUpdateCookiePartitioning(WKWebsiteDataStoreRef dataStoreRef)
+{
+ auto* store = WebKit::toImpl(dataStoreRef)->websiteDataStore().resourceLoadStatistics();
+ if (!store)
+ return;
+
+ store->scheduleCookiePartitioningUpdate();
+}
+
+void WKWebsiteDataStoreSetStatisticsShouldPartitionCookiesForHost(WKWebsiteDataStoreRef dataStoreRef, WKStringRef host, bool value)
+{
+ auto* store = WebKit::toImpl(dataStoreRef)->websiteDataStore().resourceLoadStatistics();
+ if (!store)
+ return;
+
+ if (value)
+ store->scheduleCookiePartitioningUpdateForDomains({ WebKit::toImpl(host)->string() }, { }, { }, WebKit::ShouldClearFirst::No);
+ else
+ store->scheduleClearPartitioningStateForDomains({ WebKit::toImpl(host)->string() });
+}
+
+void WKWebsiteDataStoreStatisticsSubmitTelemetry(WKWebsiteDataStoreRef dataStoreRef)
+{
+ auto* store = WebKit::toImpl(dataStoreRef)->websiteDataStore().resourceLoadStatistics();
+ if (!store)
+ return;
+
+ store->submitTelemetry();
+}
+
+void WKWebsiteDataStoreSetStatisticsNotifyPagesWhenDataRecordsWereScanned(WKWebsiteDataStoreRef dataStoreRef, bool value)
+{
+ auto* store = WebKit::toImpl(dataStoreRef)->websiteDataStore().resourceLoadStatistics();
+ if (!store)
+ return;
+
+ store->setNotifyPagesWhenDataRecordsWereScanned(value);
+}
+
+void WKWebsiteDataStoreSetStatisticsShouldClassifyResourcesBeforeDataRecordsRemoval(WKWebsiteDataStoreRef dataStoreRef, bool value)
+{
+ auto* store = WebKit::toImpl(dataStoreRef)->websiteDataStore().resourceLoadStatistics();
+ if (!store)
+ return;
+
+ store->setShouldClassifyResourcesBeforeDataRecordsRemoval(value);
+}
+
+void WKWebsiteDataStoreSetStatisticsNotifyPagesWhenTelemetryWasCaptured(WKWebsiteDataStoreRef, bool value)
+{
+ WebKit::WebResourceLoadStatisticsTelemetry::setNotifyPagesWhenTelemetryWasCaptured(value);
+}
+
+void WKWebsiteDataStoreSetStatisticsMinimumTimeBetweenDataRecordsRemoval(WKWebsiteDataStoreRef dataStoreRef, double seconds)
+{
+ auto* store = WebKit::toImpl(dataStoreRef)->websiteDataStore().resourceLoadStatistics();
+ if (!store)
+ return;
+
+ store->setMinimumTimeBetweenDataRecordsRemoval(Seconds { seconds });
+}
+
+void WKWebsiteDataStoreSetStatisticsGrandfatheringTime(WKWebsiteDataStoreRef dataStoreRef, double seconds)
+{
+ auto* store = WebKit::toImpl(dataStoreRef)->websiteDataStore().resourceLoadStatistics();
+ if (!store)
+ return;
+
+ store->setGrandfatheringTime(Seconds {seconds });
+}
+
+void WKWebsiteDataStoreSetStatisticsMaxStatisticsEntries(WKWebsiteDataStoreRef dataStoreRef, unsigned entries)
+{
+ auto* store = WebKit::toImpl(dataStoreRef)->websiteDataStore().resourceLoadStatistics();
+ if (!store)
+ return;
+
+ store->setMaxStatisticsEntries(entries);
+}
+
+void WKWebsiteDataStoreSetStatisticsPruneEntriesDownTo(WKWebsiteDataStoreRef dataStoreRef, unsigned entries)
+{
+ auto* store = WebKit::toImpl(dataStoreRef)->websiteDataStore().resourceLoadStatistics();
+ if (!store)
+ return;
+
+ store->setPruneEntriesDownTo(entries);
+}
+
+void WKWebsiteDataStoreStatisticsClearInMemoryAndPersistentStore(WKWebsiteDataStoreRef dataStoreRef)
+{
+ auto* store = WebKit::toImpl(dataStoreRef)->websiteDataStore().resourceLoadStatistics();
+ if (!store)
+ return;
+
+ store->scheduleClearInMemoryAndPersistent(WebKit::WebResourceLoadStatisticsStore::ShouldGrandfather::Yes);
+}
+
+void WKWebsiteDataStoreStatisticsClearInMemoryAndPersistentStoreModifiedSinceHours(WKWebsiteDataStoreRef dataStoreRef, unsigned hours)
+{
+ auto* store = WebKit::toImpl(dataStoreRef)->websiteDataStore().resourceLoadStatistics();
+ if (!store)
+ return;
+
+ store->scheduleClearInMemoryAndPersistent(std::chrono::system_clock::now() - std::chrono::hours(hours), WebKit::WebResourceLoadStatisticsStore::ShouldGrandfather::Yes);
+}
+
+void WKWebsiteDataStoreStatisticsClearThroughWebsiteDataRemoval(WKWebsiteDataStoreRef dataStoreRef, void* context, WKWebsiteDataStoreStatisticsClearThroughWebsiteDataRemovalFunction callback)
+{
+ OptionSet<WebKit::WebsiteDataType> dataTypes = WebKit::WebsiteDataType::ResourceLoadStatistics;
+ WebKit::toImpl(dataStoreRef)->websiteDataStore().removeData(dataTypes, std::chrono::system_clock::from_time_t(0), [context, callback] {
+ callback(context);
+ });
+}
+
+void WKWebsiteDataStoreStatisticsResetToConsistentState(WKWebsiteDataStoreRef dataStoreRef)
+{
+ auto* store = WebKit::toImpl(dataStoreRef)->websiteDataStore().resourceLoadStatistics();
+ if (!store)
+ return;
+
+ store->resetParametersToDefaultValues();
+ store->scheduleClearInMemory();
+}
+
void WKWebsiteDataStoreRemoveAllIndexedDatabases(WKWebsiteDataStoreRef dataStoreRef)
{
OptionSet<WebKit::WebsiteDataType> dataTypes = WebKit::WebsiteDataType::IndexedDBDatabases;
WK_EXPORT bool WKWebsiteDataStoreGetResourceLoadStatisticsEnabled(WKWebsiteDataStoreRef dataStoreRef);
WK_EXPORT void WKWebsiteDataStoreSetResourceLoadStatisticsEnabled(WKWebsiteDataStoreRef dataStoreRef, bool enable);
+WK_EXPORT void WKWebsiteDataStoreSetStatisticsLastSeen(WKWebsiteDataStoreRef dataStoreRef, WKStringRef host, double seconds);
+WK_EXPORT void WKWebsiteDataStoreSetStatisticsPrevalentResource(WKWebsiteDataStoreRef dataStoreRef, WKStringRef host, bool value);
+typedef void (*WKWebsiteDataStoreIsStatisticsPrevalentResourceFunction)(bool isPrevalentResource, void* functionContext);
+WK_EXPORT void WKWebsiteDataStoreIsStatisticsPrevalentResource(WKWebsiteDataStoreRef dataStoreRef, WKStringRef host, void* context, WKWebsiteDataStoreIsStatisticsPrevalentResourceFunction callback);
+WK_EXPORT void WKWebsiteDataStoreSetStatisticsHasHadUserInteraction(WKWebsiteDataStoreRef dataStoreRef, WKStringRef host, bool value);
+typedef void (*WKWebsiteDataStoreIsStatisticsHasHadUserInteractionFunction)(bool hasHadUserInteraction, void* functionContext);
+WK_EXPORT void WKWebsiteDataStoreIsStatisticsHasHadUserInteraction(WKWebsiteDataStoreRef dataStoreRef, WKStringRef host, void* context, WKWebsiteDataStoreIsStatisticsHasHadUserInteractionFunction callback);
+WK_EXPORT void WKWebsiteDataStoreSetStatisticsGrandfathered(WKWebsiteDataStoreRef dataStoreRef, WKStringRef host, bool value);
+typedef void (*WKWebsiteDataStoreIsStatisticsGrandfatheredFunction)(bool isGrandfathered, void* functionContext);
+WK_EXPORT void WKWebsiteDataStoreIsStatisticsGrandfathered(WKWebsiteDataStoreRef dataStoreRef, WKStringRef host, void* context, WKWebsiteDataStoreIsStatisticsGrandfatheredFunction callback);
+WK_EXPORT void WKWebsiteDataStoreSetStatisticsSubframeUnderTopFrameOrigin(WKWebsiteDataStoreRef dataStoreRef, WKStringRef host, WKStringRef topFrameHost);
+WK_EXPORT void WKWebsiteDataStoreSetStatisticsSubresourceUnderTopFrameOrigin(WKWebsiteDataStoreRef dataStoreRef, WKStringRef host, WKStringRef topFrameHost);
+WK_EXPORT void WKWebsiteDataStoreSetStatisticsSubresourceUniqueRedirectTo(WKWebsiteDataStoreRef dataStoreRef, WKStringRef host, WKStringRef hostRedirectedTo);
+WK_EXPORT void WKWebsiteDataStoreSetStatisticsTimeToLiveUserInteraction(WKWebsiteDataStoreRef dataStoreRef, double seconds);
+WK_EXPORT void WKWebsiteDataStoreSetStatisticsTimeToLiveCookiePartitionFree(WKWebsiteDataStoreRef dataStoreRef, double seconds);
+WK_EXPORT void WKWebsiteDataStoreStatisticsProcessStatisticsAndDataRecords(WKWebsiteDataStoreRef dataStoreRef);
+WK_EXPORT void WKWebsiteDataStoreStatisticsUpdateCookiePartitioning(WKWebsiteDataStoreRef dataStoreRef);
+WK_EXPORT void WKWebsiteDataStoreSetStatisticsShouldPartitionCookiesForHost(WKWebsiteDataStoreRef dataStoreRef, WKStringRef host, bool value);
+WK_EXPORT void WKWebsiteDataStoreStatisticsSubmitTelemetry(WKWebsiteDataStoreRef dataStoreRef);
+WK_EXPORT void WKWebsiteDataStoreSetStatisticsNotifyPagesWhenDataRecordsWereScanned(WKWebsiteDataStoreRef dataStoreRef, bool value);
+WK_EXPORT void WKWebsiteDataStoreSetStatisticsShouldClassifyResourcesBeforeDataRecordsRemoval(WKWebsiteDataStoreRef dataStoreRef, bool value);
+WK_EXPORT void WKWebsiteDataStoreSetStatisticsNotifyPagesWhenTelemetryWasCaptured(WKWebsiteDataStoreRef dataStoreRef, bool value);
+WK_EXPORT void WKWebsiteDataStoreSetStatisticsMinimumTimeBetweenDataRecordsRemoval(WKWebsiteDataStoreRef dataStoreRef, double seconds);
+WK_EXPORT void WKWebsiteDataStoreSetStatisticsGrandfatheringTime(WKWebsiteDataStoreRef dataStoreRef, double seconds);
+WK_EXPORT void WKWebsiteDataStoreSetStatisticsMaxStatisticsEntries(WKWebsiteDataStoreRef dataStoreRef, unsigned entries);
+WK_EXPORT void WKWebsiteDataStoreSetStatisticsPruneEntriesDownTo(WKWebsiteDataStoreRef dataStoreRef, unsigned entries);
+WK_EXPORT void WKWebsiteDataStoreStatisticsClearInMemoryAndPersistentStore(WKWebsiteDataStoreRef dataStoreRef);
+WK_EXPORT void WKWebsiteDataStoreStatisticsClearInMemoryAndPersistentStoreModifiedSinceHours(WKWebsiteDataStoreRef dataStoreRef, unsigned hours);
+typedef void (*WKWebsiteDataStoreStatisticsClearThroughWebsiteDataRemovalFunction)(void* functionContext);
+WK_EXPORT void WKWebsiteDataStoreStatisticsClearThroughWebsiteDataRemoval(WKWebsiteDataStoreRef dataStoreRef, void* context, WKWebsiteDataStoreStatisticsClearThroughWebsiteDataRemovalFunction callback);
+WK_EXPORT void WKWebsiteDataStoreStatisticsResetToConsistentState(WKWebsiteDataStoreRef dataStoreRef);
WK_EXPORT void WKWebsiteDataStoreRemoveAllIndexedDatabases(WKWebsiteDataStoreRef dataStoreRef);
#ifdef __cplusplus
+2017-10-05 Carlos Garcia Campos <cgarcia@igalia.com>
+
+ [GTK][WPE] All resource load statistics tests added in r212183 crash in GTK bots, timeout in GTK and WPE bots since r219049
+ https://bugs.webkit.org/show_bug.cgi?id=168171
+
+ Reviewed by Chris Dumez.
+
+ Implement all resource load statistics functions in TestController using the C API. Also enable the FileMonitor
+ unit test. This test requires a platform implementation of Util::run(), so I've added UtilitiesGLib.cpp with an
+ iplementation common to glib based ports using WTF RunLoop abstraction.
+
+ * TestWebKitAPI/PlatformGTK.cmake:
+ * TestWebKitAPI/PlatformWPE.cmake:
+ * TestWebKitAPI/Tests/WebCore/FileMonitor.cpp:
+ * TestWebKitAPI/glib/UtilitiesGLib.cpp: Copied from Source/WebKit/UIProcess/API/C/WKWebsiteDataStoreRef.h.
+ (TestWebKitAPI::Util::run):
+ (TestWebKitAPI::Util::spinRunLoop):
+ (TestWebKitAPI::Util::sleep):
+ * TestWebKitAPI/gtk/PlatformUtilitiesGtk.cpp:
+ * TestWebKitAPI/wpe/PlatformUtilitiesWPE.cpp:
+ * WebKitTestRunner/TestController.cpp:
+ (WTR::TestController::platformAdjustContext):
+ (WTR::TestController::setStatisticsLastSeen):
+ (WTR::TestController::setStatisticsPrevalentResource):
+ (WTR::ResourceStatisticsCallbackContext::ResourceStatisticsCallbackContext):
+ (WTR::resourceStatisticsCallback):
+ (WTR::TestController::isStatisticsPrevalentResource):
+ (WTR::TestController::setStatisticsHasHadUserInteraction):
+ (WTR::TestController::isStatisticsHasHadUserInteraction):
+ (WTR::TestController::setStatisticsGrandfathered):
+ (WTR::TestController::isStatisticsGrandfathered):
+ (WTR::TestController::setStatisticsSubframeUnderTopFrameOrigin):
+ (WTR::TestController::setStatisticsSubresourceUnderTopFrameOrigin):
+ (WTR::TestController::setStatisticsSubresourceUniqueRedirectTo):
+ (WTR::TestController::setStatisticsTimeToLiveUserInteraction):
+ (WTR::TestController::setStatisticsTimeToLiveCookiePartitionFree):
+ (WTR::TestController::statisticsProcessStatisticsAndDataRecords):
+ (WTR::TestController::statisticsUpdateCookiePartitioning):
+ (WTR::TestController::statisticsSetShouldPartitionCookiesForHost):
+ (WTR::TestController::statisticsSubmitTelemetry):
+ (WTR::TestController::setStatisticsNotifyPagesWhenDataRecordsWereScanned):
+ (WTR::TestController::setStatisticsShouldClassifyResourcesBeforeDataRecordsRemoval):
+ (WTR::TestController::setStatisticsNotifyPagesWhenTelemetryWasCaptured):
+ (WTR::TestController::setStatisticsMinimumTimeBetweenDataRecordsRemoval):
+ (WTR::TestController::setStatisticsGrandfatheringTime):
+ (WTR::TestController::setStatisticsMaxStatisticsEntries):
+ (WTR::TestController::setStatisticsPruneEntriesDownTo):
+ (WTR::TestController::statisticsClearInMemoryAndPersistentStore):
+ (WTR::TestController::statisticsClearInMemoryAndPersistentStoreModifiedSinceHours):
+ (WTR::TestController::statisticsClearThroughWebsiteDataRemovalCallback):
+ (WTR::TestController::statisticsClearThroughWebsiteDataRemoval):
+ (WTR::TestController::statisticsResetToConsistentState):
+ * WebKitTestRunner/TestController.h:
+
2017-10-05 Jer Noble <jer.noble@apple.com>
[Cocoa] Enable ENABLE_ENCRYPTED_MEDIA build-time setting
)
set(bundle_harness_SOURCES
+ ${TESTWEBKITAPI_DIR}/glib/UtilitiesGLib.cpp
${TESTWEBKITAPI_DIR}/gtk/InjectedBundleControllerGtk.cpp
${TESTWEBKITAPI_DIR}/gtk/PlatformUtilitiesGtk.cpp
)
set(webkit_api_harness_SOURCES
+ ${TESTWEBKITAPI_DIR}/glib/UtilitiesGLib.cpp
${TESTWEBKITAPI_DIR}/gtk/PlatformUtilitiesGtk.cpp
${TESTWEBKITAPI_DIR}/gtk/PlatformWebViewGtk.cpp
)
add_executable(TestWebCore
${test_main_SOURCES}
+ ${TESTWEBKITAPI_DIR}/glib/UtilitiesGLib.cpp
${TESTWEBKITAPI_DIR}/TestsController.cpp
${TESTWEBKITAPI_DIR}/Tests/WebCore/CSSParser.cpp
${TESTWEBKITAPI_DIR}/Tests/WebCore/ComplexTextController.cpp
+ ${TESTWEBKITAPI_DIR}/Tests/WebCore/FileMonitor.cpp
${TESTWEBKITAPI_DIR}/Tests/WebCore/FileSystem.cpp
${TESTWEBKITAPI_DIR}/Tests/WebCore/GridPosition.cpp
${TESTWEBKITAPI_DIR}/Tests/WebCore/HTMLParserIdioms.cpp
)
set(bundle_harness_SOURCES
+ ${TESTWEBKITAPI_DIR}/glib/UtilitiesGLib.cpp
${TESTWEBKITAPI_DIR}/wpe/InjectedBundleControllerWPE.cpp
${TESTWEBKITAPI_DIR}/wpe/PlatformUtilitiesWPE.cpp
)
add_executable(TestWebCore
${test_main_SOURCES}
+ ${TESTWEBKITAPI_DIR}/glib/UtilitiesGLib.cpp
${TESTWEBKITAPI_DIR}/TestsController.cpp
${TESTWEBKITAPI_DIR}/Tests/WebCore/HTMLParserIdioms.cpp
${TESTWEBKITAPI_DIR}/Tests/WebCore/LayoutUnit.cpp
${TESTWEBKITAPI_DIR}/Tests/WebCore/URL.cpp
${TESTWEBKITAPI_DIR}/Tests/WebCore/SharedBuffer.cpp
${TESTWEBKITAPI_DIR}/Tests/WebCore/SharedBufferTest.cpp
+ ${TESTWEBKITAPI_DIR}/Tests/WebCore/FileMonitor.cpp
${TESTWEBKITAPI_DIR}/Tests/WebCore/FileSystem.cpp
${TESTWEBKITAPI_DIR}/Tests/WebCore/PublicSuffix.cpp
)
* THE POSSIBILITY OF SUCH DAMAGE.
*/
-#import "config.h"
-
-#import "PlatformUtilities.h"
-#import "Test.h"
-#import "WTFStringUtilities.h"
-#import <WebCore/FileMonitor.h>
-#import <WebCore/FileSystem.h>
-#import <WebCore/ScopeGuard.h>
-#import <wtf/MainThread.h>
-#import <wtf/RunLoop.h>
-#import <wtf/StringExtras.h>
-#import <wtf/WorkQueue.h>
-#import <wtf/text/StringBuffer.h>
-
-// Note: Currently, only a Cocoa implementation exists. This could probably be supported under GTK using g_file_monitor_file
+#include "config.h"
+
+#include "PlatformUtilities.h"
+#include "Test.h"
+#include "WTFStringUtilities.h"
+#include <WebCore/FileMonitor.h>
+#include <WebCore/FileSystem.h>
+#include <WebCore/ScopeGuard.h>
+#include <wtf/MainThread.h>
+#include <wtf/RunLoop.h>
+#include <wtf/StringExtras.h>
+#include <wtf/WorkQueue.h>
+#include <wtf/text/StringBuffer.h>
+
// Note: Disabling iOS since 'system' is not available on that platform.
-#if PLATFORM(MAC)
+#if PLATFORM(MAC) || PLATFORM(GTK) || PLATFORM(WPE)
using namespace WebCore;
--- /dev/null
+/*
+ * Copyright (C) 2017 Igalia S.L.
+ *
+ * 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 APPLE INC. AND ITS CONTRIBUTORS ``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 APPLE INC. OR ITS 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.
+ */
+
+#include "config.h"
+#include "Utilities.h"
+
+#include <glib.h>
+#include <wtf/RunLoop.h>
+
+namespace TestWebKitAPI {
+namespace Util {
+
+void run(bool* done)
+{
+ g_idle_add([](gpointer userData) -> gboolean {
+ bool* done = static_cast<bool*>(userData);
+ if (*done)
+ RunLoop::main().stop();
+
+ return !*done;
+ }, done);
+ RunLoop::run();
+}
+
+void spinRunLoop(uint64_t count)
+{
+ g_idle_add([](gpointer userData) -> gboolean {
+ uint64_t* count = static_cast<uint64_t*>(userData);
+ return --(*count) ? G_SOURCE_CONTINUE : G_SOURCE_REMOVE;
+ }, &count);
+}
+
+void sleep(double seconds)
+{
+ g_timeout_add(seconds * 1000, [](gpointer userData) -> gboolean {
+ RunLoop::main().stop();
+ return G_SOURCE_REMOVE;
+ }, nullptr);
+ RunLoop::main().stop();
+}
+
+} // namespace Util
+} // namespace TestWebKitAPI
namespace TestWebKitAPI {
namespace Util {
-static gboolean checkTestFinished(gpointer userData)
-{
- bool* done = static_cast<bool*>(userData);
-
- if (*done)
- gtk_main_quit();
-
- return !*done;
-}
-
-void run(bool* done)
-{
- g_idle_add(checkTestFinished, done);
- gtk_main();
-}
-
-void sleep(double seconds)
-{
- g_usleep(seconds * 1000000);
-}
-
static char* getFilenameFromEnvironmentVariableAsUTF8(const char* variableName)
{
const char* value = g_getenv(variableName);
namespace TestWebKitAPI {
namespace Util {
-void sleep(double seconds)
-{
- g_usleep(seconds * 1000000);
-}
-
static char* getFilenameFromEnvironmentVariableAsUTF8(const char* variableName)
{
const char* value = g_getenv(variableName);
#include <WebKit/WKSecurityOriginRef.h>
#include <WebKit/WKTextChecker.h>
#include <WebKit/WKUserMediaPermissionCheck.h>
+#include <WebKit/WKWebsiteDataStoreRef.h>
#include <algorithm>
#include <cstdio>
#include <ctype.h>
WKContextRef TestController::platformAdjustContext(WKContextRef context, WKContextConfigurationRef contextConfiguration)
{
+ auto* dataStore = WKContextGetWebsiteDataStore(context);
+ WKWebsiteDataStoreSetResourceLoadStatisticsEnabled(dataStore, true);
return context;
}
#if !PLATFORM(COCOA) || !WK_API_ENABLED
-void TestController::setStatisticsLastSeen(WKStringRef, double)
+void TestController::setStatisticsLastSeen(WKStringRef host, double seconds)
{
+ auto* dataStore = WKContextGetWebsiteDataStore(platformContext());
+ WKWebsiteDataStoreSetStatisticsLastSeen(dataStore, host, seconds);
}
-
-void TestController::setStatisticsPrevalentResource(WKStringRef, bool)
+
+void TestController::setStatisticsPrevalentResource(WKStringRef host, bool value)
{
+ auto* dataStore = WKContextGetWebsiteDataStore(platformContext());
+ WKWebsiteDataStoreSetStatisticsPrevalentResource(dataStore, host, value);
}
-bool TestController::isStatisticsPrevalentResource(WKStringRef)
+struct ResourceStatisticsCallbackContext {
+ explicit ResourceStatisticsCallbackContext(TestController& controller)
+ : testController(controller)
+ {
+ }
+
+ TestController& testController;
+ bool done { false };
+ bool result { false };
+};
+
+static void resourceStatisticsCallback(bool result, void* userData)
{
- return false;
+ auto* context = static_cast<ResourceStatisticsCallbackContext*>(userData);
+ context->result = result;
+ context->done = true;
+ context->testController.notifyDone();
}
-void TestController::setStatisticsHasHadUserInteraction(WKStringRef, bool)
+bool TestController::isStatisticsPrevalentResource(WKStringRef host)
{
+ auto* dataStore = WKContextGetWebsiteDataStore(platformContext());
+ ResourceStatisticsCallbackContext context(*this);
+ WKWebsiteDataStoreIsStatisticsPrevalentResource(dataStore, host, &context, resourceStatisticsCallback);
+ if (!context.done)
+ runUntil(context.done, m_currentInvocation->shortTimeout());
+ return context.result;
}
-bool TestController::isStatisticsHasHadUserInteraction(WKStringRef)
+void TestController::setStatisticsHasHadUserInteraction(WKStringRef host, bool value)
{
- return false;
+ auto* dataStore = WKContextGetWebsiteDataStore(platformContext());
+ WKWebsiteDataStoreSetStatisticsHasHadUserInteraction(dataStore, host, value);
}
-void TestController::setStatisticsGrandfathered(WKStringRef, bool)
+bool TestController::isStatisticsHasHadUserInteraction(WKStringRef host)
{
+ auto* dataStore = WKContextGetWebsiteDataStore(platformContext());
+ ResourceStatisticsCallbackContext context(*this);
+ WKWebsiteDataStoreIsStatisticsHasHadUserInteraction(dataStore, host, &context, resourceStatisticsCallback);
+ if (!context.done)
+ runUntil(context.done, m_currentInvocation->shortTimeout());
+ return context.result;
}
-bool TestController::isStatisticsGrandfathered(WKStringRef)
+void TestController::setStatisticsGrandfathered(WKStringRef host, bool value)
{
- return false;
+ auto* dataStore = WKContextGetWebsiteDataStore(platformContext());
+ WKWebsiteDataStoreSetStatisticsGrandfathered(dataStore, host, value);
}
-void TestController::setStatisticsSubframeUnderTopFrameOrigin(WKStringRef, WKStringRef)
+bool TestController::isStatisticsGrandfathered(WKStringRef host)
{
+ auto* dataStore = WKContextGetWebsiteDataStore(platformContext());
+ ResourceStatisticsCallbackContext context(*this);
+ WKWebsiteDataStoreIsStatisticsGrandfathered(dataStore, host, &context, resourceStatisticsCallback);
+ if (!context.done)
+ runUntil(context.done, m_currentInvocation->shortTimeout());
+ return context.result;
}
-void TestController::setStatisticsSubresourceUnderTopFrameOrigin(WKStringRef, WKStringRef)
+void TestController::setStatisticsSubframeUnderTopFrameOrigin(WKStringRef host, WKStringRef topFrameHost)
{
+ auto* dataStore = WKContextGetWebsiteDataStore(platformContext());
+ WKWebsiteDataStoreSetStatisticsSubframeUnderTopFrameOrigin(dataStore, host, topFrameHost);
}
-void TestController::setStatisticsSubresourceUniqueRedirectTo(WKStringRef, WKStringRef)
+void TestController::setStatisticsSubresourceUnderTopFrameOrigin(WKStringRef host, WKStringRef topFrameHost)
{
+ auto* dataStore = WKContextGetWebsiteDataStore(platformContext());
+ WKWebsiteDataStoreSetStatisticsSubresourceUnderTopFrameOrigin(dataStore, host, topFrameHost);
}
-void TestController::setStatisticsTimeToLiveUserInteraction(double)
+void TestController::setStatisticsSubresourceUniqueRedirectTo(WKStringRef host, WKStringRef hostRedirectedTo)
{
+ auto* dataStore = WKContextGetWebsiteDataStore(platformContext());
+ WKWebsiteDataStoreSetStatisticsSubresourceUniqueRedirectTo(dataStore, host, hostRedirectedTo);
}
-void TestController::setStatisticsTimeToLiveCookiePartitionFree(double)
+void TestController::setStatisticsTimeToLiveUserInteraction(double seconds)
{
+ auto* dataStore = WKContextGetWebsiteDataStore(platformContext());
+ WKWebsiteDataStoreSetStatisticsTimeToLiveUserInteraction(dataStore, seconds);
+}
+
+void TestController::setStatisticsTimeToLiveCookiePartitionFree(double seconds)
+{
+ auto* dataStore = WKContextGetWebsiteDataStore(platformContext());
+ WKWebsiteDataStoreSetStatisticsTimeToLiveCookiePartitionFree(dataStore, seconds);
}
void TestController::statisticsProcessStatisticsAndDataRecords()
{
+ auto* dataStore = WKContextGetWebsiteDataStore(platformContext());
+ WKWebsiteDataStoreStatisticsProcessStatisticsAndDataRecords(dataStore);
}
void TestController::statisticsUpdateCookiePartitioning()
{
+ auto* dataStore = WKContextGetWebsiteDataStore(platformContext());
+ WKWebsiteDataStoreStatisticsUpdateCookiePartitioning(dataStore);
}
-void TestController::statisticsSetShouldPartitionCookiesForHost(WKStringRef, bool)
+void TestController::statisticsSetShouldPartitionCookiesForHost(WKStringRef host, bool value)
{
+ auto* dataStore = WKContextGetWebsiteDataStore(platformContext());
+ WKWebsiteDataStoreSetStatisticsShouldPartitionCookiesForHost(dataStore, host, value);
}
void TestController::statisticsSubmitTelemetry()
{
+ auto* dataStore = WKContextGetWebsiteDataStore(platformContext());
+ WKWebsiteDataStoreStatisticsSubmitTelemetry(dataStore);
}
-void TestController::setStatisticsNotifyPagesWhenDataRecordsWereScanned(bool)
+void TestController::setStatisticsNotifyPagesWhenDataRecordsWereScanned(bool value)
{
+ auto* dataStore = WKContextGetWebsiteDataStore(platformContext());
+ WKWebsiteDataStoreSetStatisticsNotifyPagesWhenDataRecordsWereScanned(dataStore, value);
}
-void TestController::setStatisticsShouldClassifyResourcesBeforeDataRecordsRemoval(bool)
+void TestController::setStatisticsShouldClassifyResourcesBeforeDataRecordsRemoval(bool value)
{
+ auto* dataStore = WKContextGetWebsiteDataStore(platformContext());
+ WKWebsiteDataStoreSetStatisticsShouldClassifyResourcesBeforeDataRecordsRemoval(dataStore, value);
}
-void TestController::setStatisticsNotifyPagesWhenTelemetryWasCaptured(bool)
+void TestController::setStatisticsNotifyPagesWhenTelemetryWasCaptured(bool value)
{
+ auto* dataStore = WKContextGetWebsiteDataStore(platformContext());
+ WKWebsiteDataStoreSetStatisticsNotifyPagesWhenTelemetryWasCaptured(dataStore, value);
}
-void TestController::setStatisticsMinimumTimeBetweenDataRecordsRemoval(double)
+void TestController::setStatisticsMinimumTimeBetweenDataRecordsRemoval(double seconds)
{
+ auto* dataStore = WKContextGetWebsiteDataStore(platformContext());
+ WKWebsiteDataStoreSetStatisticsMinimumTimeBetweenDataRecordsRemoval(dataStore, seconds);
}
-void TestController::setStatisticsGrandfatheringTime(double)
+void TestController::setStatisticsGrandfatheringTime(double seconds)
{
+ auto* dataStore = WKContextGetWebsiteDataStore(platformContext());
+ WKWebsiteDataStoreSetStatisticsGrandfatheringTime(dataStore, seconds);
}
-void TestController::setStatisticsMaxStatisticsEntries(unsigned)
+void TestController::setStatisticsMaxStatisticsEntries(unsigned entries)
{
+ auto* dataStore = WKContextGetWebsiteDataStore(platformContext());
+ WKWebsiteDataStoreSetStatisticsMaxStatisticsEntries(dataStore, entries);
}
-
-void TestController::setStatisticsPruneEntriesDownTo(unsigned)
+
+void TestController::setStatisticsPruneEntriesDownTo(unsigned entries)
{
+ auto* dataStore = WKContextGetWebsiteDataStore(platformContext());
+ WKWebsiteDataStoreSetStatisticsPruneEntriesDownTo(dataStore, entries);
}
-
+
void TestController::statisticsClearInMemoryAndPersistentStore()
{
+ auto* dataStore = WKContextGetWebsiteDataStore(platformContext());
+ WKWebsiteDataStoreStatisticsClearInMemoryAndPersistentStore(dataStore);
+}
+
+void TestController::statisticsClearInMemoryAndPersistentStoreModifiedSinceHours(unsigned hours)
+{
+ auto* dataStore = WKContextGetWebsiteDataStore(platformContext());
+ WKWebsiteDataStoreStatisticsClearInMemoryAndPersistentStoreModifiedSinceHours(dataStore, hours);
}
-void TestController::statisticsClearInMemoryAndPersistentStoreModifiedSinceHours(unsigned)
+void TestController::statisticsClearThroughWebsiteDataRemovalCallback(void* userData)
{
+ static_cast<TestController*>(userData)->m_currentInvocation->didClearStatisticsThroughWebsiteDataRemoval();
}
void TestController::statisticsClearThroughWebsiteDataRemoval()
{
+ auto* dataStore = WKContextGetWebsiteDataStore(platformContext());
+ WKWebsiteDataStoreStatisticsClearThroughWebsiteDataRemoval(dataStore, this, statisticsClearThroughWebsiteDataRemovalCallback);
}
void TestController::statisticsResetToConsistentState()
{
+ auto* dataStore = WKContextGetWebsiteDataStore(platformContext());
+ WKWebsiteDataStoreStatisticsResetToConsistentState(dataStore);
}
#endif
static const char* libraryPathForTesting();
static const char* platformLibraryPathForTesting();
+ static void statisticsClearThroughWebsiteDataRemovalCallback(void*);
+
std::unique_ptr<TestInvocation> m_currentInvocation;
bool m_verbose { false };