Bug 184514

Summary: Cannot set window.location immediately after window.open('')
Product: WebKit Reporter: Justin D'Arcangelo <jdarcangelo>
Component: WebCore JavaScriptAssignee: Nobody <webkit-unassigned>
Status: RESOLVED WORKSFORME    
Severity: Normal CC: ap, beidson, cdumez
Priority: P2    
Version: Safari 11   
Hardware: iPhone / iPad   
OS: iOS 11   

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
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.