Changeset 198698 in webkit
- Timestamp:
- Mar 25, 2016, 4:23:17 PM (9 years ago)
- Location:
- trunk
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r198689 r198698 1 2016-03-25 Mark Lam <mark.lam@apple.com> 2 3 ES6's throwing of TypeErrors on access of RegExp.prototype flag properties breaks websites. 4 https://bugs.webkit.org/show_bug.cgi?id=155904 5 6 Reviewed by Geoffrey Garen. 7 8 * ietestcenter/Javascript/TestCases/15.10.7.2-1.js: 9 (ES5Harness.registerTest.test): 10 * ietestcenter/Javascript/TestCases/15.10.7.3-1.js: 11 (ES5Harness.registerTest.test): 12 * ietestcenter/Javascript/TestCases/15.10.7.4-1.js: 13 (ES5Harness.registerTest.test): 14 - updated these tests to not expect a TypeError due to the workaround. 15 16 * js/pic/cached-named-property-getter.html: 17 - updated this test to use the source property (which still throws a TypeError) 18 instead of the ignoreCase property which no longer does. 19 1 20 2016-03-25 Ryan Haddad <ryanhaddad@apple.com> 2 21 -
trunk/LayoutTests/ietestcenter/Javascript/TestCases/15.10.7.2-1.js
r198447 r198698 28 28 29 29 test: function testcase() { 30 try { 31 RegExp.prototype.global; 32 return false; 33 } catch (e) { 30 if ((typeof(RegExp.prototype.global)) === 'undefined') 34 31 return true; 35 }32 return false; 36 33 } 37 34 }); -
trunk/LayoutTests/ietestcenter/Javascript/TestCases/15.10.7.3-1.js
r198447 r198698 28 28 29 29 test: function testcase() { 30 try { 31 RegExp.prototype.ignoreCase; 32 return false; 33 } catch (e) { 30 if ((typeof(RegExp.prototype.ignoreCase)) === 'undefined') 34 31 return true; 35 }32 return false; 36 33 } 37 34 }); -
trunk/LayoutTests/ietestcenter/Javascript/TestCases/15.10.7.4-1.js
r198447 r198698 28 28 29 29 test: function testcase() { 30 try { 31 RegExp.prototype.multiline; 32 return false; 33 } catch (e) { 30 if ((typeof(RegExp.prototype.multiline)) === 'undefined') 34 31 return true; 35 }32 return false; 36 33 } 37 34 }); -
trunk/LayoutTests/js/pic/cached-named-property-getter.html
r185370 r198698 65 65 function testCustomGetter(o) { 66 66 for (var i = 0; i < 10; i++) 67 o. ignoreCase;67 o.source; 68 68 } 69 69 var r=/a/; -
trunk/Source/JavaScriptCore/ChangeLog
r198695 r198698 1 2016-03-25 Mark Lam <mark.lam@apple.com> 2 3 ES6's throwing of TypeErrors on access of RegExp.prototype flag properties breaks websites. 4 https://bugs.webkit.org/show_bug.cgi?id=155904 5 6 Reviewed by Geoffrey Garen. 7 8 There exists a JS library XRegExp (see http://xregexp.com) that extends the regexp 9 implementation. XRegExp does feature testing by comparing RegExp.prototype.sticky 10 to undefined. See: 11 12 Example 1. https://github.com/slevithan/xregexp/blob/28a2b033c5951477bed8c7c867ddf7e89c431cd4/tests/perf/index.html 13 ... 14 } else if (knownVersion[version]) { 15 // Hack around ES6 incompatibility in XRegExp versions prior to 3.0.0 16 if (parseInt(version, 10) < 3) { 17 delete RegExp.prototype.sticky; 18 } 19 ... 20 21 Example 2. https://github.com/slevithan/xregexp/blob/d0e665d4068cec4d15919215b098b2373f1f12e9/tests/perf/versions/xregexp-all-v2.0.0.js 22 ... 23 // Check for flag y support (Firefox 3+) 24 hasNativeY = RegExp.prototype.sticky !== undef, 25 ... 26 27 The ES6 spec states that we should throw a TypeError here because RegExp.prototype 28 is not a RegExp object, and the sticky getter is only allowed to be called on 29 RegExp objects. See https://tc39.github.io/ecma262/2016/#sec-get-regexp.prototype.sticky. 30 As a result, websites that uses XRegExp can break (e.g. some Atlassian tools). 31 32 As a workaround, we'll return undefined instead of throwing on access of these 33 flag properties that may be used for feature testing. 34 35 * runtime/RegExpPrototype.cpp: 36 (JSC::regExpProtoGetterGlobal): 37 (JSC::regExpProtoGetterIgnoreCase): 38 (JSC::regExpProtoGetterMultiline): 39 (JSC::regExpProtoGetterSticky): 40 (JSC::regExpProtoGetterUnicode): 41 1 42 2016-03-25 Caitlin Potter <caitp@igalia.com> 2 43 -
trunk/Source/JavaScriptCore/runtime/RegExpPrototype.cpp
r198554 r198698 246 246 JSValue thisValue = exec->thisValue(); 247 247 if (!thisValue.inherits(RegExpObject::info())) 248 return throwVMTypeError(exec);248 return JSValue::encode(jsUndefined()); 249 249 250 250 return JSValue::encode(jsBoolean(asRegExpObject(thisValue)->regExp()->global())); … … 255 255 JSValue thisValue = exec->thisValue(); 256 256 if (!thisValue.inherits(RegExpObject::info())) 257 return throwVMTypeError(exec);257 return JSValue::encode(jsUndefined()); 258 258 259 259 return JSValue::encode(jsBoolean(asRegExpObject(thisValue)->regExp()->ignoreCase())); … … 264 264 JSValue thisValue = exec->thisValue(); 265 265 if (!thisValue.inherits(RegExpObject::info())) 266 return throwVMTypeError(exec);266 return JSValue::encode(jsUndefined()); 267 267 268 268 return JSValue::encode(jsBoolean(asRegExpObject(thisValue)->regExp()->multiline())); … … 273 273 JSValue thisValue = exec->thisValue(); 274 274 if (!thisValue.inherits(RegExpObject::info())) 275 return throwVMTypeError(exec);275 return JSValue::encode(jsUndefined()); 276 276 277 277 return JSValue::encode(jsBoolean(asRegExpObject(thisValue)->regExp()->sticky())); … … 282 282 JSValue thisValue = exec->thisValue(); 283 283 if (!thisValue.inherits(RegExpObject::info())) 284 return throwVMTypeError(exec);284 return JSValue::encode(jsUndefined()); 285 285 286 286 return JSValue::encode(jsBoolean(asRegExpObject(thisValue)->regExp()->unicode()));
Note:
See TracChangeset
for help on using the changeset viewer.