Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Could not access window created using window.open('about:blank' .... code #2481

Closed
bhavnapanchal opened this issue Mar 2, 2017 · 11 comments
Closed

Comments

@bhavnapanchal
Copy link

bhavnapanchal commented Mar 2, 2017

Hej,

I found weird behavior in firefox-iOS, while opening new window/popup using about:blank new window created by browser is not accessible and this is happening in Firefox-iOS only not in safari.

To make long story sort i created demo javascript to produce the error please have a look at it.

[Code:javascript]
var win = window.open('about:blank','windownamenew','width=1,height=1,left=5,top=3');
setTimeout(function() { win.close();}, 3000);
[Code:end]

purpose of above code is to create new window and then close it after few seconds.
but it not behave proper in firefox.

here is a video to demonstrate.
https://drive.google.com/file/d/0B7fztZykJUJMcldoRHB6QTBLSUE/view?usp=sharing
OR
firefoxBug.zip

In it you can see that safari works fine but in firefox it not.

[Next-step]
If you guys approve it as an issue then i have solution.

bhavnapanchal added a commit to bhavnapanchal/firefox-ios that referenced this issue Mar 2, 2017
mozilla-mobile#2481

[Reason]
about: url scheme was going to ignore and consider as not valid url scheme for open model/tab in browser.

[Solution]
Add about in array of valid url chemes for open model/tab
@farhanpatel
Copy link
Contributor

Thanks for filing this issue. We are having a hard time understanding this issue.
What is a real world use case for a feature like this?

@bhavnapanchal
Copy link
Author

Hi, I explain same thing here too.
https://bugzilla.mozilla.org/show_bug.cgi?id=1350833#c9

Let me know if you need more information.

@pvgoran
Copy link

pvgoran commented Sep 30, 2017

We at A3H.org (Activities & Attractions Association of Hawaii) just encountered this issue, in a very real-world use case. We host a real-time booking system which works in conjunction with companies' (third-party) web sites. The customer access the company's web site which has a form for booking a trip. When the customer clicks the submit button, the Javascript code that we supplied opens a blank popup window, which is then filled using document.write() with some <script> elements which reference our (A3H's) website. The website checks if the trip is available, and returns the Javascript that either continues the booking process, or tells the customer that booking is not possible.

https://www.prideofmaui.com/turtlesnorkel/#booknow (the booking form at the right) is an example. With Firefox on IOS, it doesn't work. In all other Firefox versions that I tried, everything is fine. Moreover, Safari and Chrome on IOS also work file; Google Browser on IOS doesn't seem to work, though.

@bhavnapanchal
Copy link
Author

@pvgoran
Will you please comment same thing here, on my pull-request as they closed it because they could not find real world example for it.
#2484

@jgreibus
Copy link

We have situation when we need check if window with window name exsists.

If it exists we add some additional information to window otherwise we create window with this new information.

`let winName = "win-name",
win = window.open("", winName),
message = 'Message content';

if(win.customObject){
win.customObject.showMessage(message);
} else {
win = window.open("index.html?message=${message}", "_blank");
win.name = winName;
}`

@Elias-Serneels
Copy link

We have a similar situation in which we open a blank window and afterwards set the location of that window like this:

let someWindow = window.open('');
// some async code to get the uri
// in callback:
someWindow.location= "https://someWebsite.url";

This works on all browsers except for firefox on iOS.

We open an empty window first because it's not possible/allowed to open a window in an async callback.

The only way for us to get around this is to get the uris needed to open the window before the user clicks on a button/link which is not feasible for our use case.

@pvgoran
Copy link

pvgoran commented Feb 14, 2018

@Elias-Serneels Does your code work in Google App on IOS, by the way?

@Elias-Serneels
Copy link

Elias-Serneels commented Feb 14, 2018

@pvgoran I just tested and no it doesn't. Here is a codepen to demonstrate the issue: https://codepen.io/anon/pen/bLrPQq

edit: The codepen seems to affect the issue so it's best to try it out for yourselves.

@bhavnapanchal
Copy link
Author

bhavnapanchal commented Jun 10, 2018

As I explain in my previous finding also, the root cause of this issue is we have this variable "SchemesAllowedToOpenAsPopups" which behaving as a gatekeeper.
reference link

It choose which URL scheme will going to open in popup window and which not.
I have debug firefox and chrome code and find out that this type of logic is only happen here and I don't know why.

WKWebView have delegate which call when some page want to open popups.
as a browser you have to create new WKWebView instance and return it to that delegate.

but what firefox do is, for certain url sheme it return WKWebView instance and for other it just return null.

SchemesAllowedToOpenAsPopups = ["http", "https", "javascript", "data", "about"]
note in the case when it return null javascript object does not have control over newly created window which is expectable as firefox does not giving it.

BEST SOLUTION WILL BE
remove SchemesAllowedToOpenAsPopups usage and find out why firefox had it because it is look like a very bad patch.

@MikeRKaplan
Copy link

We have this issue also. Our web site is a web enabled application that is password protected.

Customers can view PDFs but not via direct links - we don't want the PDFs available via a simple URL that anyone could use. Instead we open a blank window. In the first window we submit a POST request to our server and set the target of the response to the new, blank window. This works correctly in most browsers, including FireFox in Windows but it does not work in FireFox on an iPad. It does work correctly in Safari on an iPad.

@farhanpatel
Copy link
Contributor

Closing due to inactivity. Please reopen if you feel it is still is relevant

jjSDET pushed a commit to jjSDET/firefox-ios that referenced this issue Feb 13, 2024
isabelrios pushed a commit to isabelrios/firefox-ios that referenced this issue Feb 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants