Title: [263204] trunk
Revision
263204
Author
carlo...@webkit.org
Date
2020-06-18 01:17:48 -0700 (Thu, 18 Jun 2020)

Log Message

[GTK][WPE] Add API to configure and handle service worker registrations to WebKitWebsiteDataManager
https://bugs.webkit.org/show_bug.cgi?id=213290

Reviewed by Michael Catanzaro.

Source/WebKit:

The default path is always used even for apps setting a base data directory. We should handle
WebsiteDataType::ServiceWorkerRegistrations to configure the directory and allow to fetch and clear them.

* UIProcess/API/glib/WebKitWebsiteData.cpp:
(recordContainsSupportedDataTypes):
(toWebKitWebsiteDataTypes):
* UIProcess/API/glib/WebKitWebsiteDataManager.cpp:
(webkitWebsiteDataManagerGetProperty):
(webkitWebsiteDataManagerSetProperty):
(webkitWebsiteDataManagerConstructed):
(webkit_website_data_manager_class_init):
(webkitWebsiteDataManagerGetDataStore):
(webkit_website_data_manager_get_service_worker_registrations_directory):
(toWebsiteDataTypes):
* UIProcess/API/gtk/WebKitWebsiteData.h:
* UIProcess/API/gtk/WebKitWebsiteDataManager.h:
* UIProcess/API/gtk/docs/webkit2gtk-4.0-sections.txt:
* UIProcess/API/wpe/WebKitWebsiteData.h:
* UIProcess/API/wpe/WebKitWebsiteDataManager.h:
* UIProcess/API/wpe/docs/wpe-1.0-sections.txt:

Tools:

Handle new website data in MiniBrowser and add a unit test.

* MiniBrowser/gtk/main.c:
(gotWebsiteDataCallback):
* TestWebKitAPI/Tests/WebKitGLib/TestWebsiteData.cpp:
(serverCallback):
(testWebsiteDataConfiguration):
(testWebsiteDataEphemeral):
(testWebsiteDataITP):
(testWebsiteDataServiceWorkerRegistrations):
(beforeAll):
* TestWebKitAPI/glib/WebKitGLib/TestMain.h:
(Test::Test):

Modified Paths

Diff

Modified: trunk/Source/WebKit/ChangeLog (263203 => 263204)


--- trunk/Source/WebKit/ChangeLog	2020-06-18 08:15:21 UTC (rev 263203)
+++ trunk/Source/WebKit/ChangeLog	2020-06-18 08:17:48 UTC (rev 263204)
@@ -1,3 +1,31 @@
+2020-06-18  Carlos Garcia Campos  <cgar...@igalia.com>
+
+        [GTK][WPE] Add API to configure and handle service worker registrations to WebKitWebsiteDataManager
+        https://bugs.webkit.org/show_bug.cgi?id=213290
+
+        Reviewed by Michael Catanzaro.
+
+        The default path is always used even for apps setting a base data directory. We should handle
+        WebsiteDataType::ServiceWorkerRegistrations to configure the directory and allow to fetch and clear them.
+
+        * UIProcess/API/glib/WebKitWebsiteData.cpp:
+        (recordContainsSupportedDataTypes):
+        (toWebKitWebsiteDataTypes):
+        * UIProcess/API/glib/WebKitWebsiteDataManager.cpp:
+        (webkitWebsiteDataManagerGetProperty):
+        (webkitWebsiteDataManagerSetProperty):
+        (webkitWebsiteDataManagerConstructed):
+        (webkit_website_data_manager_class_init):
+        (webkitWebsiteDataManagerGetDataStore):
+        (webkit_website_data_manager_get_service_worker_registrations_directory):
+        (toWebsiteDataTypes):
+        * UIProcess/API/gtk/WebKitWebsiteData.h:
+        * UIProcess/API/gtk/WebKitWebsiteDataManager.h:
+        * UIProcess/API/gtk/docs/webkit2gtk-4.0-sections.txt:
+        * UIProcess/API/wpe/WebKitWebsiteData.h:
+        * UIProcess/API/wpe/WebKitWebsiteDataManager.h:
+        * UIProcess/API/wpe/docs/wpe-1.0-sections.txt:
+
 2020-06-18  Yuri Chornoivan  <yurc...@ukr.net>
 
         Unreviewed. Fix a typo introduced in r263085

Modified: trunk/Source/WebKit/UIProcess/API/glib/WebKitWebsiteData.cpp (263203 => 263204)


--- trunk/Source/WebKit/UIProcess/API/glib/WebKitWebsiteData.cpp	2020-06-18 08:15:21 UTC (rev 263203)
+++ trunk/Source/WebKit/UIProcess/API/glib/WebKitWebsiteData.cpp	2020-06-18 08:17:48 UTC (rev 263204)
@@ -79,7 +79,8 @@
 #endif
         WebsiteDataType::Cookies,
         WebsiteDataType::DeviceIdHashSalt,
