instanceof behavior cross-contexts doesn't match spec/Firefox |
|||
Issue descriptionLoad 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)
,
May 1 2017
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.
,
May 1 2017
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?
,
May 1 2017
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).
,
May 4 2017
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!
,
Jul 5
|
|||
►
Sign in to add a comment |
|||
Comment 1 by rbyers@chromium.org
, May 1 2017