New issue
Advanced search Search tips

Issue 795855 link

Starred by 1 user

Issue metadata

Status: Available
Owner: ----
Cc:
Components:
EstimatedDays: ----
NextAction: ----
OS: iOS
Pri: 3
Type: Bug



Sign in to add a comment

Javascript injection fails on "Content-Disposition: attachment" pages

Project Member Reported by michaeldo@chromium.org, Dec 18 2017

Issue description

Pages which attempt to trigger a content download (with the "Content-Disposition: attachment" header) are actually rendered inside the WKWebView, if the web view supports displaying the content. (Supported content display is based on WKNavigationResponse's canShowMIMEType.)

When this content is displayed, WKWebView prevents JavaScript injection. Injecting the windowId fails with the following error in the Safari Debugging console:
"Blocked script execution in '<URL>' because the document's frame is sandboxed and the 'allow-scripts' permission is not set."

and the following error is returned from WKWebView evaluateJavaScript:completionHandler:
Error Domain=WKErrorDomain Code=4 "A JavaScript exception occurred" UserInfo={WKJavaScriptExceptionLineNumber=0, WKJavaScriptExceptionMessage=, WKJavaScriptExceptionColumnNumber=0, NSLocalizedDescription=A JavaScript exception occurred}

I tested with the text file download at the bottom of http://www.jtricks.com/bits/content_disposition.html and reproduced the error on iPhone 7 simulator for both 10.3.1 and 11.2
 
This issue was discovered in crbug.com/794206.

In order to fix this, we would need to present the content from our own html page if we want to render it directly. Otherwise, we could simply present the download page as described in  crbug.com/574033 , but I strongly believe we need to give the user an easy way to view supported content instead of only showing download page. (Download page experience would be very poor on sites like unsplash.com where every tapped image is a "downloaded".)

Blockedon: 574033
Blockedon: -574033
Mike, should we file a radar?
Components: Mobile>iOSWeb
Components: -Mobile>WebView>Glue
Components: -Mobile>iOSWeb Mobile>iOSWeb>ScriptInjections

Sign in to add a comment