Note that for now code running with system principals still has the hasInstance hook, so instanceof will still return true there if the platform object and its interface's prototype object are from different realms. We do plan to align to the behaviour from the spec everywhere in the near future [1], but it involves fixing a lot of existing code/tests [2].

We added an isInstance() static function on interface objects as a way to do cross-realm branding checks a while back (only exposed in realms running with system principals) [3]. New code running with system principals that needs to do a cross-realm branding check should use for example 'Node.isInstance(foo)', as opposed to 'foo instanceof Node'.

Peter

[1] https://bugzilla.mozilla.org/show_bug.cgi?id=1695435
[2] https://treeherder.mozilla.org/jobs?repo=try&revision=c256674824c991dd3891889f613641a1a34e70bf
[3] https://bugzilla.mozilla.org/show_bug.cgi?id=1428531

On 04/03/2021 21:53, Kagami Rosylight wrote:
https://github.com/heycam/webidl/pull/356 removed custom hasInstance behavior 
in 2017, and the feature has only been shipped by Firefox.

Dropping the support means that JavaScript `instanceof` operator will return 
false when the contexts of the object and the constructor don't match, e.g. the 
object is from an iframe and the constructor is from the top window.

The change will initially be only on Nightly to make sure there won't be any 
significant breakages, and then will propagate to stable versions.

Tracking bug: https://bugzilla.mozilla.org/show_bug.cgi?id=1360715
WPT: https://wpt.live/WebIDL/ecmascript-binding/has-instance.html
Relevant flag: dom.webidl.crosscontext_hasinstance.enabled


_______________________________________________
dev-platform mailing list
dev-platform@lists.mozilla.org
https://lists.mozilla.org/listinfo/dev-platform

Reply via email to