clients.openWindow throws "TypeError: Unable to open window" when no window is open
Categories
(Core :: DOM: Service Workers, defect, P3)
Tracking
()
People
(Reporter: github, Unassigned)
References
Details
(Whiteboard: dom-lws-bugdash-triage)
Attachments
(3 files)
User Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.114 Safari/537.36
Steps to reproduce:
Click any push notification when no tab nor window is open. Please note that when any window/tab is open, the problem can't be reproduced. All windows/tabs need to be closed.
Make push messaging and service worker with this function:
self.addEventListener('notificationclick', function(e) {
clients.openWindow('https://example.com').catch(function(e) {console.log(e);});
});
Actual results:
Nothing happens, no window opens. An error is reported in the service worker's logs: TypeError: Unable to open window
Expected results:
A new window/tab should have opened.
Comment 1•4 years ago
|
||
The Bugbug bot thinks this bug should belong to the 'Firefox::Messaging System' component, and is moving the bug to that component. Please revert this change in case you think the bot is wrong.
Comment 2•4 years ago
|
||
I believe this is the right component for this issue, moving it over to Dom: Service Workers. Thank you for the report!
Comment 3•3 years ago
|
||
I believe this likely should be addressed in Firefox when running under fission thanks to the many cleanups involved, but we'll need to confirm this.
Comment 4•2 years ago
|
||
I think the bug is still present.
On my service worker implementation, the problem is simple to reproduce.
OS: MacOs Ventura
Firefox Version: Stable, 112
- Open firefox normal window and load web app installing service worker
- Open incognito window to web app responsible triggering push event on previous service worker installed
- close normal window
- from incognito window, trigger the push event
From here, the service worker receive the push event and showNotification()
- the user click on the notification
- the service worker "notificationclick" event handler triggers and fails to open the window with "self.clients.openWindow()"
Here is the linked stack overflow:
Comment 5•2 years ago
|
||
At current version of Firefox for Android. It opens about:blank page instead of open url.
This code navigates to url from active window. But its not a solution to open url in new window.
self.addEventListener("notificationclick", (e) => {
e.notification.close();
e.waitUntil(self.clients.claim().then(() => {
// See https://developer.mozilla.org/en-US/docs/Web/API/Clients/matchAll
return self.clients.matchAll({type: 'window'});
}).then(clients => {
return clients.map(client => {
// Check to make sure WindowClient.navigate() is supported.
if ('navigate' in client) {
return client.navigate('https://google.com/');
}
});
}));
});
Likely duplicate: https://bugzilla.mozilla.org/show_bug.cgi?id=1815380
Opening windows via clients.openWindow
doesn't work at all, neither does client.focus
. Both open a blank window, and clients.openWindow
returns NS_ERROR_FAILURE
.
Tried with Firefox Android 116.3.0 on my own device and 114.2.0 on BrowserStack.
Chrome in https://webpushtest.com/ - everything works as expected
Firefox in https://webpushtest.com/ - doesn't open the page, not even blank
Comment 9•3 months ago
|
||
Do we see the issue outside of Android? For Android we have bug 1825910 which is being worked on. If not probably we can mark this as a duplicate.
Comment 10•3 months ago
|
||
I should check the comment #0 is still a thing, although a simple test says it's not a problem anymore, but that was a living service worker. I need to check whether a newly triggered service worker also works.
Comment 11•3 months ago
|
||
(And me realizes that we have bug 1847096, so that can't happen. So let's track the Android part in bug 1825910, the service worker startup part in bug 1847096, and close this as comment #0 doesn't happen anymore.)
Updated•3 months ago
|
Description
•