getUserMedia permission dialog disappears in FireFox - javascript

When I access getUserMedia, a permission dialog pops up and my website waits until the user either accepts or blocks the request. That part works in Chrome 47.
However, in FireFox 43, (at least), when the dialog is visible, the user can click anywhere else and it will disappear and getUserMedia's callback will never be invoked. Then the user can't give permission and my site is stuck waiting. And it is pretty easy to click somewhere else, too, so I'm anticipating lots of "the microphone doesn't work" support calls.
(That seems like a bug in FireFox to me, since Chrome keeps the dialog visible until the user clicks it.) But anyway, is there a work around?
For instance, is there a way to detect whether the permission dialog is currently visible?
Or is there a way to re-summon that dialog in javascript by using a setTimeout?
Does anyone have another suggestion about how to make this user experience better?
The only thing I can think of is to put up a message something to the effect of, "Waiting for permission to use the microphone. If you don't see a permission dialog please refresh this page." There must be something better than that.
Thanks!

The permission dialog is merely minimized. Click on the gray microphone (or camera) icon that the dialog hung off, which is still there in the URL bar, and the dialog grows back and can be answered.
It is not a bug, as it was designed to be less intrusive than Chrome, to not let sites keep users hostage, so to speak, until they give up permissions, but the behavior does seem to confuse a lot of people. See https://bugzil.la/1004055.
There is no surefire way to detect whether the permission dialog is currently visible, though if you detect a mouseclick anywhere on the page, and you have not gotten a response, then chances are it is not.
One workaround is to issue another getUserMedia call (through setTimeout or otherwise). It should not crash. If it does then please file a bug.
Another workaround is to programmatically refresh the page, using location.refresh().
If your site is not designed to work without a microphone, or you detect a user-action that suggests the user is stuck, then maybe something like "Waiting for permission to use the microphone. Please click the microphone icon in the URL bar to summon the permission dialog if it is not visible."

Related

Chrome Notification API (for Extensions!) How to Re-enable Once Blocked?

I have spent considerable time researching this and hopefully I have just missed something so I thought I would bounce it off the StackExchange community as well.
Background:
On latest Chrome > 65, all of the notifications are stores on a per-site basis, so if one were to grant or deny notification popup for a SITE and want to reverse that decision (accidentally clicked the "block" for example) they can simply go into Chrome notification settings, find that specific site, and remove the block. This works as designed today and is well documented.
So here is the issue detail in a scenario:
Now, that exact same mechanism is used for extensions. An extension is initially granted all it's required permissions and works properly. Then, the user accidentally clicks "block" one time on a single desktop notification from the extension using the "gears" cog-wheel icon on the notification which then changes the notify balloon to this prompt:
Now, any time that extension attempts to send a notify message, instead of the normal desktop notify, an ugly javascript notify pops up in the middle of the screen (with the exact same notify text), and two buttons - "OK" and "Cancel". All extension functionality is unchanged if "OK" is clicked for example, the very same functions fire as if the user had clicked the prior desktop notify balloon popup.
Here are two screenshots of this exact scenario using the popular Tampermonkey Chrome extension (using a randomly selected script with a known update) that uses desktop notification API to communicate script updates:
"Normal" desktop notify message with default grant permission:
The exact same message (appears in center of the screen) once that permission is revoked by user clicking "block". **Note the actual message itself is not blocked which I find odd, just the desktop notify GUI bubble:
So, the question is really 2-fold:
Where does Chrome store that boolean value of PermissionLevel FOR EXTENSIONS - as they do NOT appear in the normal list of granted/blocked SITES. If not in the UI, is this setting exposed in a configuration file or is there even currently any way in Chrome>65 for the user to ever reverse this decision?
Is there either a programmatic method that can be implemented by an extension developer on the back-end to ever check if this has occurred and re-prompt the user to change their mind and re-grant that permission? I have found a couple unofficial posts here saying common sense says no to avoid malicious harassing of users etc. but I cannot find anything official.
Well, I can confirm after opening this as an official Chromium bug, that it's sitting waiting for triage and clearly has no current workaround here:
https://bugs.chromium.org/p/chromium/issues/detail?id=825497
I also did further testing to determine you can use the ID from the extension and add it into "sites" settings which also based on that behavior, appears to be yet another bug due to some settings not saving, none having desired effect, etc.
I will post this as the current answer as of 04-09-2018:
"it is impossible to re-enable Chrome desktop notifications FOR A SPECIFIC EXTENSION once blocked".
If anyone can post here a successful workaround to in any way re-enable the normal desktop notifications for an extension (tested with Tampermonkey) after the user clicks the "block all notifications from this app" to simply reverse the decision that would be great but I think as long as this has remained unanswered makes me lean towards believing there simply is no current method and it is just a (glaring) UI bug.
Sadly the only method for reversing this is to remove the extension and re-install it.
This issue has been open for nearly half a year. Not expecting a fix any time soon at this point. https://bugs.chromium.org/p/chromium/issues/detail?id=825497
Please star this issue at the link above if you're affected by it.

periodically reload tab and bring to front

I have a requirement where a few users are required to keep a watch over a dashboard browser page.
My first thought was use some javascript magic that reloads the page, switches to it if it is not active and being the browser window to front. I quickly realized how difficult this (accept for reload) is and that browsers do everything possible to prevent it, with good reason.
On the other hand, I have err, seen some "websites" which show a pop-up telling me that my browser is affected and I need to call the given 800 number. These pop-ups are pretty much impossible to kill. I could use that if I knew how.
I have also considered utilities like ergociser which sit in the taskbar and open a browser window periodically. This could work but it opens a new pop-up window every time, while I am keen to reload it in the same window.
The closest I have come so far is to use alert which does not bring the window to front but it does flash the taskbar.
I am thinking of a chrome extension or firefox add-on that brings named pop-up tab. But I am open to any other ideas. It can be a browser specific solution, and it is ok to require white-listing in pop-up blockers
What is a best way to do this?
UPDATE
There are two close votes for "Too Broad". It is true that I am looking for the right technology to use for this problem, so I cannot refine it with technology-specific details. But short of that, appreciate if someone can give suggestion for narrowing down the problem statement.

Detecting if the user browser closes the browser

I have a website with master page. I want to catch a user trying to close the browser/tab. When I try using onunload in the body tag, it fires not only when I try closing the browser, but also when I navigate to another page.
Any idea how to only catch the event of closing the browser?
That is not possible. Javascript can only determine if the page you're on closes. If Javascript could determine whether other tabs and windows you're on closed, for example knowing if you closed down Facebook or Flyspray, that would be a major security risk. That's now how javascript works.
I am working with a secure wizzard online, that will save data through the process, and I needed to detect wether the client closed the tab and/or the browser, so far everything was going allright until I clicked the "continue" button to proceed to the next step, it threw me the same message, I've done quite some research on this and there is no way I'll be able to ignore the unload event that occurs when I navigate away from the pagethrough a link.
I tried to use the
if(window.event.clientY < 0 && window.event.clientX < 0){
alert('holy damn! the window is closing!')
};
and some other methods that are around the web. none of them will be able to detect only the browser closing. So as far as my research has advanced, there is no way to do this.

JavaScript Trigger window.open When a User Clicks Anywhere on Page

I have a problem that I have been trying to figure out and haven't been able to get past it because Chrome/FireFox/IE do not publicly publish their "rules" for pop up blocking when it comes to JavaScript, Flash, etc. I am trying to trigger a window.open() when a user clicks anywhere on page. I've tried this:
document.onclick = window.open("http://msn.com");
But all 3 browsers are blocking the popup, even though it is a user interaction.
If the user is blocking pop-ups, it's because they don't want popups like yours to appear as a response to their user interactions. If a popup (as opposed to something more sophisticated such as making an otherwise hidden div appear) is what you really must have, then inform the user that they need to enable popups to interact with your site (I've seen a few sites do that, that annoys me and I count it as a big black mark against the site that prompts me to look for their competitors and alternatives, but if there's no real alternative I'll grit my teeth and temporarily re-enable popups in such cases). (But, do consider that annoying users is not a way to win their hearts and minds, so do look for nicer alternatives!-).

Creating a notification system using a firefox extension

I am creating a firefox extension that should give a notification when the user hits specific sites. I do not want the same kind of notification that firefox gives for pop-ups. I don't want the user to have to go through the hassle of clicking the X in order to close the notification. Instead, I would like it to look like what happens when a normal firefox download is completed - a notification comes up, and automatically goes after a few seconds. On a mac, it looks like a growl notification, and I love the way it looks. Is there an easy way to implement this feature?
Thanks
I think you want this type of notification.
I'm not sure how to implement "Download Complete" type one - but since entire FF AFAIK is implemented in XUL, probably it's doable.
I have found the following:
chrome://global/content/alerts/alert.xul F Window used for stuff like "download complete" that shows in lower right
Haowever, if you don't find a way to do that, why not implement banner-notifications, the way StackOverflow does? They are not obtrusive as far as site functionality, don't require extra work to get rid of (well, SO ones do but you can rig yours to automatically fade away after a time), and very visible/noticeable with the right styling.

Categories

Resources