Bug 184514
Summary: | Cannot set window.location immediately after window.open('') | ||
---|---|---|---|
Product: | WebKit | Reporter: | Justin D'Arcangelo <jdarcangelo> |
Component: | WebCore JavaScript | Assignee: | 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
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
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.