-        WebsiteDataType::ResourceLoadStatistics
+        WebsiteDataType::ResourceLoadStatistics,
+        WebsiteDataType::ServiceWorkerRegistrations
     });
 }
 
@@ -112,6 +113,8 @@
         returnValue |= WEBKIT_WEBSITE_DATA_DEVICE_ID_HASH_SALT;
     if (types.contains(WebsiteDataType::ResourceLoadStatistics))
         returnValue |= WEBKIT_WEBSITE_DATA_ITP;
+    if (types.contains(WebsiteDataType::ServiceWorkerRegistrations))
+        returnValue |= WEBKIT_WEBSITE_DATA_SERVICE_WORKER_REGISTRATIONS;
     return static_cast<WebKitWebsiteDataTypes>(returnValue);
 }
 

Modified: trunk/Source/WebKit/UIProcess/API/glib/WebKitWebsiteDataManager.cpp (263203 => 263204)


--- trunk/Source/WebKit/UIProcess/API/glib/WebKitWebsiteDataManager.cpp	2020-06-18 08:15:21 UTC (rev 263203)
+++ trunk/Source/WebKit/UIProcess/API/glib/WebKitWebsiteDataManager.cpp	2020-06-18 08:17:48 UTC (rev 263204)
@@ -87,6 +87,7 @@
     PROP_WEBSQL_DIRECTORY,
     PROP_HSTS_CACHE_DIRECTORY,
     PROP_ITP_DIRECTORY,
+    PROP_SERVICE_WORKER_REGISTRATIONS_DIRECTORY,
     PROP_IS_EPHEMERAL
 };
 
@@ -106,6 +107,7 @@
     GUniquePtr<char> webSQLDirectory;
     GUniquePtr<char> hstsCacheDirectory;
     GUniquePtr<char> itpDirectory;
+    GUniquePtr<char> swRegistrationsDirectory;
 
     GRefPtr<WebKitCookieManager> cookieManager;
     Vector<WebProcessPool*> processPools;
@@ -147,6 +149,9 @@
     case PROP_ITP_DIRECTORY:
         g_value_set_string(value, webkit_website_data_manager_get_itp_directory(manager));
         break;
+    case PROP_SERVICE_WORKER_REGISTRATIONS_DIRECTORY:
+        g_value_set_string(value, webkit_website_data_manager_get_service_worker_registrations_directory(manager));
+        break;
     case PROP_IS_EPHEMERAL:
         g_value_set_boolean(value, webkit_website_data_manager_is_ephemeral(manager));
         break;
@@ -187,6 +192,9 @@
     case PROP_ITP_DIRECTORY:
         manager->priv->itpDirectory.reset(g_value_dup_string(value));
         break;
+    case PROP_SERVICE_WORKER_REGISTRATIONS_DIRECTORY:
+        manager->priv->swRegistrationsDirectory.reset(g_value_dup_string(value));
+        break;
     case PROP_IS_EPHEMERAL:
         if (g_value_get_boolean(value))
             manager->priv->websiteDataStore = WebKit::WebsiteDataStore::createNonPersistent();
@@ -210,6 +218,8 @@
             priv->webSQLDirectory.reset(g_build_filename(priv->baseDataDirectory.get(), "databases", nullptr));
         if (!priv->itpDirectory)
             priv->itpDirectory.reset(g_build_filename(priv->baseDataDirectory.get(), "itp", nullptr));
+        if (!priv->swRegistrationsDirectory)
+            priv->swRegistrationsDirectory.reset(g_build_filename(priv->baseDataDirectory.get(), "serviceworkers", nullptr));
     }
 
     if (priv->baseCacheDirectory) {
@@ -388,6 +398,23 @@
             static_cast<GParamFlags>(WEBKIT_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY)));
 
     /**
+     * WebKitWebsiteDataManager:service-worker-registrations-directory:
+     *
+     * The directory where service workers registrations will be stored.
+     *
+     * Since: 2.30
+     */
+    g_object_class_install_property(
+        gObjectClass,
+        PROP_SERVICE_WORKER_REGISTRATIONS_DIRECTORY,
+        g_param_spec_string(
+            "service-worker-registrations-directory",
+            _("Service Worker Registrations Directory"),
+            _("The directory where service workers registrations will be stored"),
+            nullptr,
+            static_cast<GParamFlags>(WEBKIT_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY)));
+
+    /**
      * WebKitWebsiteDataManager:is-ephemeral:
      *
      * Whether the #WebKitWebsiteDataManager is ephemeral. An ephemeral #WebKitWebsiteDataManager
@@ -427,6 +454,8 @@
             WebKit::WebsiteDataStore::defaultHSTSDirectory() : FileSystem::stringFromFileSystemRepresentation(priv->hstsCacheDirectory.get()));
         configuration->setResourceLoadStatisticsDirectory(!priv->itpDirectory ?
             WebKit::WebsiteDataStore::defaultResourceLoadStatisticsDirectory() : FileSystem::stringFromFileSystemRepresentation(priv->itpDirectory.get()));
+        configuration->setServiceWorkerRegistrationDirectory(!priv->swRegistrationsDirectory ?
+            WebKit::WebsiteDataStore::defaultServiceWorkerRegistrationDirectory() : FileSystem::stringFromFileSystemRepresentation(priv->swRegistrationsDirectory.get()));
         configuration->setMediaKeysStorageDirectory(WebKit::WebsiteDataStore::defaultMediaKeysStorageDirectory());
         priv->websiteDataStore = WebKit::WebsiteDataStore::create(WTFMove(configuration), PAL::SessionID::defaultSessionID());
     }
@@ -712,6 +741,29 @@
 }
 
 /**
+ * webkit_website_data_manager_get_service_worker_registrations_directory:
+ * @manager: a #WebKitWebsiteDataManager
+ *
+ * Get the #WebKitWebsiteDataManager:service-worker-registrations-directory property.
+ *
+ * Returns: (allow-none): the directory where service worker registrations are stored or %NULL if @manager is ephemeral.
+ *
+ * Since: 2.30
+ */
+const gchar* webkit_website_data_manager_get_service_worker_registrations_directory(WebKitWebsiteDataManager* manager)
+{
+    g_return_val_if_fail(WEBKIT_IS_WEBSITE_DATA_MANAGER(manager), nullptr);
+
+    WebKitWebsiteDataManagerPrivate* priv = manager->priv;
+    if (priv->websiteDataStore && !priv->websiteDataStore->isPersistent())
+        return nullptr;
+
+    if (!priv->swRegistrationsDirectory)
+        priv->swRegistrationsDirectory.reset(g_strdup(WebKit::WebsiteDataStore::defaultServiceWorkerRegistrationDirectory().utf8().data()));
+    return priv->swRegistrationsDirectory.get();
+}
+
+/**
  * webkit_website_data_manager_get_cookie_manager:
  * @manager: a #WebKitWebsiteDataManager
  *
@@ -796,6 +848,8 @@
         returnValue.add(WebsiteDataType::DeviceIdHashSalt);
     if (types & WEBKIT_WEBSITE_DATA_ITP)
         returnValue.add(WebsiteDataType::ResourceLoadStatistics);
+    if (types & WEBKIT_WEBSITE_DATA_SERVICE_WORKER_REGISTRATIONS)
+        returnValue.add(WebsiteDataType::ServiceWorkerRegistrations);
     return returnValue;
 }
 

Modified: trunk/Source/WebKit/UIProcess/API/gtk/WebKitWebsiteData.h (263203 => 263204)


--- trunk/Source/WebKit/UIProcess/API/gtk/WebKitWebsiteData.h	2020-06-18 08:15:21 UTC (rev 263203)
+++ trunk/Source/WebKit/UIProcess/API/gtk/WebKitWebsiteData.h	2020-06-18 08:17:48 UTC (rev 263204)
@@ -47,6 +47,7 @@
  * @WEBKIT_WEBSITE_DATA_DEVICE_ID_HASH_SALT: Hash salt used to generate the device ids used by webpages. Since 2.24
  * @WEBKIT_WEBSITE_DATA_HSTS_CACHE: HSTS cache. Since 2.26
  * @WEBKIT_WEBSITE_DATA_ITP: Intelligent Tracking Prevention data. Since 2.30.
+ * @WEBKIT_WEBSITE_DATA_SERVICE_WORKER_REGISTRATIONS: Service worker registrations. Since 2.30
  * @WEBKIT_WEBSITE_DATA_ALL: All types.
  *
  * Enum values with flags representing types of Website data.
@@ -54,19 +55,20 @@
  * Since: 2.16
  */
 typedef enum {
-    WEBKIT_WEBSITE_DATA_MEMORY_CACHE              = 1 << 0,
-    WEBKIT_WEBSITE_DATA_DISK_CACHE                = 1 << 1,
-    WEBKIT_WEBSITE_DATA_OFFLINE_APPLICATION_CACHE = 1 << 2,
-    WEBKIT_WEBSITE_DATA_SESSION_STORAGE           = 1 << 3,
-    WEBKIT_WEBSITE_DATA_LOCAL_STORAGE             = 1 << 4,
-    WEBKIT_WEBSITE_DATA_WEBSQL_DATABASES          = 1 << 5,
-    WEBKIT_WEBSITE_DATA_INDEXEDDB_DATABASES       = 1 << 6,
-    WEBKIT_WEBSITE_DATA_PLUGIN_DATA               = 1 << 7,
-    WEBKIT_WEBSITE_DATA_COOKIES                   = 1 << 8,
-    WEBKIT_WEBSITE_DATA_DEVICE_ID_HASH_SALT       = 1 << 9,
-    WEBKIT_WEBSITE_DATA_HSTS_CACHE                = 1 << 10,
-    WEBKIT_WEBSITE_DATA_ITP                       = 1 << 11,
-    WEBKIT_WEBSITE_DATA_ALL                       = (1 << 12) - 1
+    WEBKIT_WEBSITE_DATA_MEMORY_CACHE                 = 1 << 0,
+    WEBKIT_WEBSITE_DATA_DISK_CACHE                   = 1 << 1,
+    WEBKIT_WEBSITE_DATA_OFFLINE_APPLICATION_CACHE    = 1 << 2,
+    WEBKIT_WEBSITE_DATA_SESSION_STORAGE              = 1 << 3,
+    WEBKIT_WEBSITE_DATA_LOCAL_STORAGE                = 1 << 4,
+    WEBKIT_WEBSITE_DATA_WEBSQL_DATABASES             = 1 << 5,
+    WEBKIT_WEBSITE_DATA_INDEXEDDB_DATABASES          = 1 << 6,
+    WEBKIT_WEBSITE_DATA_PLUGIN_DATA                  = 1 << 7,
+    WEBKIT_WEBSITE_DATA_COOKIES                      = 1 << 8,
+    WEBKIT_WEBSITE_DATA_DEVICE_ID_HASH_SALT          = 1 << 9,
+    WEBKIT_WEBSITE_DATA_HSTS_CACHE                   = 1 << 10,
+    WEBKIT_WEBSITE_DATA_ITP                          = 1 << 11,
+    WEBKIT_WEBSITE_DATA_SERVICE_WORKER_REGISTRATIONS = 1 << 12,
+    WEBKIT_WEBSITE_DATA_ALL                          = (1 << 13) - 1
 } WebKitWebsiteDataTypes;
 
 WEBKIT_API GType

Modified: trunk/Source/WebKit/UIProcess/API/gtk/WebKitWebsiteDataManager.h (263203 => 263204)


--- trunk/Source/WebKit/UIProcess/API/gtk/WebKitWebsiteDataManager.h	2020-06-18 08:15:21 UTC (rev 263203)
+++ trunk/Source/WebKit/UIProcess/API/gtk/WebKitWebsiteDataManager.h	2020-06-18 08:17:48 UTC (rev 263204)
@@ -96,6 +96,9 @@
 WEBKIT_API const gchar *
 webkit_website_data_manager_get_itp_directory                         (WebKitWebsiteDataManager *manager);
 
+WEBKIT_API const gchar *
+webkit_website_data_manager_get_service_worker_registrations_directory(WebKitWebsiteDataManager *manager);
+
 WEBKIT_API WebKitCookieManager *
 webkit_website_data_manager_get_cookie_manager                        (WebKitWebsiteDataManager *manager);
 

Modified: trunk/Source/WebKit/UIProcess/API/gtk/docs/webkit2gtk-4.0-sections.txt (263203 => 263204)


--- trunk/Source/WebKit/UIProcess/API/gtk/docs/webkit2gtk-4.0-sections.txt	2020-06-18 08:15:21 UTC (rev 263203)
+++ trunk/Source/WebKit/UIProcess/API/gtk/docs/webkit2gtk-4.0-sections.txt	2020-06-18 08:17:48 UTC (rev 263204)
@@ -1462,6 +1462,7 @@
 webkit_website_data_manager_get_websql_directory
 webkit_website_data_manager_get_hsts_cache_directory
 webkit_website_data_manager_get_itp_directory
+webkit_website_data_manager_get_service_worker_registrations_directory
 webkit_website_data_manager_get_cookie_manager
 webkit_website_data_manager_set_itp_enabled
 webkit_website_data_manager_get_itp_enabled

Modified: trunk/Source/WebKit/UIProcess/API/wpe/WebKitWebsiteData.h (263203 => 263204)


--- trunk/Source/WebKit/UIProcess/API/wpe/WebKitWebsiteData.h	2020-06-18 08:15:21 UTC (rev 263203)
+++ trunk/Source/WebKit/UIProcess/API/wpe/WebKitWebsiteData.h	2020-06-18 08:17:48 UTC (rev 263204)
@@ -47,6 +47,7 @@
  * @WEBKIT_WEBSITE_DATA_DEVICE_ID_HASH_SALT: Hash salt used to generate the device ids used by webpages. Since 2.24
  * @WEBKIT_WEBSITE_DATA_HSTS_CACHE: HSTS cache. Since 2.26
  * @WEBKIT_WEBSITE_DATA_ITP: Intelligent Tracking Prevention data. Since 2.30.
+ * @WEBKIT_WEBSITE_DATA_SERVICE_WORKER_REGISTRATIONS: Service worker registrations. Since 2.30
  * @WEBKIT_WEBSITE_DATA_ALL: All types.
  *
  * Enum values with flags representing types of Website data.
@@ -54,19 +55,20 @@
  * Since: 2.16
  */
 typedef enum {
-    WEBKIT_WEBSITE_DATA_MEMORY_CACHE              = 1 << 0,
-    WEBKIT_WEBSITE_DATA_DISK_CACHE                = 1 << 1,
-    WEBKIT_WEBSITE_DATA_OFFLINE_APPLICATION_CACHE = 1 << 2,
-    WEBKIT_WEBSITE_DATA_SESSION_STORAGE           = 1 << 3,
-    WEBKIT_WEBSITE_DATA_LOCAL_STORAGE             = 1 << 4,
-    WEBKIT_WEBSITE_DATA_WEBSQL_DATABASES          = 1 << 5,
-    WEBKIT_WEBSITE_DATA_INDEXEDDB_DATABASES       = 1 << 6,
-    WEBKIT_WEBSITE_DATA_PLUGIN_DATA               = 1 << 7,
-    WEBKIT_WEBSITE_DATA_COOKIES                   = 1 << 8,
-    WEBKIT_WEBSITE_DATA_DEVICE_ID_HASH_SALT       = 1 << 9,
-    WEBKIT_WEBSITE_DATA_HSTS_CACHE                = 1 << 10,
-    WEBKIT_WEBSITE_DATA_ITP                       = 1 << 11,
-    WEBKIT_WEBSITE_DATA_ALL                       = (1 << 12) - 1
+    WEBKIT_WEBSITE_DATA_MEMORY_CACHE                 = 1 << 0,
+    WEBKIT_WEBSITE_DATA_DISK_CACHE                   = 1 << 1,
+    WEBKIT_WEBSITE_DATA_OFFLINE_APPLICATION_CACHE    = 1 << 2,
+    WEBKIT_WEBSITE_DATA_SESSION_STORAGE              = 1 << 3,
+    WEBKIT_WEBSITE_DATA_LOCAL_STORAGE                = 1 << 4,
+    WEBKIT_WEBSITE_DATA_WEBSQL_DATABASES             = 1 << 5,
+    WEBKIT_WEBSITE_DATA_INDEXEDDB_DATABASES          = 1 << 6,
+    WEBKIT_WEBSITE_DATA_PLUGIN_DATA                  = 1 << 7,
+    WEBKIT_WEBSITE_DATA_COOKIES                      = 1 << 8,
+    WEBKIT_WEBSITE_DATA_DEVICE_ID_HASH_SALT          = 1 << 9,
+    WEBKIT_WEBSITE_DATA_HSTS_CACHE                   = 1 << 10,
+    WEBKIT_WEBSITE_DATA_ITP                          = 1 << 11,
+    WEBKIT_WEBSITE_DATA_SERVICE_WORKER_REGISTRATIONS = 1 << 12,
+    WEBKIT_WEBSITE_DATA_ALL                          = (1 << 13) - 1
 } WebKitWebsiteDataTypes;
 
 WEBKIT_API GType

Modified: trunk/Source/WebKit/UIProcess/API/wpe/WebKitWebsiteDataManager.h (263203 => 263204)


--- trunk/Source/WebKit/UIProcess/API/wpe/WebKitWebsiteDataManager.h	2020-06-18 08:15:21 UTC (rev 263203)
+++ trunk/Source/WebKit/UIProcess/API/wpe/WebKitWebsiteDataManager.h	2020-06-18 08:17:48 UTC (rev 263204)
@@ -96,6 +96,9 @@
 WEBKIT_API const gchar *
 webkit_website_data_manager_get_itp_directory                         (WebKitWebsiteDataManager *manager);
 
+WEBKIT_API const gchar *
+webkit_website_data_manager_get_service_worker_registrations_directory(WebKitWebsiteDataManager *manager);
+
 WEBKIT_API WebKitCookieManager *
 webkit_website_data_manager_get_cookie_manager                        (WebKitWebsiteDataManager *manager);
 

Modified: trunk/Source/WebKit/UIProcess/API/wpe/docs/wpe-1.0-sections.txt (263203 => 263204)


--- trunk/Source/WebKit/UIProcess/API/wpe/docs/wpe-1.0-sections.txt	2020-06-18 08:15:21 UTC (rev 263203)
+++ trunk/Source/WebKit/UIProcess/API/wpe/docs/wpe-1.0-sections.txt	2020-06-18 08:17:48 UTC (rev 263204)
@@ -1396,6 +1396,7 @@
 webkit_website_data_manager_get_websql_directory
 webkit_website_data_manager_get_hsts_cache_directory
 webkit_website_data_manager_get_itp_directory
+webkit_website_data_manager_get_service_worker_registrations_directory
 webkit_website_data_manager_get_cookie_manager
 webkit_website_data_manager_set_itp_enabled
 webkit_website_data_manager_get_itp_enabled

Modified: trunk/Tools/ChangeLog (263203 => 263204)


--- trunk/Tools/ChangeLog	2020-06-18 08:15:21 UTC (rev 263203)
+++ trunk/Tools/ChangeLog	2020-06-18 08:17:48 UTC (rev 263204)
@@ -1,3 +1,24 @@
+2020-06-18  Carlos Garcia Campos  <cgar...@igalia.com>
+
+        [GTK][WPE] Add API to configure and handle service worker registrations to WebKitWebsiteDataManager
+        https://bugs.webkit.org/show_bug.cgi?id=213290
+
+        Reviewed by Michael Catanzaro.
+
+        Handle new website data in MiniBrowser and add a unit test.
+
+        * MiniBrowser/gtk/main.c:
+        (gotWebsiteDataCallback):
+        * TestWebKitAPI/Tests/WebKitGLib/TestWebsiteData.cpp:
+        (serverCallback):
+        (testWebsiteDataConfiguration):
+        (testWebsiteDataEphemeral):
+        (testWebsiteDataITP):
+        (testWebsiteDataServiceWorkerRegistrations):
+        (beforeAll):
+        * TestWebKitAPI/glib/WebKitGLib/TestMain.h:
+        (Test::Test):
+
 2020-06-17  Fujii Hironori  <hironori.fu...@sony.com>
 
         RebaselineServer: "Rebaseline queue" button is placed behind the footer

Modified: trunk/Tools/MiniBrowser/gtk/main.c (263203 => 263204)


--- trunk/Tools/MiniBrowser/gtk/main.c	2020-06-18 08:15:21 UTC (rev 263203)
+++ trunk/Tools/MiniBrowser/gtk/main.c	2020-06-18 08:17:48 UTC (rev 263204)
@@ -449,6 +449,8 @@
     aboutDataFillTable(result, dataRequest, dataList, "Offline Web Applications Cache", WEBKIT_WEBSITE_DATA_OFFLINE_APPLICATION_CACHE, webkit_website_data_manager_get_offline_application_cache_directory(manager), pageID);
     aboutDataFillTable(result, dataRequest, dataList, "HSTS Cache", WEBKIT_WEBSITE_DATA_HSTS_CACHE, webkit_website_data_manager_get_hsts_cache_directory(manager), pageID);
     aboutDataFillTable(result, dataRequest, dataList, "ITP data", WEBKIT_WEBSITE_DATA_ITP, webkit_website_data_manager_get_itp_directory(manager), pageID);
+    aboutDataFillTable(result, dataRequest, dataList, "Service Worker Registratations", WEBKIT_WEBSITE_DATA_SERVICE_WORKER_REGISTRATIONS,
+        webkit_website_data_manager_get_service_worker_registrations_directory(manager), pageID);
 
     result = g_string_append(result, "</body></html>");
     gsize streamLength = result->len;

Modified: trunk/Tools/TestWebKitAPI/Tests/WebKitGLib/TestWebsiteData.cpp (263203 => 263204)


--- trunk/Tools/TestWebKitAPI/Tests/WebKitGLib/TestWebsiteData.cpp	2020-06-18 08:15:21 UTC (rev 263203)
+++ trunk/Tools/TestWebKitAPI/Tests/WebKitGLib/TestWebsiteData.cpp	2020-06-18 08:17:48 UTC (rev 263204)
@@ -74,6 +74,20 @@
         soup_message_body_append(message->response_body, SOUP_MEMORY_STATIC, enumerateDevicesHTML, strlen(enumerateDevicesHTML));
         soup_message_body_complete(message->response_body);
         soup_message_set_status(message, SOUP_STATUS_OK);
+    } else if (g_str_equal(path, "/service/register.html")) {
+        static const char* swRegisterHTML = "<html><body><script src=""
+        soup_message_body_append(message->response_body, SOUP_MEMORY_STATIC, swRegisterHTML, strlen(swRegisterHTML));
+        soup_message_body_complete(message->response_body);
+        soup_message_set_status(message, SOUP_STATUS_OK);
+    } else if (g_str_equal(path, "/service/register.js")) {
+        static const char* swRegisterJS =
+            "async function test() { await navigator.serviceWorker.register(\"/service/empty-worker.js\"); } test();";
+        soup_message_body_append(message->response_body, SOUP_MEMORY_STATIC, swRegisterJS, strlen(swRegisterJS));
+        soup_message_body_complete(message->response_body);
+        soup_message_set_status(message, SOUP_STATUS_OK);
+    } else if (g_str_equal(path, "/service/empty-worker.js")) {
+        soup_message_body_complete(message->response_body);
+        soup_message_set_status(message, SOUP_STATUS_OK);
     } else
         soup_message_set_status(message, SOUP_STATUS_NOT_FOUND);
 }
@@ -176,6 +190,10 @@
     GUniquePtr<char> itpDirectory(g_build_filename(Test::dataDirectory(), "itp", nullptr));
     g_assert_cmpstr(itpDirectory.get(), ==, webkit_website_data_manager_get_itp_directory(test->m_manager));
 
+    GUniquePtr<char> swRegistrationsDirectory(g_build_filename(Test::dataDirectory(), "serviceworkers", nullptr));
+    g_assert_cmpstr(swRegistrationsDirectory.get(), ==, webkit_website_data_manager_get_service_worker_registrations_directory(test->m_manager));
+    g_assert_true(g_file_test(swRegistrationsDirectory.get(), G_FILE_TEST_IS_DIR));
+
     // Clear all persistent caches, since the data dir is common to all test cases. Note: not cleaning the HSTS cache here as its data
     // is needed for the HSTS tests, where data cleaning will be tested.
     static const WebKitWebsiteDataTypes persistentCaches = static_cast<WebKitWebsiteDataTypes>(WEBKIT_WEBSITE_DATA_DISK_CACHE | WEBKIT_WEBSITE_DATA_LOCAL_STORAGE
@@ -192,6 +210,8 @@
     g_assert_cmpstr(webkit_website_data_manager_get_disk_cache_directory(test->m_manager), !=, webkit_website_data_manager_get_disk_cache_directory(defaultManager));
     g_assert_cmpstr(webkit_website_data_manager_get_offline_application_cache_directory(test->m_manager), !=, webkit_website_data_manager_get_offline_application_cache_directory(defaultManager));
     g_assert_cmpstr(webkit_website_data_manager_get_hsts_cache_directory(test->m_manager), !=, webkit_website_data_manager_get_hsts_cache_directory(defaultManager));
+    g_assert_cmpstr(webkit_website_data_manager_get_itp_directory(test->m_manager), !=, webkit_website_data_manager_get_itp_directory(defaultManager));
+    g_assert_cmpstr(webkit_website_data_manager_get_service_worker_registrations_directory(test->m_manager), !=, webkit_website_data_manager_get_service_worker_registrations_directory(defaultManager));
 
     // Using Test::dataDirectory() we get the default configuration but for a differrent prefix.
     GRefPtr<WebKitWebsiteDataManager> baseDataManager = adoptGRef(webkit_website_data_manager_new("base-data-directory", Test::dataDirectory(), "base-cache-directory", Test::dataDirectory(), nullptr));
@@ -208,6 +228,8 @@
 
     g_assert_cmpstr(webkit_website_data_manager_get_itp_directory(baseDataManager.get()), ==, itpDirectory.get());
 
+    g_assert_cmpstr(webkit_website_data_manager_get_service_worker_registrations_directory(baseDataManager.get()), ==, swRegistrationsDirectory.get());
+
     g_assert_cmpstr(webkit_website_data_manager_get_disk_cache_directory(baseDataManager.get()), ==, Test::dataDirectory());
 
     // Any specific configuration provided takes precedence over base dirs.
@@ -220,6 +242,7 @@
     // The result should be the same as previous manager.
     g_assert_cmpstr(webkit_website_data_manager_get_local_storage_directory(baseDataManager.get()), ==, localStorageDirectory.get());
     g_assert_cmpstr(webkit_website_data_manager_get_itp_directory(baseDataManager.get()), ==, itpDirectory.get());
+    g_assert_cmpstr(webkit_website_data_manager_get_service_worker_registrations_directory(baseDataManager.get()), ==, swRegistrationsDirectory.get());
     g_assert_cmpstr(webkit_website_data_manager_get_disk_cache_directory(baseDataManager.get()), ==, Test::dataDirectory());
 }
 
@@ -243,6 +266,7 @@
     g_assert_null(webkit_website_data_manager_get_indexeddb_directory(manager.get()));
     g_assert_null(webkit_website_data_manager_get_hsts_cache_directory(manager.get()));
     g_assert_null(webkit_website_data_manager_get_itp_directory(manager.get()));
