Closed Bug 1172928 Opened 5 years ago Closed 5 years ago
.close() does not close the tab
47 bytes, text/x-github-pull-request
|Details | Review|
This is a followup bug for 1124942, which has not landed yet. STR: * Go to https://mozillians.org * Login with persona * The Persona login screen should appear in a new tab * Finish the login Expected: The persona login tab closes and you go back to the tab you came from. Actual: Persona just sits there. But if you manually close the tab and you go back to the mozillians.org tab, you are actually correctly logged in. Not sure what piece we miss to support window.close(), may be some WKWebView delegate that we need to implement?
It looks like that there is no public API for detecting window.close events in WKWebview frameworks. There is some code in Webkit https://bugs.webkit.org/show_bug.cgi?id=137008 demonstrating a private API, but this doesn't seem to be working for us in Swift. Plus: private APIs.
Summary: Persona login (popup) window does not close after logging in → Window.close() does not close the tab
Work in progress but please take a look anyway. This may catch most cases. Except persona as noted below. This patches window.close to send us a callback so that the native code can close the tab. This work for the general case. It does not work for Persona because Persona is insanely complicated and they probably do something special.
Comment on attachment 8634771 [details] [review] PR: https://github.com/mozilla/firefox-ios/pull/758 LGTM with a few comments.
Attachment #8634771 - Flags: review?(bnicholson) → review+
Couple of notes: This works correctly on for example http://www.permadi.com/tutorial/facebook-js-oauth-popup-centered/ which opens a new tab with a Facebook login. After logging in the tab closes correctly and you are back at the original tab and logged in. On Persona this fails, but now I think this may not be an error in this code but an issue with Persona. I see a message about origin login.persona.org not matching login.mozilla.org. (This appears in the console for login.persona.org - dont forget to attach the debugger to the right tab)
Assuming we want to land this since it handles some cases on iOS 8. Filed bug 1186030 for iOS 9 specifically.
Assignee: jhugman → nobody
Status: ASSIGNED → NEW
Whiteboard: ios9 → ios9, needs-cleanup
Stefan, this needs landing.
Assignee: nobody → sarentz
I'll deal with the review comments on tuesday and land it then. Is there someone on the (old) Persona team who we can loop in to see if we can find out why this patch does not work for the Persona popup? Persona does crazy things, but I don't know enough about JS to understand what specifically.
I have addressed the review comments and landed this. Couple of notes: * There is a test page at http://people.mozilla.org/~sarentz/t/wo.html that shows this fix in action. * For testing it is important to know that WebKit only lets you window.close() webviews that have a parent/child relationship. You can't just window.close() any window. * This does not work with Persona yet because I assume Persona does some more complicated things. I have reached out to people to get that fixed too, which can be done as a followup bug. https://github.com/mozilla/firefox-ios/commit/43e50b6c697196c260a0fd1472da3210b98592b2
Status: ASSIGNED → RESOLVED
Closed: 5 years ago
Resolution: --- → FIXED
Shane Tomlinson would be your best bet from the legacy Persona team. You might want to approach Ryan Kelly or Chris Karlof about getting some of Shane's time to look into this.
Look like this issue is produce again in latest build. (BUG RISES) Please have a look into this issue for more detail. https://github.com/mozilla-mobile/firefox-ios/issues/2481 I also did pull request for solution https://github.com/mozilla-mobile/firefox-ios/pull/2484 Here is a test url i created to test. https://bhavnapanchal.github.io/firefoxpopuptest.github.io/
Please file a new bug.
You need to log in before you can comment on or make changes to this bug.