Skip to content

Web Extensions: Parse getRecent() bookmark function #47086

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Conversation

akutira-umich
Copy link
Contributor

@akutira-umich akutira-umich commented Jun 23, 2025

6663438

Web Extensions: Parse getRecent() bookmark function
rdar://153924872
https://bugs.webkit.org/show_bug.cgi?id=294766

Reviewed by Timothy Hatcher.

Added Parsing for getRecent that uses mock BookmarkTreeNodes created by Create()
to test its functionality. Added tests for this as well.

* Source/WebKit/WebProcess/Extensions/API/Cocoa/WebExtensionAPIBookmarksCocoa.mm:
(WebKit::WebExtensionAPIBookmarks::createDictionaryFromNode):
(WebKit::WebExtensionAPIBookmarks::createBookmark):
(WebKit::WebExtensionAPIBookmarks::getRecent):
* Source/WebKit/WebProcess/Extensions/API/WebExtensionAPIBookmarks.h:
* Source/WebKit/WebProcess/Extensions/Interfaces/WebExtensionAPIBookmarks.idl:
* Tools/TestWebKitAPI/Tests/WebKitCocoa/WKWebExtensionAPIBookmarks.mm:
(TestWebKitAPI::TEST_F(WKWebExtensionAPIBookmarks, BookmarksAPICheckgetRecent)):
(TestWebKitAPI::TEST_F(WKWebExtensionAPIBookmarks, BookmarksAPIMockNodeWithgetRecent)):

Canonical link: https://commits.webkit.org/296640@main

66e36a3

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
✅ 🛠 🧪 unsafe-merge ✅ 🛠 tv 🛠 mac-safer-cpp
✅ 🛠 tv-sim
✅ 🛠 watch
✅ 🛠 watch-sim

Copy link
Contributor

@AriYoung00 AriYoung00 left a comment

Choose a reason for hiding this comment

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

Requesting changes based on previous comments

@@ -35,9 +35,50 @@

namespace WebKit {

NSDictionary* WebExtensionAPIBookmarks::createDictionaryFromNode(const MockBookmarkNode& node)
{
double msSinceEpoch = (node.dateAdded + kCFAbsoluteTimeIntervalSince1970) * 1000.0;
Copy link
Contributor

Choose a reason for hiding this comment

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

You should use toImpl() from CocoaHelpers.h.

WallTime toImpl(NSDate *);

Then toImpl(node.dateAdded).secondsSinceEpoch().milliseconds().

std::string id;
std::string title;
std::string url;
CFAbsoluteTime dateAdded;
Copy link
Contributor

Choose a reason for hiding this comment

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

Prefer WTF::WallTime.

@webkit-ews-buildbot webkit-ews-buildbot added the merging-blocked Applied to prevent a change from being merged label Jun 24, 2025
@akutira-umich akutira-umich force-pushed the eng/Web-Extensions-Parse-getRecent-bookmark-function branch from 878f98b to 5e559ac Compare June 24, 2025 18:04
@akutira-umich akutira-umich force-pushed the eng/Web-Extensions-Parse-getRecent-bookmark-function branch from 5e559ac to 256aa88 Compare June 24, 2025 18:53
@akutira-umich akutira-umich force-pushed the eng/Web-Extensions-Parse-getRecent-bookmark-function branch from 256aa88 to 9a37c49 Compare June 24, 2025 22:35
@akutira-umich akutira-umich force-pushed the eng/Web-Extensions-Parse-getRecent-bookmark-function branch from 9a37c49 to f4e8617 Compare June 25, 2025 21:04
Comment on lines 57 to 65
NSArray *requiredKeys = @[ @"id", @"url", @"dateAdded" ];
NSDictionary *types = @{
WebExtensionBookmarkIDKey: [NSString class],
WebExtensionBookmarkURLKey: [NSString class],
WebExtensionBookmarkDateAddedKey: [NSNumber class],
WebExtensionBookmarkTitleKey: [NSString class]
};
Copy link
Contributor

Choose a reason for hiding this comment

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

Use constants defined above here. NSString.class, NSNumber.class.

MockBookmarkNode newNode;
newNode.id = bookmark[@"id"];
newNode.url = bookmark[@"url"];
id dateAddedValue = bookmark[@"dateAdded"];
Copy link
Contributor

Choose a reason for hiding this comment

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

No need for a local. Should use auto * instead of id.

@akutira-umich akutira-umich force-pushed the eng/Web-Extensions-Parse-getRecent-bookmark-function branch from f4e8617 to 66e36a3 Compare June 25, 2025 22:55
@xeenon xeenon added unsafe-merge-queue Applied to send a pull request to merge-queue, but skip building and testing WebKit Extensions Bugs related to extension support. and removed merging-blocked Applied to prevent a change from being merged labels Jun 26, 2025
rdar://153924872
https://bugs.webkit.org/show_bug.cgi?id=294766

Reviewed by Timothy Hatcher.

Added Parsing for getRecent that uses mock BookmarkTreeNodes created by Create()
to test its functionality. Added tests for this as well.

* Source/WebKit/WebProcess/Extensions/API/Cocoa/WebExtensionAPIBookmarksCocoa.mm:
(WebKit::WebExtensionAPIBookmarks::createDictionaryFromNode):
(WebKit::WebExtensionAPIBookmarks::createBookmark):
(WebKit::WebExtensionAPIBookmarks::getRecent):
* Source/WebKit/WebProcess/Extensions/API/WebExtensionAPIBookmarks.h:
* Source/WebKit/WebProcess/Extensions/Interfaces/WebExtensionAPIBookmarks.idl:
* Tools/TestWebKitAPI/Tests/WebKitCocoa/WKWebExtensionAPIBookmarks.mm:
(TestWebKitAPI::TEST_F(WKWebExtensionAPIBookmarks, BookmarksAPICheckgetRecent)):
(TestWebKitAPI::TEST_F(WKWebExtensionAPIBookmarks, BookmarksAPIMockNodeWithgetRecent)):

Canonical link: https://commits.webkit.org/296640@main
@webkit-commit-queue webkit-commit-queue force-pushed the eng/Web-Extensions-Parse-getRecent-bookmark-function branch from 66e36a3 to 6663438 Compare June 26, 2025 00:17
@webkit-commit-queue
Copy link
Collaborator

Committed 296640@main (6663438): https://commits.webkit.org/296640@main

Reviewed commits have been landed. Closing PR #47086 and removing active labels.

@webkit-commit-queue webkit-commit-queue merged commit 6663438 into WebKit:main Jun 26, 2025
@webkit-commit-queue webkit-commit-queue removed the unsafe-merge-queue Applied to send a pull request to merge-queue, but skip building and testing label Jun 26, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
WebKit Extensions Bugs related to extension support.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants