WebKit Bugzilla
New
Browse
Log In
×
Sign in with GitHub
or
Remember my login
Create Account
·
Forgot Password
Forgotten password account recovery
RESOLVED WORKSFORME
184514
Cannot set window.location immediately after window.open('')
https://bugs.webkit.org/show_bug.cgi?id=184514
Summary
Cannot set window.location immediately after window.open('')
Justin D'Arcangelo
Reported
2018-04-11 12:52:28 PDT
In a WKWebView, web content cannot set `window.location` or `window.opener` on a `Window` returned immediately after calling `window.open('')` or `window.open('about:blank')`. For example, clicking the link in the following HTML/JS snippet will result in a BLANK `WKWebView` being opened via `webView(_:createWebViewWith:for:windowFeatures:)` and the location is never set: ``` <a href="
https://webkit.org/
" id="brokenlink">Click Me</a> <script> var brokenlink = document.getElementById('brokenlink'); brokenlink.addEventListener(function(evt) { evt.preventDefault(); var openedWin = window.open('about:blank'); openedWin.location = this.href; }); </script> ``` A more in-depth version of the above example can be found at:
http://output.jsbin.com/tegacej
Also, a minimal proof-of-concept iOS app to reproduce this issue can be found at:
https://github.com/justindarc/WebViewOpenTester
Attachments
Add attachment
proposed patch, testcase, etc.
Justin D'Arcangelo
Comment 1
2018-04-12 12:57:14 PDT
After further investigation, I realized that the documentation mentions that *WebKit* will load the request in the returned web view from `webView(_:createWebViewWith:for:windowFeatures:)`. In my example, I am loading the request myself which seems to break this. I'm going to mark this as resolved. Sorry for the confusion.
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