Bug 1360715 - Part 1: Hide @@hasInstance for IDL interfaces behind a flag r=edgar

Differential Revision: https://phabricator.services.mozilla.com/D106661
This commit is contained in:
Kagami Sascha Rosylight 2021-03-04 22:03:57 +00:00
Родитель 451f185db7
Коммит 933c060bcd
3 изменённых файлов: 16 добавлений и 13 удалений

Просмотреть файл

@ -837,13 +837,16 @@ static JSObject* CreateInterfaceObject(
if (DOMIfaceAndProtoJSClass::FromJSClass(constructorClass)
->wantsInterfaceHasInstance) {
JS::Rooted<jsid> hasInstanceId(cx, SYMBOL_TO_JSID(JS::GetWellKnownSymbol(
cx, JS::SymbolCode::hasInstance)));
if (!JS_DefineFunctionById(
cx, constructor, hasInstanceId, InterfaceHasInstance, 1,
// Flags match those of Function[Symbol.hasInstance]
JSPROP_READONLY | JSPROP_PERMANENT)) {
return nullptr;
if (isChrome ||
StaticPrefs::dom_webidl_crosscontext_hasinstance_enabled()) {
JS::Rooted<jsid> hasInstanceId(cx, SYMBOL_TO_JSID(JS::GetWellKnownSymbol(
cx, JS::SymbolCode::hasInstance)));
if (!JS_DefineFunctionById(
cx, constructor, hasInstanceId, InterfaceHasInstance, 1,
// Flags match those of Function[Symbol.hasInstance]
JSPROP_READONLY | JSPROP_PERMANENT)) {
return nullptr;
}
}
if (isChrome && !JS_DefineFunction(cx, constructor, "isInstance",

Просмотреть файл

@ -3513,6 +3513,11 @@
value: true
mirror: always
- name: dom.webidl.crosscontext_hasinstance.enabled
type: RelaxedAtomicBool
value: @IS_NOT_NIGHTLY_BUILD@
mirror: always
# WebShare API - exposes navigator.share()
- name: dom.webshare.enabled
type: bool

Просмотреть файл

@ -1,7 +1,2 @@
[has-instance.html]
[instanceof must return false across different globals, for platform objects]
expected: FAIL
[platform objects do not have Symbol.hasInstance installed]
expected: FAIL
prefs: [dom.webidl.crosscontext_hasinstance.enabled:false]