New issue
Advanced search Search tips
Note: Color blocks (like or ) mean that a user may not be available. Tooltip shows the reason.

Issue 717016 link

Starred by 5 users

Issue metadata

Status: WontFix
Owner: ----
Closed: May 2017
Cc:
Components:
EstimatedDays: ----
NextAction: ----
OS: All
Pri: 3
Type: Bug



Sign in to add a comment

instanceof behavior cross-contexts doesn't match spec/Firefox

Project Member Reported by rbyers@chromium.org, May 1 2017

Issue description

Load this page: http://jsbin.com/yefesuv which basically does:
new MouseEvent("click") instanceof iframe.contentWindow.MouseEvent

Chrome (and Edge and Safari) return false, and Firefox returns true.

I initially assumed this was a Firefox bug so filed https://bugzilla.mozilla.org/show_bug.cgi?id=1360715 but Boris set me straight there.  This is covered by the WebIDL spec:

https://heycam.github.io/webidl/#es-interface-hasinstance

It seems like we've been locked in debate for years on this.  Ideally I think the blink bindings team should drive either:
1) Making our implementation match Firefox, or
2) Getting a WebIDL spec change to match the other implementations (which may require having another good answer to issues like  bug 716423 ).

Note MDN has some documentation about this:  https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/instanceof#instanceof_and_multiple_context_(e.g._frames_or_windows)

 
Cc: rbyers@chromium.org
 Issue 716423  has been merged into this issue.
FWIW, I'm not an expert in this space but from what I've read/experienced my opinion is that (assuming it's not too hard to do efficiently) we should just match Firefox and the spec here.  Most important is reducing surprise for developers and  issue 716423  highlights how the Firefox behavior is really what developers are likely to expect here.
Cc: domenic@chromium.org
Previous discussion with Blink bindings folks: https://groups.google.com/a/chromium.org/forum/#!msg/blink-reviews-bindings/6qzaSWen21c/OU792ZXFAwAJ

Open spec issue: https://github.com/heycam/webidl/issues/129

Given the discussion there (in particular performance implications in engines like v8), perhaps the best path forward is to define some new API (implemented consistently by WebIDL) developers can explicitly opt into using in cases like  issue 716423 ?  If that would address the use case, then hopefully we could get Firefox to match everyone else in terms of instanceof behavior?
There was also a discussion on the internal chrome-platform-architecture-team list that goes into some detail (subject is "Web IDL brand-checking API", for those with access).
Status: WontFix (was: Untriaged)
The spec has been fixed to match reality (3/4 browsers) and Firefox has a bug filed to update to match the new spec:

- https://github.com/heycam/webidl/pull/356
- https://bugzilla.mozilla.org/show_bug.cgi?id=1360715

As such we can close this now as WontFix. Thanks to  matthijs.wessels@gmail.com in  bug 716423  for providing the spur we needed to get this sorted out!
Cc: susan.boorgula@chromium.org
 Issue 850007  has been merged into this issue.

Sign in to add a comment