Bug 204557 - WKScriptMessageHandler is unable to evaluate JavaScript in the context of the calling frame
Summary: WKScriptMessageHandler is unable to evaluate JavaScript in the context of the...
Status: RESOLVED DUPLICATE of bug 213556
Alias: None
Product: WebKit
Classification: Unclassified
Component: WebKit2 (show other bugs)
Version: Safari 13
Hardware: All All
: P2 Blocker
Assignee: Nobody
URL:
Keywords: InRadar
Depends on:
Blocks:
 
Reported: 2019-11-24 08:09 PST by Ken Case
Modified: 2020-06-29 22:38 PDT (History)
4 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Ken Case 2019-11-24 08:09:06 PST
I'm trying to get password autofill working again in OmniWeb after porting to WKWebView. Because WKWebView doesn't have any direct API to support this, I've registered a WKUserScript which catches events on password fields and calls back to the app to look up the site's password in the keychain. This works fine for the main frame and for any child frames which share the security origin of the main frame, since I can register some callback functions on window.top. But CORS makes this impossible when the child frame has a different security origin (such as with appstoreconnect.apple.com with its embedded iframe at idmsa.apple.com).

It would be great if WKScriptMessageHandler had some way to get results back to the frame which called it--for example, if it could pass the WKFrameInfo from its received WKScriptMessage to a variant of WKWebView's -evaluateJavaScript:completionHandler: to evaluate a script in the context of that originating frame.

There may be other ways to solve the specific use case of implementing password autofill—but, generally speaking, it seems like a very big limitation that WKScriptMessageHandler is unable to call back to the JavaScript context which called it to return results to the invoking context.

(Thanks in advance for considering this!)
Comment 1 Radar WebKit Bug Importer 2019-11-24 15:23:15 PST
<rdar://problem/57461911>
Comment 2 Brady Eidson 2020-06-29 22:38:50 PDT
Due to lots of people reporting this in lots of different venues and lots of conversations happening around them at different times... I worked on this in a newer bug report.

So sorry for the reverse dupe!

*** This bug has been marked as a duplicate of bug 213556 ***