[Webkit-unassigned] [Bug 213556] [iOS 14] JavaScript cannot be injected into iframes using isolated worlds

bugzilla-daemon at webkit.org bugzilla-daemon at webkit.org
Wed Jun 24 14:51:39 PDT 2020


https://bugs.webkit.org/show_bug.cgi?id=213556

--- Comment #4 from Ali Juma <ajuma at chromium.org> ---
(In reply to Alex Christensen from comment #3)
> I'm wondering if these SPIs would meet your needs?
> 
> - (void)_evaluateJavaScript:(NSString *)javaScriptString
> inFrame:(WKFrameInfo *)frame inContentWorld:(WKContentWorld *)contentWorld
> completionHandler:(void (^)(id, NSError * error))completionHandler
> WK_API_AVAILABLE(macos(WK_MAC_TBA), ios(WK_IOS_TBA));
> ...
> - (void)_callAsyncJavaScript:(NSString *)functionBody
> arguments:(NSDictionary<NSString *, id> *)arguments inFrame:(WKFrameInfo
> *)frame inContentWorld:(WKContentWorld *)contentWorld
> completionHandler:(void (^)(id, NSError *error))completionHandler
> WK_API_AVAILABLE(macos(WK_MAC_TBA), ios(WK_IOS_TBA));
> ...
> - (void)_frames:(void (^)(_WKFrameTreeNode *))completionHandler
> WK_API_AVAILABLE(macos(WK_MAC_TBA), ios(WK_IOS_TBA));

My main concerns with this approach are how we would find out about new frames appearing in _frames, and how early we would be able to inject script into a new frame. We don't currently get much by way of navigation callbacks for subframes in public API -- decidePolicyForNavigationAction has a targetFrame, but it's presumably too early to inject at that point, and decidePolicyForNavigationResponse tells us whether the response is for a subframe, but doesn't include a WKFrameInfo. Periodically polling _frames doesn't seem like a great solution.

As a concrete example, we inject logic for form autofill. This code adds event listeners on |document| for events that could be related to a form being edited (like 'focus', 'blur', 'change'). It's important that this gets reliably injected before the user interacts with the page, so using a WKUserScript with WKUserScriptInjectionTimeAtDocumentStart works well.

-- 
You are receiving this mail because:
You are the assignee for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.webkit.org/pipermail/webkit-unassigned/attachments/20200624/0cea98d0/attachment-0001.htm>


More information about the webkit-unassigned mailing list