Changeset 199545 in webkit
- Timestamp:
- Apr 14, 2016 11:16:35 AM (8 years ago)
- Location:
- trunk
- Files:
-
- 3 added
- 13 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r199544 r199545 1 2016-04-14 Mark Lam <mark.lam@apple.com> 2 3 Update treatment of invoking RegExp.prototype methods on RegExp.prototype. 4 https://bugs.webkit.org/show_bug.cgi?id=155922 5 6 Reviewed by Keith Miller. 7 8 * fast/regex/script-tests/toString.js: 9 * fast/regex/toString-expected.txt: 10 * ietestcenter/Javascript/15.10.7.1-1-expected.txt: 11 * ietestcenter/Javascript/TestCases/15.10.7.1-1.js: 12 (ES5Harness.registerTest.test): 13 * js/kde/RegExp-expected.txt: 14 * js/kde/script-tests/RegExp.js: 15 * js/pic/cached-named-property-getter.html: 16 * js/regexp-flags-expected.txt: 17 * js/script-tests/regexp-flags.js: 18 - updated test behaviors in some cases, and rebased results as needed. 19 20 * js/regress/regexp-prototype-is-not-instance-expected.txt: Added. 21 * js/regress/regexp-prototype-is-not-instance.html: Added. 22 * js/regress/script-tests/regexp-prototype-is-not-instance.js: Added. 23 - Tests new RegExp.prototype method behaviors. 24 25 1 26 2016-04-14 Frederic Wang <fwang@igalia.com> 2 27 -
trunk/LayoutTests/fast/regex/script-tests/toString.js
r198447 r199545 20 20 shouldBe("RegExp('/').source", '"\\\\/"'); 21 21 shouldBe("RegExp('').source", '"(?:)"'); 22 should Throw("RegExp.prototype.source", '"TypeError: Type error"');22 shouldBe("RegExp.prototype.source", '"(?:)"'); 23 23 24 24 shouldBe("RegExp('/').toString()", '"/\\\\//"'); 25 25 shouldBe("RegExp('').toString()", '"/(?:)/"'); 26 should Throw("RegExp.prototype.toString()", '"TypeError: Type error"');26 shouldBe("RegExp.prototype.toString()", '"/(?:)/"'); 27 27 28 28 // These strings are equivalent, since the '\' is identity escaping the '/' at the string level. -
trunk/LayoutTests/fast/regex/toString-expected.txt
r198447 r199545 6 6 PASS RegExp('/').source is "\\/" 7 7 PASS RegExp('').source is "(?:)" 8 PASS RegExp.prototype.source threw exception TypeError: Type error.8 PASS RegExp.prototype.source is "(?:)" 9 9 PASS RegExp('/').toString() is "/\\//" 10 10 PASS RegExp('').toString() is "/(?:)/" 11 PASS RegExp.prototype.toString() threw exception TypeError: Type error.11 PASS RegExp.prototype.toString() is "/(?:)/" 12 12 PASS testForwardSlash("^/$", "/"); is true 13 13 PASS testForwardSlash("^/$", "/"); is true -
trunk/LayoutTests/ietestcenter/Javascript/15.10.7.1-1-expected.txt
r198447 r199545 1 15.10.7.1-1 (TestCases/chapter15/15.10/15.10.7/15.10.7.1/15.10.7.1-1.js) RegExp.prototype.source should throw because RegExp.prototype is not a RegExp1 15.10.7.1-1 (TestCases/chapter15/15.10/15.10.7/15.10.7.1/15.10.7.1-1.js) RegExp.prototype.source should be '(?:)' 2 2 3 3 On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE". -
trunk/LayoutTests/ietestcenter/Javascript/TestCases/15.10.7.1-1.js
r198447 r199545 25 25 path: "TestCases/chapter15/15.10/15.10.7/15.10.7.1/15.10.7.1-1.js", 26 26 27 description: "RegExp.prototype.source should throw because RegExp.prototype is not a RegExp",27 description: "RegExp.prototype.source should be '(?:)'", 28 28 29 29 test: function testcase() { 30 try { 31 RegExp.prototype.source; 32 return false; 33 } catch (e) { 34 return true; 35 } 30 return RegExp.prototype.source === '(?:)'; 36 31 } 37 32 }); -
trunk/LayoutTests/js/kde/RegExp-expected.txt
r198447 r199545 92 92 PASS 'abc'.match(/\u0062/).toString() is 'b' 93 93 PASS Object.prototype.toString.apply(RegExp.prototype) is '[object Object]' 94 PASS RegExp.prototype.toString() threw exception TypeError: Type error.94 PASS RegExp.prototype.toString() is '/(?:)/' 95 95 PASS new RegExp().toString() is '/(?:)/' 96 96 PASS (new RegExp('(?:)')).source is '(?:)' -
trunk/LayoutTests/js/kde/script-tests/RegExp.js
r198447 r199545 148 148 // not sure what this should return. most importantly 149 149 // it doesn't throw an exception 150 should Throw("RegExp.prototype.toString()", "'TypeError: Type error'");150 shouldBe("RegExp.prototype.toString()", "'/(?:)/'"); 151 151 152 152 // Empty regular expressions have string representation /(?:)/ -
trunk/LayoutTests/js/pic/cached-named-property-getter.html
r198698 r199545 93 93 shouldThrow(function () { 94 94 testCustomGetter({__proto__: r}); 95 }, "TypeError: T ype error");95 }, "TypeError: The RegExp.prototype.source getter can only be called on a RegExp object"); 96 96 shouldThrow(function () { 97 97 testCustomGetter({__proto__: {__proto__: r}}); 98 }, "TypeError: T ype error");98 }, "TypeError: The RegExp.prototype.source getter can only be called on a RegExp object"); 99 99 })(); 100 100 </script> -
trunk/LayoutTests/js/regexp-flags-expected.txt
r197869 r199545 15 15 PASS flags.call(/a/ig) is 'gi' 16 16 non-object receivers 17 PASS flags.call(undefined) threw exception TypeError: T ype error.18 PASS flags.call(null) threw exception TypeError: T ype error.19 PASS flags.call(false) threw exception TypeError: T ype error.20 PASS flags.call(true) threw exception TypeError: T ype error.17 PASS flags.call(undefined) threw exception TypeError: The RegExp.prototype.flags getter can only be called on an object. 18 PASS flags.call(null) threw exception TypeError: The RegExp.prototype.flags getter can only be called on an object. 19 PASS flags.call(false) threw exception TypeError: The RegExp.prototype.flags getter can only be called on an object. 20 PASS flags.call(true) threw exception TypeError: The RegExp.prototype.flags getter can only be called on an object. 21 21 non-regex objects 22 22 PASS flags.call({}) is '' -
trunk/LayoutTests/js/script-tests/regexp-flags.js
r197869 r199545 17 17 18 18 debug("non-object receivers"); 19 shouldThrow("flags.call(undefined)", "'TypeError: T ype error'");20 shouldThrow("flags.call(null)", "'TypeError: T ype error'");21 shouldThrow("flags.call(false)", "'TypeError: T ype error'");22 shouldThrow("flags.call(true)", "'TypeError: T ype error'");19 shouldThrow("flags.call(undefined)", "'TypeError: The RegExp.prototype.flags getter can only be called on an object'"); 20 shouldThrow("flags.call(null)", "'TypeError: The RegExp.prototype.flags getter can only be called on an object'"); 21 shouldThrow("flags.call(false)", "'TypeError: The RegExp.prototype.flags getter can only be called on an object'"); 22 shouldThrow("flags.call(true)", "'TypeError: The RegExp.prototype.flags getter can only be called on an object'"); 23 23 24 24 debug("non-regex objects"); -
trunk/Source/JavaScriptCore/ChangeLog
r199543 r199545 1 2016-04-14 Mark Lam <mark.lam@apple.com> 2 3 Update treatment of invoking RegExp.prototype methods on RegExp.prototype. 4 https://bugs.webkit.org/show_bug.cgi?id=155922 5 6 Reviewed by Keith Miller. 7 8 According to the TC39 committee, when invoking the following RegExp.prototype 9 methods on the RegExp.prototype: 10 1. RegExp.prototype.flags yields "" 11 2. RegExp.prototype.global yields undefined 12 3. RegExp.prototype.ignoreCase yields undefined 13 4. RegExp.prototype.multiline yields undefined 14 5. RegExp.prototype.unicode yields undefined 15 6. RegExp.prototype.source yields "(?:)" 16 7. RegExp.prototype.sticky yields undefined 17 8. RegExp.prototype.toString() yields "/(?:)/" 18 19 and RegExp.prototype is still NOT an instance of RegExp. The above behavior 20 changes is a special dispensation applicable only to RegExp.prototype. The ES6 21 spec of throwing errors still applies if those methods are applied to anything = 22 else that is not a RegExp object. 23 24 * runtime/RegExpPrototype.cpp: 25 (JSC::regExpProtoGetterGlobal): 26 (JSC::regExpProtoGetterIgnoreCase): 27 (JSC::regExpProtoGetterMultiline): 28 (JSC::regExpProtoGetterSticky): 29 (JSC::regExpProtoGetterUnicode): 30 (JSC::regExpProtoGetterFlags): 31 (JSC::regExpProtoGetterSource): 32 - Implemented new behavior. 33 34 * tests/es6/miscellaneous_built-in_prototypes_are_not_instances.js: 35 (test): 36 - Updated to match current kangax test. 37 1 38 2016-04-14 Geoffrey Garen <ggaren@apple.com> 2 39 -
trunk/Source/JavaScriptCore/runtime/RegExpPrototype.cpp
r199514 r199545 245 245 { 246 246 JSValue thisValue = exec->thisValue(); 247 if (!thisValue.inherits(RegExpObject::info())) 248 return JSValue::encode(jsUndefined()); 247 if (UNLIKELY(!thisValue.inherits(RegExpObject::info()))) { 248 if (thisValue.inherits(RegExpPrototype::info())) 249 return JSValue::encode(jsUndefined()); 250 return throwVMTypeError(exec, ASCIILiteral("The RegExp.prototype.global getter can only be called on a RegExp object")); 251 } 249 252 250 253 return JSValue::encode(jsBoolean(asRegExpObject(thisValue)->regExp()->global())); … … 254 257 { 255 258 JSValue thisValue = exec->thisValue(); 256 if (!thisValue.inherits(RegExpObject::info())) 257 return JSValue::encode(jsUndefined()); 259 if (UNLIKELY(!thisValue.inherits(RegExpObject::info()))) { 260 if (thisValue.inherits(RegExpPrototype::info())) 261 return JSValue::encode(jsUndefined()); 262 return throwVMTypeError(exec, ASCIILiteral("The RegExp.prototype.ignoreCase getter can only be called on a RegExp object")); 263 } 258 264 259 265 return JSValue::encode(jsBoolean(asRegExpObject(thisValue)->regExp()->ignoreCase())); … … 263 269 { 264 270 JSValue thisValue = exec->thisValue(); 265 if (!thisValue.inherits(RegExpObject::info())) 266 return JSValue::encode(jsUndefined()); 271 if (UNLIKELY(!thisValue.inherits(RegExpObject::info()))) { 272 if (thisValue.inherits(RegExpPrototype::info())) 273 return JSValue::encode(jsUndefined()); 274 return throwVMTypeError(exec, ASCIILiteral("The RegExp.prototype.multiline getter can only be called on a RegExp object")); 275 } 267 276 268 277 return JSValue::encode(jsBoolean(asRegExpObject(thisValue)->regExp()->multiline())); … … 272 281 { 273 282 JSValue thisValue = exec->thisValue(); 274 if (!thisValue.inherits(RegExpObject::info())) 275 return JSValue::encode(jsUndefined()); 283 if (UNLIKELY(!thisValue.inherits(RegExpObject::info()))) { 284 if (thisValue.inherits(RegExpPrototype::info())) 285 return JSValue::encode(jsUndefined()); 286 return throwVMTypeError(exec, ASCIILiteral("The RegExp.prototype.sticky getter can only be called on a RegExp object")); 287 } 276 288 277 289 return JSValue::encode(jsBoolean(asRegExpObject(thisValue)->regExp()->sticky())); … … 281 293 { 282 294 JSValue thisValue = exec->thisValue(); 283 if (!thisValue.inherits(RegExpObject::info())) 284 return JSValue::encode(jsUndefined()); 295 if (UNLIKELY(!thisValue.inherits(RegExpObject::info()))) { 296 if (thisValue.inherits(RegExpPrototype::info())) 297 return JSValue::encode(jsUndefined()); 298 return throwVMTypeError(exec, ASCIILiteral("The RegExp.prototype.unicode getter can only be called on a RegExp object")); 299 } 285 300 286 301 return JSValue::encode(jsBoolean(asRegExpObject(thisValue)->regExp()->unicode())); … … 290 305 { 291 306 JSValue thisValue = exec->thisValue(); 292 if ( !thisValue.isObject())293 return throwVMTypeError(exec );307 if (UNLIKELY(!thisValue.isObject())) 308 return throwVMTypeError(exec, ASCIILiteral("The RegExp.prototype.flags getter can only be called on an object")); 294 309 295 310 auto flags = flagsString(exec, asObject(thisValue)); … … 409 424 { 410 425 JSValue thisValue = exec->thisValue(); 411 if (!thisValue.inherits(RegExpObject::info())) 412 return throwVMTypeError(exec); 426 if (UNLIKELY(!thisValue.inherits(RegExpObject::info()))) { 427 if (thisValue.inherits(RegExpPrototype::info())) 428 return JSValue::encode(jsString(exec, ASCIILiteral("(?:)"))); 429 return throwVMTypeError(exec, ASCIILiteral("The RegExp.prototype.source getter can only be called on a RegExp object")); 430 } 413 431 414 432 String pattern = asRegExpObject(thisValue)->regExp()->pattern(); -
trunk/Source/JavaScriptCore/tests/es6/miscellaneous_built-in_prototypes_are_not_instances.js
r198469 r199545 2 2 3 3 try { 4 RegExp.prototype. source; return false;4 RegExp.prototype.exec(); return false; 5 5 } catch(e) {} 6 6 try {
Note: See TracChangeset
for help on using the changeset viewer.