Skip to content

Conversation

@akutira-umich
Copy link
Contributor

@akutira-umich akutira-umich commented Jul 24, 2025

9edb20b

Web Extension: Add implementations for get(), getSubTree(), and getChildren()
rdar://152505844
https://bugs.webkit.org/show_bug.cgi?id=295876

Reviewed by NOBODY (OOPS!).

Adds the WebProcess and UIProcess for get(), getSubTree(), and getChildren(). Also adds tests for these.

* Source/WebKit/UIProcess/Extensions/Cocoa/API/WebExtensionContextAPIBookmarksCocoa.mm:
(WebKit::findBookmarkNodeInTree):
(WebKit::createShallowParametersFromProtocolObjects):
(WebKit::WebExtensionContext::bookmarksGetSubTree):
(WebKit::WebExtensionContext::bookmarksGet):
(WebKit::WebExtensionContext::bookmarksGetChildren):
* Source/WebKit/WebProcess/Extensions/API/Cocoa/WebExtensionAPIBookmarksCocoa.mm:
(WebKit::WebExtensionAPIBookmarks::getChildren):
(WebKit::WebExtensionAPIBookmarks::getSubTree):
(WebKit::WebExtensionAPIBookmarks::get):
* Tools/TestWebKitAPI/Tests/WebKitCocoa/WKWebExtensionAPIBookmarks.mm:
(-[_MockBookmarkNode bookmarkTypeForWebExtensionContext:]):
(TestWebKitAPI::TEST_F(WKWebExtensionAPIBookmarks, CreateAndGetTree)):
(TestWebKitAPI::TEST_F(WKWebExtensionAPIBookmarks, GetSubTree)):

6a60011

Web Extensions: Add delegate functions for getTree()
rdar://155264420
https://bugs.webkit.org/show_bug.cgi?id=295551

Reviewed by NOBODY (OOPS!).

Implementation of getTree and mockNode for create bookmarks for testing. Created a delegate for getTree and create.

* Source/WebKit/Modules/OSX_Private.modulemap:
* Source/WebKit/Modules/iOS_Private.modulemap:
* Source/WebKit/UIProcess/API/Cocoa/WKWebExtensionControllerDelegatePrivate.h:
* Source/WebKit/UIProcess/API/Cocoa/_WKWebExtensionBookmarks.h: Added.
* Source/WebKit/UIProcess/Extensions/Cocoa/API/WebExtensionContextAPIBookmarksCocoa.mm:
(WebKit::createParametersFromProtocolObject):
(WebKit::createParametersFromProtocolObjects):
(WebKit::WebExtensionContext::bookmarksCreate):
(WebKit::WebExtensionContext::bookmarksGetTree):
* Source/WebKit/WebKit.xcodeproj/project.pbxproj:
* Source/WebKit/WebProcess/Extensions/API/Cocoa/WebExtensionAPIBookmarksCocoa.mm:
(WebKit::toAPI):
(WebKit::toWebAPI):
(WebKit::WebExtensionAPIBookmarks::createBookmark):
(WebKit::WebExtensionAPIBookmarks::getTree):
* Tools/TestWebKitAPI/Tests/WebKitCocoa/WKWebExtensionAPIBookmarks.mm:
(-[_MockBookmarkNode initWithDictionary:]):
(-[_MockBookmarkNode childrenForWebExtensionContext:]):
(findParentInMockTree):
(-[TestBookmarksDelegate init]):
(-[TestBookmarksDelegate _webExtensionController:getBookmarksForExtensionContext:completionHandler:]):
(-[TestBookmarksDelegate _webExtensionController:createBookmarkWithParentIdentifier:index:url:title:forExtensionContext:completionHandler:]):
(TestWebKitAPI::TEST_F(WKWebExtensionAPIBookmarks, BookmarksAPIMockNodeWithgetRecent)):
(TestWebKitAPI::TEST_F(WKWebExtensionAPIBookmarks, BookmarksAPICreateParse)):
(TestWebKitAPI::TEST_F(WKWebExtensionAPIBookmarks, BookmarksAPIGetTree)):
(TestWebKitAPI::TEST_F(WKWebExtensionAPIBookmarks, CreateAndGetTree)):
* Tools/TestWebKitAPI/cocoa/TestWebExtensionsDelegate.h:
* Tools/TestWebKitAPI/cocoa/TestWebExtensionsDelegate.mm:
(-[TestWebExtensionsDelegate _webExtensionController:createBookmarkWithParentIdentifier:index:url:title:forExtensionContext:completionHandler:]):
(-[TestWebExtensionsDelegate _webExtensionController:getBookmarksForExtensionContext:completionHandler:]):

