WebKit Bugzilla
New
Browse
Log In
×
Sign in with GitHub
or
Remember my login
Create Account
·
Forgot Password
Forgotten password account recovery
RESOLVED FIXED
239933
[macOS] The "Markup Image" services menu item should be gated on image analysis results
https://bugs.webkit.org/show_bug.cgi?id=239933
Summary
[macOS] The "Markup Image" services menu item should be gated on image analys...
Wenson Hsieh
Reported
2022-04-30 12:54:46 PDT
rdar://92348202
Attachments
For EWS
(24.04 KB, patch)
2022-04-30 16:55 PDT
,
Wenson Hsieh
no flags
Details
Formatted Diff
Diff
Patch
(24.05 KB, patch)
2022-04-30 18:26 PDT
,
Wenson Hsieh
no flags
Details
Formatted Diff
Diff
Patch
(23.95 KB, patch)
2022-05-01 10:43 PDT
,
Wenson Hsieh
katherine_cheney
: review+
Details
Formatted Diff
Diff
Patch for landing
(24.07 KB, patch)
2022-05-02 11:43 PDT
,
Wenson Hsieh
no flags
Details
Formatted Diff
Diff
Show Obsolete
(2)
View All
Add attachment
proposed patch, testcase, etc.
Wenson Hsieh
Comment 1
2022-04-30 16:55:42 PDT
Created
attachment 458640
[details]
For EWS
Wenson Hsieh
Comment 2
2022-04-30 18:26:05 PDT
Created
attachment 458642
[details]
Patch
Tim Nguyen (:ntim)
Comment 3
2022-05-01 02:52:03 PDT
Comment on
attachment 458642
[details]
Patch View in context:
https://bugs.webkit.org/attachment.cgi?id=458642&action=review
> Tools/TestWebKitAPI/Tests/WebKitCocoa/image-controls.html:30 > + await new Promise(async resolve => { > + let button = null; > + do { > + await new Promise(requestAnimationFrame); > + button = servicesControlButton(); > + } while (!button); > + resolve(); > + button.click(); > + });
You don't need to wrap a Promise object since you're already in an async function, I think this should just work: ``` async function waitForAndClickImageControls() { if (!window.internals) return; let button = null; do { await new Promise(requestAnimationFrame); button = servicesControlButton(); } while (!button); button.click(); } ```
Tim Nguyen (:ntim)
Comment 4
2022-05-01 03:03:33 PDT
Comment on
attachment 458642
[details]
Patch View in context:
https://bugs.webkit.org/attachment.cgi?id=458642&action=review
>> Tools/TestWebKitAPI/Tests/WebKitCocoa/image-controls.html:30 >> + }); > > You don't need to wrap a Promise object since you're already in an async function, I think this should just work: > > ``` > > async function waitForAndClickImageControls() { > if (!window.internals) > return; > > let button = null; > do { > await new Promise(requestAnimationFrame); > button = servicesControlButton(); > } while (!button); > button.click(); > } > ```
or if you really meant to resolve() before the button click (which is pretty weird IMO): ``` function waitForAndClickImageControls() { return new Promise(async resolve => { if (!window.internals) return resolve(); let button = null; do { await new Promise(requestAnimationFrame); button = servicesControlButton(); } while (!button); resolve(); button.click(); }); } ```
Wenson Hsieh
Comment 5
2022-05-01 10:41:28 PDT
Good point! With the current version of the test, we don't need to resolve the promise before clicking because we'll always dispatch the runloop timer before we start spinning the runloop for the context menu. Changed to simplify waitForAndClickImageControls().
Wenson Hsieh
Comment 6
2022-05-01 10:43:02 PDT
Created
attachment 458651
[details]
Patch
Kate Cheney
Comment 7
2022-05-02 11:03:33 PDT
Comment on
attachment 458651
[details]
Patch View in context:
https://bugs.webkit.org/attachment.cgi?id=458651&action=review
> Source/WebKit/UIProcess/mac/WebContextMenuProxyMac.mm:299 > + if (!page()->preferences().imageAnalysisMarkupEnabled())
Do we need to check for a null page here?
Wenson Hsieh
Comment 8
2022-05-02 11:34:51 PDT
Comment on
attachment 458651
[details]
Patch View in context:
https://bugs.webkit.org/attachment.cgi?id=458651&action=review
Thanks for the review!
>> Source/WebKit/UIProcess/mac/WebContextMenuProxyMac.mm:299 >> + if (!page()->preferences().imageAnalysisMarkupEnabled()) > > Do we need to check for a null page here?
Ah, so I think we're technically okay here since this method is only called from `setupServicesMenu()` which already dereferences `page()` (and therefore assumes that it's non-null). That said, since this is a separate method now, adding an extra null check is probably a good idea — I'll add an early return here for `!page()`.
Wenson Hsieh
Comment 9
2022-05-02 11:43:15 PDT
Created
attachment 458697
[details]
Patch for landing
EWS
Comment 10
2022-05-02 13:30:53 PDT
Committed
r293681
(
250181@main
): <
https://commits.webkit.org/250181@main
> All reviewed patches have been landed. Closing bug and clearing flags on
attachment 458697
[details]
.
Note
You need to
log in
before you can comment on or make changes to this bug.
Top of Page
Format For Printing
XML
Clone This Bug