Diff
Modified: trunk/Source/WebKit/ChangeLog (269286 => 269287)
--- trunk/Source/WebKit/ChangeLog 2020-11-03 06:56:54 UTC (rev 269286)
+++ trunk/Source/WebKit/ChangeLog 2020-11-03 08:40:48 UTC (rev 269287)
@@ -1,3 +1,24 @@
+2020-11-03 Adrian Perez de Castro <[email protected]>
+
+ [GTK][WPE] Cannot remove individual scripts/stylesheets using WebKitUserContentManager
+ https://bugs.webkit.org/show_bug.cgi?id=218403
+
+ Reviewed by Carlos Garcia Campos.
+
+ Add the missing WebKitUserContentManager functions which allow
+ removing a single script and style sheet from the manager. Given
+ that it is possible to remove a single content filter and message
+ handlers already, this make the API orthogonal for scripts and style
+ sheets as well.
+
+ * UIProcess/API/glib/WebKitUserContentManager.cpp:
+ (webkit_user_content_manager_remove_style_sheet): Added.
+ (webkit_user_content_manager_remove_script): Added.
+ * UIProcess/API/gtk/WebKitUserContentManager.h: Add declarations for the new functions.
+ * UIProcess/API/gtk/docs/webkit2gtk-4.0-sections.txt: Ditto.
+ * UIProcess/API/wpe/WebKitUserContentManager.h: Ditto.
+ * UIProcess/API/wpe/docs/wpe-1.0-sections.txt: Ditto.
+
2020-11-02 Ryosuke Niwa <[email protected]>
Remove some useless comments from .messages.in files
Modified: trunk/Source/WebKit/UIProcess/API/glib/WebKitUserContentManager.cpp (269286 => 269287)
--- trunk/Source/WebKit/UIProcess/API/glib/WebKitUserContentManager.cpp 2020-11-03 06:56:54 UTC (rev 269286)
+++ trunk/Source/WebKit/UIProcess/API/glib/WebKitUserContentManager.cpp 2020-11-03 08:40:48 UTC (rev 269287)
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2014 Igalia S.L.
+ * Copyright (C) 2014, 2020 Igalia S.L.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
@@ -139,6 +139,24 @@
}
/**
+ * webkit_user_content_manager_remove_style_sheet:
+ * @manager: A #WebKitUserContentManager
+ * @stylesheet: A #WebKitUserStyleSheet
+ *
+ * Removes a #WebKitUserStyleSheet from the given #WebKitUserContentManager.
+ *
+ * See also webkit_user_content_manager_remove_all_style_sheets().
+ *
+ * Since: 2.32
+ */
+void webkit_user_content_manager_remove_style_sheet(WebKitUserContentManager* manager, WebKitUserStyleSheet* styleSheet)
+{
+ g_return_if_fail(WEBKIT_IS_USER_CONTENT_MANAGER(manager));
+ g_return_if_fail(styleSheet);
+ manager->priv->userContentController->removeUserStyleSheet(webkitUserStyleSheetGetUserStyleSheet(styleSheet));
+}
+
+/**
* webkit_user_content_manager_remove_all_style_sheets:
* @manager: A #WebKitUserContentManager
*
@@ -171,11 +189,31 @@
}
/**
+ * webkit_user_content_manager_remove_script:
+ * @manager: A #WebKitUserContentManager
+ * @script: A #WebKitUserScript
+ *
+ * Removes a #WebKitUserScript from the given #WebKitUserContentManager.
+ *
+ * See also webkit_user_content_manager_remove_all_scripts().
+ *
+ * Since: 2.32
+ */
+void webkit_user_content_manager_remove_script(WebKitUserContentManager* manager, WebKitUserScript* script)
+{
+ g_return_if_fail(WEBKIT_IS_USER_CONTENT_MANAGER(manager));
+ g_return_if_fail(script);
+ manager->priv->userContentController->removeUserScript(webkitUserScriptGetUserScript(script));
+}
+
+/**
* webkit_user_content_manager_remove_all_scripts:
* @manager: A #WebKitUserContentManager
*
* Removes all user scripts from the given #WebKitUserContentManager
*
+ * See also webkit_user_content_manager_remove_script().
+ *
* Since: 2.6
*/
void webkit_user_content_manager_remove_all_scripts(WebKitUserContentManager* manager)
Modified: trunk/Source/WebKit/UIProcess/API/gtk/WebKitUserContentManager.h (269286 => 269287)
--- trunk/Source/WebKit/UIProcess/API/gtk/WebKitUserContentManager.h 2020-11-03 06:56:54 UTC (rev 269286)
+++ trunk/Source/WebKit/UIProcess/API/gtk/WebKitUserContentManager.h 2020-11-03 08:40:48 UTC (rev 269287)
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2014 Igalia S.L.
+ * Copyright (C) 2014, 2020 Igalia S.L.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
@@ -67,7 +67,12 @@
WEBKIT_API void
webkit_user_content_manager_add_style_sheet (WebKitUserContentManager *manager,
WebKitUserStyleSheet *stylesheet);
+
WEBKIT_API void
+webkit_user_content_manager_remove_style_sheet (WebKitUserContentManager *manager,
+ WebKitUserStyleSheet *stylesheet);
+
+WEBKIT_API void
webkit_user_content_manager_remove_all_style_sheets (WebKitUserContentManager *manager);
WEBKIT_API gboolean
@@ -91,6 +96,10 @@
WebKitUserScript *script);
WEBKIT_API void
+webkit_user_content_manager_remove_script (WebKitUserContentManager *manager,
+ WebKitUserScript *script);
+
+WEBKIT_API void
webkit_user_content_manager_remove_all_scripts (WebKitUserContentManager *manager);
WEBKIT_API void
Modified: trunk/Source/WebKit/UIProcess/API/gtk/docs/webkit2gtk-4.0-sections.txt (269286 => 269287)
--- trunk/Source/WebKit/UIProcess/API/gtk/docs/webkit2gtk-4.0-sections.txt 2020-11-03 06:56:54 UTC (rev 269286)
+++ trunk/Source/WebKit/UIProcess/API/gtk/docs/webkit2gtk-4.0-sections.txt 2020-11-03 08:40:48 UTC (rev 269287)
@@ -128,8 +128,10 @@
WebKitUserContentManager
webkit_user_content_manager_new
webkit_user_content_manager_add_style_sheet
+webkit_user_content_manager_remove_style_sheet
webkit_user_content_manager_remove_all_style_sheets
webkit_user_content_manager_add_script
+webkit_user_content_manager_remove_script
webkit_user_content_manager_remove_all_scripts
webkit_user_content_manager_register_script_message_handler
webkit_user_content_manager_unregister_script_message_handler
Modified: trunk/Source/WebKit/UIProcess/API/wpe/WebKitUserContentManager.h (269286 => 269287)
--- trunk/Source/WebKit/UIProcess/API/wpe/WebKitUserContentManager.h 2020-11-03 06:56:54 UTC (rev 269286)
+++ trunk/Source/WebKit/UIProcess/API/wpe/WebKitUserContentManager.h 2020-11-03 08:40:48 UTC (rev 269287)
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2014 Igalia S.L.
+ * Copyright (C) 2014, 2020 Igalia S.L.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
@@ -67,7 +67,12 @@
WEBKIT_API void
webkit_user_content_manager_add_style_sheet (WebKitUserContentManager *manager,
WebKitUserStyleSheet *stylesheet);
+
WEBKIT_API void
+webkit_user_content_manager_remove_style_sheet (WebKitUserContentManager *manager,
+ WebKitUserStyleSheet *stylesheet);
+
+WEBKIT_API void
webkit_user_content_manager_remove_all_style_sheets (WebKitUserContentManager *manager);
WEBKIT_API gboolean
@@ -91,6 +96,10 @@
WebKitUserScript *script);
WEBKIT_API void
+webkit_user_content_manager_remove_script (WebKitUserContentManager *manager,
+ WebKitUserScript *script);
+
+WEBKIT_API void
webkit_user_content_manager_remove_all_scripts (WebKitUserContentManager *manager);
WEBKIT_API void
Modified: trunk/Source/WebKit/UIProcess/API/wpe/docs/wpe-1.0-sections.txt (269286 => 269287)
--- trunk/Source/WebKit/UIProcess/API/wpe/docs/wpe-1.0-sections.txt 2020-11-03 06:56:54 UTC (rev 269286)
+++ trunk/Source/WebKit/UIProcess/API/wpe/docs/wpe-1.0-sections.txt 2020-11-03 08:40:48 UTC (rev 269287)
@@ -103,8 +103,10 @@
WebKitUserContentManager
webkit_user_content_manager_new
webkit_user_content_manager_add_style_sheet
+webkit_user_content_manager_remove_style_sheet
webkit_user_content_manager_remove_all_style_sheets
webkit_user_content_manager_add_script
+webkit_user_content_manager_remove_script
webkit_user_content_manager_remove_all_scripts
webkit_user_content_manager_register_script_message_handler
webkit_user_content_manager_unregister_script_message_handler
Modified: trunk/Tools/ChangeLog (269286 => 269287)
--- trunk/Tools/ChangeLog 2020-11-03 06:56:54 UTC (rev 269286)
+++ trunk/Tools/ChangeLog 2020-11-03 08:40:48 UTC (rev 269287)
@@ -1,3 +1,22 @@
+2020-11-03 Adrian Perez de Castro <[email protected]>
+
+ [GTK][WPE] Cannot remove individual scripts/stylesheets using WebKitUserContentManager
+ https://bugs.webkit.org/show_bug.cgi?id=218403
+
+ Reviewed by Carlos Garcia Campos.
+
+ Add the missing WebKitUserContentManager functions which allow
+ removing a single script and style sheet from the manager. Given
+ that it is possible to remove a single content filter and message
+ handlers already, this make the API orthogonal for scripts and style
+ sheets as well.
+
+ * TestWebKitAPI/Tests/WebKitGLib/TestWebKitUserContentManager.cpp:
+ (testUserContentManagerInjectedStyleSheet): Add test for
+ webkit_user_content_manager_remove_style_sheet().
+ (testUserContentManagerInjectedScript): Add test for
+ webkit_user_content_manager_remove_script().
+
2020-11-02 Sam Weinig <[email protected]>
Sort/cleanup preferences in resetWebPreferencesToConsistentValues
Modified: trunk/Tools/TestWebKitAPI/Tests/WebKitGLib/TestWebKitUserContentManager.cpp (269286 => 269287)
--- trunk/Tools/TestWebKitAPI/Tests/WebKitGLib/TestWebKitUserContentManager.cpp 2020-11-03 06:56:54 UTC (rev 269286)
+++ trunk/Tools/TestWebKitAPI/Tests/WebKitGLib/TestWebKitUserContentManager.cpp 2020-11-03 08:40:48 UTC (rev 269287)
@@ -186,6 +186,16 @@
g_assert_false(isStyleSheetInjectedForURLAtPath(test, inTheAllowListAndBlockList));
g_assert_false(isStyleSheetInjectedForURLAtPath(test, notInAllowList));
+ removeOldInjectedContentAndResetLists(test->m_userContentManager.get(), allowList, blockList);
+
+ g_assert_false(isStyleSheetInjectedForURLAtPath(test, randomPath));
+ styleSheet = webkit_user_style_sheet_new(kInjectedStyleSheet, WEBKIT_USER_CONTENT_INJECT_ALL_FRAMES, WEBKIT_USER_STYLE_LEVEL_USER, nullptr, nullptr);
+ webkit_user_content_manager_add_style_sheet(test->m_userContentManager.get(), styleSheet);
+ g_assert_true(isStyleSheetInjectedForURLAtPath(test, randomPath));
+ webkit_user_content_manager_remove_style_sheet(test->m_userContentManager.get(), styleSheet);
+ g_assert_false(isStyleSheetInjectedForURLAtPath(test, randomPath));
+ webkit_user_style_sheet_unref(styleSheet);
+
// It's important to clean up the environment before other tests.
removeOldInjectedContentAndResetLists(test->m_userContentManager.get(), allowList, blockList);
}
@@ -237,6 +247,16 @@
g_assert_false(isScriptInjectedForURLAtPath(test, inTheAllowListAndBlockList));
g_assert_false(isScriptInjectedForURLAtPath(test, notInAllowList));
+ removeOldInjectedContentAndResetLists(test->m_userContentManager.get(), allowList, blockList);
+
+ g_assert_false(isScriptInjectedForURLAtPath(test, randomPath));
+ script = webkit_user_script_new(kInjectedScript, WEBKIT_USER_CONTENT_INJECT_ALL_FRAMES, WEBKIT_USER_SCRIPT_INJECT_AT_DOCUMENT_END, nullptr, nullptr);
+ webkit_user_content_manager_add_script(test->m_userContentManager.get(), script);
+ g_assert_true(isScriptInjectedForURLAtPath(test, randomPath));
+ webkit_user_content_manager_remove_script(test->m_userContentManager.get(), script);
+ g_assert_false(isScriptInjectedForURLAtPath(test, randomPath));
+ webkit_user_script_unref(script);
+
// It's important to clean up the environment before other tests.
removeOldInjectedContentAndResetLists(test->m_userContentManager.get(), allowList, blockList);
}