Title: [198698] trunk
- Revision
- 198698
- Author
- [email protected]
- Date
- 2016-03-25 16:23:17 -0700 (Fri, 25 Mar 2016)
Log Message
ES6's throwing of TypeErrors on access of RegExp.prototype flag properties breaks websites.
https://bugs.webkit.org/show_bug.cgi?id=155904
Reviewed by Geoffrey Garen.
Source/_javascript_Core:
There exists a JS library XRegExp (see http://xregexp.com) that extends the regexp
implementation. XRegExp does feature testing by comparing RegExp.prototype.sticky
to undefined. See:
Example 1. https://github.com/slevithan/xregexp/blob/28a2b033c5951477bed8c7c867ddf7e89c431cd4/tests/perf/index.html
...
} else if (knownVersion[version]) {
// Hack around ES6 incompatibility in XRegExp versions prior to 3.0.0
if (parseInt(version, 10) < 3) {
delete RegExp.prototype.sticky;
}
...
Example 2. https://github.com/slevithan/xregexp/blob/d0e665d4068cec4d15919215b098b2373f1f12e9/tests/perf/versions/xregexp-all-v2.0.0.js
...
// Check for flag y support (Firefox 3+)
hasNativeY = RegExp.prototype.sticky !== undef,
...
The ES6 spec states that we should throw a TypeError here because RegExp.prototype
is not a RegExp object, and the sticky getter is only allowed to be called on
RegExp objects. See https://tc39.github.io/ecma262/2016/#sec-get-regexp.prototype.sticky.
As a result, websites that uses XRegExp can break (e.g. some Atlassian tools).
As a workaround, we'll return undefined instead of throwing on access of these
flag properties that may be used for feature testing.
* runtime/RegExpPrototype.cpp:
(JSC::regExpProtoGetterGlobal):
(JSC::regExpProtoGetterIgnoreCase):
(JSC::regExpProtoGetterMultiline):
(JSC::regExpProtoGetterSticky):
(JSC::regExpProtoGetterUnicode):
LayoutTests:
* ietestcenter/_javascript_/TestCases/15.10.7.2-1.js:
(ES5Harness.registerTest.test):
* ietestcenter/_javascript_/TestCases/15.10.7.3-1.js:
(ES5Harness.registerTest.test):
* ietestcenter/_javascript_/TestCases/15.10.7.4-1.js:
(ES5Harness.registerTest.test):
- updated these tests to not expect a TypeError due to the workaround.
* js/pic/cached-named-property-getter.html:
- updated this test to use the source property (which still throws a TypeError)
instead of the ignoreCase property which no longer does.
Modified Paths
Diff
Modified: trunk/LayoutTests/ChangeLog (198697 => 198698)
--- trunk/LayoutTests/ChangeLog 2016-03-25 23:15:03 UTC (rev 198697)
+++ trunk/LayoutTests/ChangeLog 2016-03-25 23:23:17 UTC (rev 198698)
@@ -1,3 +1,22 @@
+2016-03-25 Mark Lam <[email protected]>
+
+ ES6's throwing of TypeErrors on access of RegExp.prototype flag properties breaks websites.
+ https://bugs.webkit.org/show_bug.cgi?id=155904
+
+ Reviewed by Geoffrey Garen.
+
+ * ietestcenter/_javascript_/TestCases/15.10.7.2-1.js:
+ (ES5Harness.registerTest.test):
+ * ietestcenter/_javascript_/TestCases/15.10.7.3-1.js:
+ (ES5Harness.registerTest.test):
+ * ietestcenter/_javascript_/TestCases/15.10.7.4-1.js:
+ (ES5Harness.registerTest.test):
+ - updated these tests to not expect a TypeError due to the workaround.
+
+ * js/pic/cached-named-property-getter.html:
+ - updated this test to use the source property (which still throws a TypeError)
+ instead of the ignoreCase property which no longer does.
+
2016-03-25 Ryan Haddad <[email protected]>
Marking compositing/repaint/become-overlay-composited-layer.html as flaky on ios-sim-wk2
Modified: trunk/LayoutTests/ietestcenter/_javascript_/TestCases/15.10.7.2-1.js (198697 => 198698)
--- trunk/LayoutTests/ietestcenter/_javascript_/TestCases/15.10.7.2-1.js 2016-03-25 23:15:03 UTC (rev 198697)
+++ trunk/LayoutTests/ietestcenter/_javascript_/TestCases/15.10.7.2-1.js 2016-03-25 23:23:17 UTC (rev 198698)
@@ -27,11 +27,8 @@
description: "RegExp.prototype.global should throw because RegExp.prototype is not a RegExp",
test: function testcase() {
- try {
- RegExp.prototype.global;
- return false;
- } catch (e) {
+ if ((typeof(RegExp.prototype.global)) === 'undefined')
return true;
- }
+ return false;
}
});
Modified: trunk/LayoutTests/ietestcenter/_javascript_/TestCases/15.10.7.3-1.js (198697 => 198698)
--- trunk/LayoutTests/ietestcenter/_javascript_/TestCases/15.10.7.3-1.js 2016-03-25 23:15:03 UTC (rev 198697)
+++ trunk/LayoutTests/ietestcenter/_javascript_/TestCases/15.10.7.3-1.js 2016-03-25 23:23:17 UTC (rev 198698)
@@ -27,11 +27,8 @@
description: "RegExp.prototype.ignoreCase should throw because RegExp.prototype is not a RegExp",
test: function testcase() {
- try {
- RegExp.prototype.ignoreCase;
- return false;
- } catch (e) {
+ if ((typeof(RegExp.prototype.ignoreCase)) === 'undefined')
return true;
- }
+ return false;
}
});
Modified: trunk/LayoutTests/ietestcenter/_javascript_/TestCases/15.10.7.4-1.js (198697 => 198698)
--- trunk/LayoutTests/ietestcenter/_javascript_/TestCases/15.10.7.4-1.js 2016-03-25 23:15:03 UTC (rev 198697)
+++ trunk/LayoutTests/ietestcenter/_javascript_/TestCases/15.10.7.4-1.js 2016-03-25 23:23:17 UTC (rev 198698)
@@ -27,11 +27,8 @@
description: "RegExp.prototype.multiline should throw because RegExp.prototype is not a RegExp",
test: function testcase() {
- try {
- RegExp.prototype.multiline;
- return false;
- } catch (e) {
+ if ((typeof(RegExp.prototype.multiline)) === 'undefined')
return true;
- }
+ return false;
}
});
Modified: trunk/LayoutTests/js/pic/cached-named-property-getter.html (198697 => 198698)
--- trunk/LayoutTests/js/pic/cached-named-property-getter.html 2016-03-25 23:15:03 UTC (rev 198697)
+++ trunk/LayoutTests/js/pic/cached-named-property-getter.html 2016-03-25 23:23:17 UTC (rev 198698)
@@ -64,7 +64,7 @@
function testCustomGetter(o) {
for (var i = 0; i < 10; i++)
- o.ignoreCase;
+ o.source;
}
var r=/a/;
testCustomGetter(r);
Modified: trunk/Source/_javascript_Core/ChangeLog (198697 => 198698)
--- trunk/Source/_javascript_Core/ChangeLog 2016-03-25 23:15:03 UTC (rev 198697)
+++ trunk/Source/_javascript_Core/ChangeLog 2016-03-25 23:23:17 UTC (rev 198698)
@@ -1,3 +1,44 @@
+2016-03-25 Mark Lam <[email protected]>
+
+ ES6's throwing of TypeErrors on access of RegExp.prototype flag properties breaks websites.
+ https://bugs.webkit.org/show_bug.cgi?id=155904
+
+ Reviewed by Geoffrey Garen.
+
+ There exists a JS library XRegExp (see http://xregexp.com) that extends the regexp
+ implementation. XRegExp does feature testing by comparing RegExp.prototype.sticky
+ to undefined. See:
+
+ Example 1. https://github.com/slevithan/xregexp/blob/28a2b033c5951477bed8c7c867ddf7e89c431cd4/tests/perf/index.html
+ ...
+ } else if (knownVersion[version]) {
+ // Hack around ES6 incompatibility in XRegExp versions prior to 3.0.0
+ if (parseInt(version, 10) < 3) {
+ delete RegExp.prototype.sticky;
+ }
+ ...
+
+ Example 2. https://github.com/slevithan/xregexp/blob/d0e665d4068cec4d15919215b098b2373f1f12e9/tests/perf/versions/xregexp-all-v2.0.0.js
+ ...
+ // Check for flag y support (Firefox 3+)
+ hasNativeY = RegExp.prototype.sticky !== undef,
+ ...
+
+ The ES6 spec states that we should throw a TypeError here because RegExp.prototype
+ is not a RegExp object, and the sticky getter is only allowed to be called on
+ RegExp objects. See https://tc39.github.io/ecma262/2016/#sec-get-regexp.prototype.sticky.
+ As a result, websites that uses XRegExp can break (e.g. some Atlassian tools).
+
+ As a workaround, we'll return undefined instead of throwing on access of these
+ flag properties that may be used for feature testing.
+
+ * runtime/RegExpPrototype.cpp:
+ (JSC::regExpProtoGetterGlobal):
+ (JSC::regExpProtoGetterIgnoreCase):
+ (JSC::regExpProtoGetterMultiline):
+ (JSC::regExpProtoGetterSticky):
+ (JSC::regExpProtoGetterUnicode):
+
2016-03-25 Caitlin Potter <[email protected]>
[JSC] fix divide-by-zero in String.prototype.padStart/padEnd
Modified: trunk/Source/_javascript_Core/runtime/RegExpPrototype.cpp (198697 => 198698)
--- trunk/Source/_javascript_Core/runtime/RegExpPrototype.cpp 2016-03-25 23:15:03 UTC (rev 198697)
+++ trunk/Source/_javascript_Core/runtime/RegExpPrototype.cpp 2016-03-25 23:23:17 UTC (rev 198698)
@@ -245,7 +245,7 @@
{
JSValue thisValue = exec->thisValue();
if (!thisValue.inherits(RegExpObject::info()))
- return throwVMTypeError(exec);
+ return JSValue::encode(jsUndefined());
return JSValue::encode(jsBoolean(asRegExpObject(thisValue)->regExp()->global()));
}
@@ -254,7 +254,7 @@
{
JSValue thisValue = exec->thisValue();
if (!thisValue.inherits(RegExpObject::info()))
- return throwVMTypeError(exec);
+ return JSValue::encode(jsUndefined());
return JSValue::encode(jsBoolean(asRegExpObject(thisValue)->regExp()->ignoreCase()));
}
@@ -263,7 +263,7 @@
{
JSValue thisValue = exec->thisValue();
if (!thisValue.inherits(RegExpObject::info()))
- return throwVMTypeError(exec);
+ return JSValue::encode(jsUndefined());
return JSValue::encode(jsBoolean(asRegExpObject(thisValue)->regExp()->multiline()));
}
@@ -272,7 +272,7 @@
{
JSValue thisValue = exec->thisValue();
if (!thisValue.inherits(RegExpObject::info()))
- return throwVMTypeError(exec);
+ return JSValue::encode(jsUndefined());
return JSValue::encode(jsBoolean(asRegExpObject(thisValue)->regExp()->sticky()));
}
@@ -281,7 +281,7 @@
{
JSValue thisValue = exec->thisValue();
if (!thisValue.inherits(RegExpObject::info()))
- return throwVMTypeError(exec);
+ return JSValue::encode(jsUndefined());
return JSValue::encode(jsBoolean(asRegExpObject(thisValue)->regExp()->unicode()));
}
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes