MS Edge has a window.chrome object?? Breaks browser detection

"you should be checking features not browsers"

Spoken like someone who has never encountered a feature that exists in multiple browsers but does not function, or function the same, in all browsers it appears in.

My own recent case, I had a small function that has worked in all browsers for at least 12 years, since before Chrome even existed. The function just fires off a custom url which is registered on the client OS to run an external handler. So it just launches the custom url in a child _blank window and immediately closes it that child window.

function foo(stuff,otherstuff) {
  t = window.open("myproto://"+stuff,"_blank");
  t.close();
  window.location.replace("path/to/...?"+otherstuff);
}

Chrome, and only Chrome, and only recently sometime in late 2016 or so, changed window.open() so that it no longer blocks, so now to work around that I have to do:

t = window.open("myproto://"+stuff,"_blank");
t.addEventListener('load',t.close());

Ok, not the end of the world, except, not all browsers have that function...

Wait, wait don't tell me... "Test for the FEATURE!!!!"

Why didn't I think of that? Maybe because, guess what, Edge HAS the feature, and it DOESN'T behave properly.

So here I am googling for ways to detect Chrome, BY NAME, FOR A REASON.

Should I not only test for the existence of the feature, but also construct some kind of test that actually tries to invoke the feature, to see if it worked right? The thing I'm testing happens to be window opening and closing behavior. I can't be popping up junk windows, that then get stuck and don't close themselves, every time the damned page loads, or every time the user clicks on the damned button that needs the feature...

and if !!window.chrome is no longer viable because once again Edge, then I'm back to THIS utter buffoonery I guess:

var is_chrome = navigator.userAgent.toLowerCase().indexOf('chrome') > -1;

I know you have marked the above answer but if you really want to detect Google Chrome browser by Google, I will suggest you to use something like this:

var isChrome = /Chrome/.test(navigator.userAgent) && /Google Inc/.test(navigator.vendor);