eladnava / applicationize

Converts your favorite web apps into desktop apps with their own dedicated launcher icon.
https://applicationize.me/
Apache License 2.0
495 stars 85 forks source link

window.opener not set on windows opened via web notifications #69

Closed adammw closed 5 years ago

adammw commented 6 years ago

Example: gmail notifications - they require the window.opener to be the original gmail webview that opened it, whereas it's not set as a popup in a webview.

eladnava commented 6 years ago

Hi @adammw, Thanks for the report.

What is the current behavior of Gmail desktop notifications? Do they throw an error in the console? They don't focus the webview window?

adammw commented 6 years ago

It appears to open a new popup window, as they are supposed to, however the window is blank as it seems it relies on javascript communication with the main window to populate it's contents. Opening the same URL in a new tab gives the same result. I noted that the popup is within the applicationize webview as well - and the window.opener of the page holding the webview is correct but isn't inherited by the webview. Inspecting the javascript error, I could trace it back to a line where it tries to use a javascript object from window.opener.

eladnava commented 6 years ago

@adammw Cool, great work and observations.

I tried to fix this in https://github.com/eladnava/applicationize/commit/bfcb66674f0ae9ca6c41bdedc7495e4b8b96c524, please re-generate the extension and let me know if it works: https://applicationize.me/now

adammw commented 6 years ago

Hmm, doesn't seem to be any different.

You can reproduce this by going to your Gmail account and in the devtools console, running: window.open('https://mail.google.com/mail/?ui=2&view=btop'). The page that opens, if you inspect that, you should be able to access window.opener.js and window.opener.js._GM_ftcb objects (ie. they should not be null).

When doing the same in applicationize, window.opener is still null - I suspect because of the different chrome context it runs in.

eladnava commented 6 years ago

Hi @adammw, Thanks for the reproduction steps.

It appears we are limited by the Chrome APIs here. The only way to attach the opening window as the window.opener of the popup window would be if the webview we create to host the popup would be in the same chrome.app.window as the opener (parent).

Otherwise, the following error is thrown when calling popup.window.attach(webview) within a new chrome.app.window:

Error: <webview>: An action has already been taken for this "newwindow" event.

Using the same chrome.app.window obviously defeats the purpose of a popup, so I'm not sure how we can rectify this as it is upstream.

On another note, Applicationize is on its way to deprecation due to the deprecation of Chrome apps. Please read this and check out alternatives mentioned there (I highly recommend Nativefier): https://github.com/eladnava/applicationize/issues/62

eladnava commented 5 years ago

Closing due to upstream functionality limitation of Chrome APIs.