Modified: trunk/JSTests/ChangeLog (262907 => 262908)
--- trunk/JSTests/ChangeLog 2020-06-11 17:16:09 UTC (rev 262907)
+++ trunk/JSTests/ChangeLog 2020-06-11 17:23:56 UTC (rev 262908)
@@ -1,3 +1,12 @@
+2020-06-11 Alexey Shvayka <[email protected]>
+
+ RegExp.prototype getters should throw on cross-realm access
+ https://bugs.webkit.org/show_bug.cgi?id=213075
+
+ Reviewed by Saam Barati.
+
+ * test262/expectations.yaml: Mark 14 test cases as passing.
+
2020-06-10 Ross Kirsling <[email protected]>
REGRESSION(r260697): [Intl] "missing script" locales like zh-TW are no longer mapped
Modified: trunk/JSTests/test262/expectations.yaml (262907 => 262908)
--- trunk/JSTests/test262/expectations.yaml 2020-06-11 17:16:09 UTC (rev 262907)
+++ trunk/JSTests/test262/expectations.yaml 2020-06-11 17:23:56 UTC (rev 262908)
@@ -1435,30 +1435,9 @@
test/built-ins/RegExp/prototype/Symbol.split/u-lastindex-adv-thru-failure.js:
default: 'Test262Error: Expected SameValue(«2», «1») to be true'
strict mode: 'Test262Error: Expected SameValue(«2», «1») to be true'
-test/built-ins/RegExp/prototype/dotAll/cross-realm.js:
- default: 'Test262Error: cross-realm RegExp.prototype Expected a TypeError to be thrown but no exception was thrown at all'
- strict mode: 'Test262Error: cross-realm RegExp.prototype Expected a TypeError to be thrown but no exception was thrown at all'
test/built-ins/RegExp/prototype/exec/u-lastindex-adv.js:
default: 'Test262Error: Expected SameValue(«�», «null») to be true'
strict mode: 'Test262Error: Expected SameValue(«�», «null») to be true'
-test/built-ins/RegExp/prototype/global/cross-realm.js:
- default: 'Test262Error: cross-realm RegExp.prototype Expected a TypeError to be thrown but no exception was thrown at all'
- strict mode: 'Test262Error: cross-realm RegExp.prototype Expected a TypeError to be thrown but no exception was thrown at all'
-test/built-ins/RegExp/prototype/ignoreCase/cross-realm.js:
- default: 'Test262Error: cross-realm RegExp.prototype Expected a TypeError to be thrown but no exception was thrown at all'
- strict mode: 'Test262Error: cross-realm RegExp.prototype Expected a TypeError to be thrown but no exception was thrown at all'
-test/built-ins/RegExp/prototype/multiline/cross-realm.js:
- default: 'Test262Error: cross-realm RegExp.prototype Expected a TypeError to be thrown but no exception was thrown at all'
- strict mode: 'Test262Error: cross-realm RegExp.prototype Expected a TypeError to be thrown but no exception was thrown at all'
-test/built-ins/RegExp/prototype/source/cross-realm.js:
- default: 'Test262Error: cross-realm RegExp.prototype Expected a TypeError to be thrown but no exception was thrown at all'
- strict mode: 'Test262Error: cross-realm RegExp.prototype Expected a TypeError to be thrown but no exception was thrown at all'
-test/built-ins/RegExp/prototype/sticky/cross-realm.js:
- default: 'Test262Error: cross-realm RegExp.prototype Expected a TypeError to be thrown but no exception was thrown at all'
- strict mode: 'Test262Error: cross-realm RegExp.prototype Expected a TypeError to be thrown but no exception was thrown at all'
-test/built-ins/RegExp/prototype/unicode/cross-realm.js:
- default: 'Test262Error: cross-realm RegExp.prototype Expected a TypeError to be thrown but no exception was thrown at all'
- strict mode: 'Test262Error: cross-realm RegExp.prototype Expected a TypeError to be thrown but no exception was thrown at all'
test/built-ins/RegExp/quantifier-integer-limit.js:
default: 'SyntaxError: Invalid regular _expression_: number too large in {} quantifier'
strict mode: 'SyntaxError: Invalid regular _expression_: number too large in {} quantifier'
Modified: trunk/Source/_javascript_Core/ChangeLog (262907 => 262908)
--- trunk/Source/_javascript_Core/ChangeLog 2020-06-11 17:16:09 UTC (rev 262907)
+++ trunk/Source/_javascript_Core/ChangeLog 2020-06-11 17:23:56 UTC (rev 262908)
@@ -1,3 +1,27 @@
+2020-06-11 Alexey Shvayka <[email protected]>
+
+ RegExp.prototype getters should throw on cross-realm access
+ https://bugs.webkit.org/show_bug.cgi?id=213075
+
+ Reviewed by Saam Barati.
+
+ This patch makes RegExp.prototype getters throw TypeError when called on
+ RegExp.prototype object from another realm, aligning JSC with V8 and SpiderMonkey.
+
+ The spec [1] allows same-realm access to avoid breaking the web, while makes
+ RegExp.prototype an ordinary object (rather than RegExp instance) where possible.
+
+ [1]: https://tc39.es/ecma262/#sec-get-regexp.prototype.global (step 3.a)
+
+ * runtime/RegExpPrototype.cpp:
+ (JSC::regExpProtoGetterGlobal):
+ (JSC::regExpProtoGetterIgnoreCase):
+ (JSC::regExpProtoGetterMultiline):
+ (JSC::regExpProtoGetterDotAll):
+ (JSC::regExpProtoGetterSticky):
+ (JSC::regExpProtoGetterUnicode):
+ (JSC::regExpProtoGetterSource):
+
2020-06-11 Paulo Matos <[email protected]>
Add missing include to JSONObject.cpp - non-unified build
Modified: trunk/Source/_javascript_Core/runtime/RegExpPrototype.cpp (262907 => 262908)
--- trunk/Source/_javascript_Core/runtime/RegExpPrototype.cpp 2020-06-11 17:16:09 UTC (rev 262907)
+++ trunk/Source/_javascript_Core/runtime/RegExpPrototype.cpp 2020-06-11 17:23:56 UTC (rev 262908)
@@ -239,7 +239,7 @@
JSValue thisValue = callFrame->thisValue();
auto* regexp = jsDynamicCast<RegExpObject*>(vm, thisValue);
if (UNLIKELY(!regexp)) {
- if (thisValue.inherits<RegExpPrototype>(vm))
+ if (thisValue == globalObject->regExpPrototype())
return JSValue::encode(jsUndefined());
return throwVMTypeError(globalObject, scope, "The RegExp.prototype.global getter can only be called on a RegExp object"_s);
}
@@ -255,7 +255,7 @@
JSValue thisValue = callFrame->thisValue();
auto* regexp = jsDynamicCast<RegExpObject*>(vm, thisValue);
if (UNLIKELY(!regexp)) {
- if (thisValue.inherits<RegExpPrototype>(vm))
+ if (thisValue == globalObject->regExpPrototype())
return JSValue::encode(jsUndefined());
return throwVMTypeError(globalObject, scope, "The RegExp.prototype.ignoreCase getter can only be called on a RegExp object"_s);
}
@@ -271,7 +271,7 @@
JSValue thisValue = callFrame->thisValue();
auto* regexp = jsDynamicCast<RegExpObject*>(vm, thisValue);
if (UNLIKELY(!regexp)) {
- if (thisValue.inherits<RegExpPrototype>(vm))
+ if (thisValue == globalObject->regExpPrototype())
return JSValue::encode(jsUndefined());
return throwVMTypeError(globalObject, scope, "The RegExp.prototype.multiline getter can only be called on a RegExp object"_s);
}
@@ -287,7 +287,7 @@
JSValue thisValue = callFrame->thisValue();
auto* regexp = jsDynamicCast<RegExpObject*>(vm, thisValue);
if (UNLIKELY(!regexp)) {
- if (thisValue.inherits<RegExpPrototype>(vm))
+ if (thisValue == globalObject->regExpPrototype())
return JSValue::encode(jsUndefined());
return throwVMTypeError(globalObject, scope, "The RegExp.prototype.dotAll getter can only be called on a RegExp object"_s);
}
@@ -303,7 +303,7 @@
JSValue thisValue = callFrame->thisValue();
auto* regexp = jsDynamicCast<RegExpObject*>(vm, thisValue);
if (UNLIKELY(!regexp)) {
- if (thisValue.inherits<RegExpPrototype>(vm))
+ if (thisValue == globalObject->regExpPrototype())
return JSValue::encode(jsUndefined());
return throwVMTypeError(globalObject, scope, "The RegExp.prototype.sticky getter can only be called on a RegExp object"_s);
}
@@ -319,7 +319,7 @@
JSValue thisValue = callFrame->thisValue();
auto* regexp = jsDynamicCast<RegExpObject*>(vm, thisValue);
if (UNLIKELY(!regexp)) {
- if (thisValue.inherits<RegExpPrototype>(vm))
+ if (thisValue == globalObject->regExpPrototype())
return JSValue::encode(jsUndefined());
return throwVMTypeError(globalObject, scope, "The RegExp.prototype.unicode getter can only be called on a RegExp object"_s);
}
@@ -457,7 +457,7 @@
JSValue thisValue = callFrame->thisValue();
auto* regexp = jsDynamicCast<RegExpObject*>(vm, thisValue);
if (UNLIKELY(!regexp)) {
- if (thisValue.inherits<RegExpPrototype>(vm))
+ if (thisValue == globalObject->regExpPrototype())
return JSValue::encode(jsNontrivialString(vm, "(?:)"_s));
return throwVMTypeError(globalObject, scope, "The RegExp.prototype.source getter can only be called on a RegExp object"_s);
}