+    g_assert_null(webkit_website_data_manager_get_service_worker_registrations_directory(manager.get()));
 
     // Configuration is ignored when is-ephemeral is used.
     manager = adoptGRef(WEBKIT_WEBSITE_DATA_MANAGER(g_object_new(WEBKIT_TYPE_WEBSITE_DATA_MANAGER, "base-data-directory", Test::dataDirectory(), "is-ephemeral", TRUE, nullptr)));
@@ -673,6 +697,36 @@
     g_rmdir(itpDirectory);
 }
 
+static void testWebsiteDataServiceWorkerRegistrations(WebsiteDataTest* test, gconstpointer)
+{
+    GList* dataList = test->fetch(WEBKIT_WEBSITE_DATA_SERVICE_WORKER_REGISTRATIONS);
+    g_assert_null(dataList);
+
+    test->loadURI(kServer->getURIForPath("/service/register.html").data());
+    test->waitUntilLoadFinished();
+
+    dataList = test->fetch(WEBKIT_WEBSITE_DATA_SERVICE_WORKER_REGISTRATIONS);
+    g_assert_cmpuint(g_list_length(dataList), ==, 1);
+    g_assert_nonnull(dataList);
+    auto* data = ""
+    g_assert_nonnull(data);
+    WebKitSecurityOrigin* origin = webkit_security_origin_new_for_uri(kServer->getURIForPath("/service/register.html").data());
+    g_assert_cmpstr(webkit_website_data_get_name(data), ==, webkit_security_origin_get_host(origin));
+    webkit_security_origin_unref(origin);
+
+    // Remove the registration.
+    GList removeList = { data, nullptr, nullptr };
+    test->remove(WEBKIT_WEBSITE_DATA_SERVICE_WORKER_REGISTRATIONS, &removeList);
+    dataList = test->fetch(WEBKIT_WEBSITE_DATA_SERVICE_WORKER_REGISTRATIONS);
+    g_assert_null(dataList);
+
+    // Clear all.
+    static const WebKitWebsiteDataTypes cacheAndRegistrations = static_cast<WebKitWebsiteDataTypes>(WEBKIT_WEBSITE_DATA_SERVICE_WORKER_REGISTRATIONS | WEBKIT_WEBSITE_DATA_MEMORY_CACHE | WEBKIT_WEBSITE_DATA_DISK_CACHE);
+    test->clear(cacheAndRegistrations, 0);
+    dataList = test->fetch(cacheAndRegistrations);
+    g_assert_null(dataList);
+}
+
 void beforeAll()
 {
     kServer = new WebKitTestServer();
@@ -694,6 +748,7 @@
 #endif
     WebsiteDataTest::add("WebKitWebsiteData", "deviceidhashsalt", testWebsiteDataDeviceIdHashSalt);
     WebsiteDataTest::add("WebKitWebsiteData", "itp", testWebsiteDataITP);
+    WebsiteDataTest::add("WebKitWebsiteData", "service-worker-registrations", testWebsiteDataServiceWorkerRegistrations);
 }
 
 void afterAll()

Modified: trunk/Tools/TestWebKitAPI/glib/WebKitGLib/TestMain.h (263203 => 263204)


--- trunk/Tools/TestWebKitAPI/glib/WebKitGLib/TestMain.h	2020-06-18 08:15:21 UTC (rev 263203)
+++ trunk/Tools/TestWebKitAPI/glib/WebKitGLib/TestMain.h	2020-06-18 08:17:48 UTC (rev 263204)
@@ -125,11 +125,12 @@
         GUniquePtr<char> webSQLDirectory(g_build_filename(dataDirectory(), "websql", nullptr));
         GUniquePtr<char> hstsDirectory(g_build_filename(dataDirectory(), "hsts", nullptr));
         GUniquePtr<char> itpDirectory(g_build_filename(dataDirectory(), "itp", nullptr));
+        GUniquePtr<char> swRegistrationsDirectory(g_build_filename(dataDirectory(), "serviceworkers", nullptr));
         GRefPtr<WebKitWebsiteDataManager> websiteDataManager = adoptGRef(webkit_website_data_manager_new(
             "local-storage-directory", localStorageDirectory.get(), "indexeddb-directory", indexedDBDirectory.get(),
             "disk-cache-directory", diskCacheDirectory.get(), "offline-application-cache-directory", applicationCacheDirectory.get(),
             "websql-directory", webSQLDirectory.get(), "hsts-cache-directory", hstsDirectory.get(),
-            "itp-directory", itpDirectory.get(), nullptr));
+            "itp-directory", itpDirectory.get(), "service-worker-registrations-directory", swRegistrationsDirectory.get(), nullptr));
 
         m_webContext = adoptGRef(WEBKIT_WEB_CONTEXT(g_object_new(WEBKIT_TYPE_WEB_CONTEXT,
             "website-data-manager", websiteDataManager.get(),
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to