9edb20b

Misc iOS, visionOS, tvOS & watchOS macOS Linux Windows
✅ 🧪 style ✅ 🛠 ios ✅ 🛠 mac ✅ 🛠 wpe ✅ 🛠 win
✅ 🧪 bindings ✅ 🛠 ios-sim ✅ 🛠 mac-AS-debug ✅ 🧪 wpe-wk2 🧪 win-tests
✅ 🧪 webkitperl ✅ 🧪 ios-wk2 ✅ 🧪 api-mac ✅ 🧪 api-wpe
✅ 🧪 ios-wk2-wpt ✅ 🧪 mac-wk1 ✅ 🛠 wpe-cairo
✅ 🧪 api-ios ✅ 🧪 mac-wk2 ✅ 🛠 gtk
✅ 🛠 vision ✅ 🧪 mac-AS-debug-wk2 ✅ 🧪 gtk-wk2
✅ 🛠 vision-sim ✅ 🧪 mac-wk2-stress ✅ 🧪 api-gtk
✅ 🧪 vision-wk2 ✅ 🧪 mac-intel-wk2 🛠 playstation
❌ 🛠 tv ✅ 🛠 mac-safer-cpp
❌ 🛠 tv-sim
❌ 🛠 watch
❌ 🛠 watch-sim

@webkit-ews-buildbot webkit-ews-buildbot added the merging-blocked Applied to prevent a change from being merged label Jul 24, 2025
rdar://155264420
https://bugs.webkit.org/show_bug.cgi?id=295551

Reviewed by NOBODY (OOPS!).

Implementation of getTree and mockNode for create bookmarks for testing. Created a delegate for getTree and create.

* Source/WebKit/Modules/OSX_Private.modulemap:
* Source/WebKit/Modules/iOS_Private.modulemap:
* Source/WebKit/UIProcess/API/Cocoa/WKWebExtensionControllerDelegatePrivate.h:
* Source/WebKit/UIProcess/API/Cocoa/_WKWebExtensionBookmarks.h: Added.
* Source/WebKit/UIProcess/Extensions/Cocoa/API/WebExtensionContextAPIBookmarksCocoa.mm:
(WebKit::createParametersFromProtocolObject):
(WebKit::createParametersFromProtocolObjects):
(WebKit::WebExtensionContext::bookmarksCreate):
(WebKit::WebExtensionContext::bookmarksGetTree):
* Source/WebKit/WebKit.xcodeproj/project.pbxproj:
* Source/WebKit/WebProcess/Extensions/API/Cocoa/WebExtensionAPIBookmarksCocoa.mm:
(WebKit::toAPI):
(WebKit::toWebAPI):
(WebKit::WebExtensionAPIBookmarks::createBookmark):
(WebKit::WebExtensionAPIBookmarks::getTree):
* Tools/TestWebKitAPI/Tests/WebKitCocoa/WKWebExtensionAPIBookmarks.mm:
(-[_MockBookmarkNode initWithDictionary:]):
(-[_MockBookmarkNode childrenForWebExtensionContext:]):
(findParentInMockTree):
(-[TestBookmarksDelegate init]):
(-[TestBookmarksDelegate _webExtensionController:getBookmarksForExtensionContext:completionHandler:]):
(-[TestBookmarksDelegate _webExtensionController:createBookmarkWithParentIdentifier:index:url:title:forExtensionContext:completionHandler:]):
(TestWebKitAPI::TEST_F(WKWebExtensionAPIBookmarks, BookmarksAPIMockNodeWithgetRecent)):
(TestWebKitAPI::TEST_F(WKWebExtensionAPIBookmarks, BookmarksAPICreateParse)):
(TestWebKitAPI::TEST_F(WKWebExtensionAPIBookmarks, BookmarksAPIGetTree)):
(TestWebKitAPI::TEST_F(WKWebExtensionAPIBookmarks, CreateAndGetTree)):
* Tools/TestWebKitAPI/cocoa/TestWebExtensionsDelegate.h:
* Tools/TestWebKitAPI/cocoa/TestWebExtensionsDelegate.mm:
(-[TestWebExtensionsDelegate _webExtensionController:createBookmarkWithParentIdentifier:index:url:title:forExtensionContext:completionHandler:]):
(-[TestWebExtensionsDelegate _webExtensionController:getBookmarksForExtensionContext:completionHandler:]):
@akutira-umich akutira-umich force-pushed the eng/Web-Extension-Add-the-ability-for-extensions-to-create-a-new-bookmark branch from 366a276 to 337d675 Compare July 24, 2025 07:55
…ildren()

rdar://152505844
https://bugs.webkit.org/show_bug.cgi?id=295876

Reviewed by NOBODY (OOPS!).

Adds the WebProcess and UIProcess for get(), getSubTree(), and getChildren(). Also adds tests for these.

* Source/WebKit/UIProcess/Extensions/Cocoa/API/WebExtensionContextAPIBookmarksCocoa.mm:
(WebKit::findBookmarkNodeInTree):
(WebKit::createShallowParametersFromProtocolObjects):
(WebKit::WebExtensionContext::bookmarksGetSubTree):
(WebKit::WebExtensionContext::bookmarksGet):
(WebKit::WebExtensionContext::bookmarksGetChildren):
* Source/WebKit/WebProcess/Extensions/API/Cocoa/WebExtensionAPIBookmarksCocoa.mm:
(WebKit::WebExtensionAPIBookmarks::getChildren):
(WebKit::WebExtensionAPIBookmarks::getSubTree):
(WebKit::WebExtensionAPIBookmarks::get):
* Tools/TestWebKitAPI/Tests/WebKitCocoa/WKWebExtensionAPIBookmarks.mm:
(-[_MockBookmarkNode bookmarkTypeForWebExtensionContext:]):
(TestWebKitAPI::TEST_F(WKWebExtensionAPIBookmarks, CreateAndGetTree)):
(TestWebKitAPI::TEST_F(WKWebExtensionAPIBookmarks, GetSubTree)):
@akutira-umich akutira-umich force-pushed the eng/Web-Extension-Add-the-ability-for-extensions-to-create-a-new-bookmark branch from 337d675 to 9edb20b Compare July 24, 2025 16:18
translating its native bookmark objects into objects that conform to the `_WKWebExtensionBookmark` protocol and
represent the top-level nodes of the bookmark hierarchy.
*/
- (void)_webExtensionController:(WKWebExtensionController * _Nonnull)controller getBookmarksForExtensionContext:(WKWebExtensionContext * _Nonnull)context completionHandler:(void (^)(NSArray<NSObject<_WKWebExtensionBookmark> *> * _Nullable, NSError * _Nullable))completionHandler;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
- (void)_webExtensionController:(WKWebExtensionController * _Nonnull)controller getBookmarksForExtensionContext:(WKWebExtensionContext * _Nonnull)context completionHandler:(void (^)(NSArray<NSObject<_WKWebExtensionBookmark> *> * _Nullable, NSError * _Nullable))completionHandler;
- (void)_webExtensionController:(WKWebExtensionController * _Nonnull)controller bookmarksForExtensionContext:(WKWebExtensionContext * _Nonnull)context completionHandler:(void (^)(NSArray<NSObject<_WKWebExtensionBookmark> *> * _Nullable, NSError * _Nullable))completionHandler;

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

merging-blocked Applied to prevent a change from being merged

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants