Changeset 197999 in webkit
- Timestamp:
- Mar 10, 2016, 11:10:18 PM (9 years ago)
- Location:
- trunk
- Files:
-
- 2 added
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/js/regexp-toString-expected.txt
r185528 r197999 12 12 PASS RegExp.prototype.toString.call(new RegExp('a')) is '/a/' 13 13 PASS RegExp.prototype.toString.call(new RegExp('\\\\')) is '/\\\\/' 14 PASS RegExp.prototype.toString.call({}) is '/undefined/ '15 PASS RegExp.prototype.toString.call({source: 'hi'}) is '/hi/ '16 PASS RegExp.prototype.toString.call({ __proto__: { source: 'yo' } }) is '/yo/ '17 PASS RegExp.prototype.toString.call({source: ''}) is '// '18 PASS RegExp.prototype.toString.call({source: '/'}) is '/// '14 PASS RegExp.prototype.toString.call({}) is '/undefined/undefined' 15 PASS RegExp.prototype.toString.call({source: 'hi'}) is '/hi/undefined' 16 PASS RegExp.prototype.toString.call({ __proto__: { source: 'yo' } }) is '/yo/undefined' 17 PASS RegExp.prototype.toString.call({source: ''}) is '//undefined' 18 PASS RegExp.prototype.toString.call({source: '/'}) is '///undefined' 19 19 PASS RegExp.prototype.toString.call(undefined) threw exception TypeError: Type error. 20 20 PASS RegExp.prototype.toString.call(null) threw exception TypeError: Type error. -
trunk/LayoutTests/js/script-tests/regexp-toString.js
r185528 r197999 11 11 shouldBe("RegExp.prototype.toString.call(new RegExp('\\\\\\\\'))", "'/\\\\\\\\/'"); 12 12 13 shouldBe("RegExp.prototype.toString.call({})", "'/undefined/ '");14 shouldBe("RegExp.prototype.toString.call({source: 'hi'})", "'/hi/ '");15 shouldBe("RegExp.prototype.toString.call({ __proto__: { source: 'yo' } })", "'/yo/ '");16 shouldBe("RegExp.prototype.toString.call({source: ''})", "'// '");17 shouldBe("RegExp.prototype.toString.call({source: '/'})", "'/// '");13 shouldBe("RegExp.prototype.toString.call({})", "'/undefined/undefined'"); 14 shouldBe("RegExp.prototype.toString.call({source: 'hi'})", "'/hi/undefined'"); 15 shouldBe("RegExp.prototype.toString.call({ __proto__: { source: 'yo' } })", "'/yo/undefined'"); 16 shouldBe("RegExp.prototype.toString.call({source: ''})", "'//undefined'"); 17 shouldBe("RegExp.prototype.toString.call({source: '/'})", "'///undefined'"); 18 18 19 19 shouldThrow("RegExp.prototype.toString.call(undefined)"); -
trunk/Source/JavaScriptCore/ChangeLog
r197994 r197999 1 2016-03-10 Saam barati <sbarati@apple.com> 2 3 [ES6] Make RegExp.prototype.toString spec compliant 4 https://bugs.webkit.org/show_bug.cgi?id=155341 5 6 Reviewed by Filip Pizlo. 7 8 Before we were directly calling into the flagsString 9 function. Instead, we must get the "flags" property 10 of the thisObject. This will usually call into the flags 11 getter, but not always. Specifically, you can you a Proxy 12 to observe this behavior. 13 14 * runtime/RegExpPrototype.cpp: 15 (JSC::regExpProtoFuncToString): 16 (JSC::regExpProtoGetterGlobal): 17 * tests/es6.yaml: 18 * tests/es6/Proxy_internal_get_calls_RegExp.prototype.toString.js: Added. 19 (test.get var): 20 (test.): 21 * tests/stress/regexp-prototype-tostring.js: Added. 22 (assert): 23 (test): 24 (test.get var): 25 (test.): 26 (let.handler.get switch): 27 (let.handler): 28 (get test): 29 (test.get RegExp): 30 1 31 2016-03-10 Benjamin Poulain <bpoulain@apple.com> 2 32 -
trunk/Source/JavaScriptCore/runtime/RegExpPrototype.cpp
r197869 r197999 209 209 return JSValue::encode(earlyReturnValue); 210 210 211 JSValue sourceValue = thisObject->get(exec, exec->propertyNames().source); 212 if (exec->hadException()) 211 VM& vm = exec->vm(); 212 JSValue sourceValue = thisObject->get(exec, vm.propertyNames->source); 213 if (vm.exception()) 213 214 return JSValue::encode(jsUndefined()); 214 215 String source = sourceValue.toString(exec)->value(exec); 215 if (exec->hadException()) 216 return JSValue::encode(jsUndefined()); 217 218 auto flags = flagsString(exec, thisObject); 219 if (exec->hadException()) 220 return JSValue::encode(jsUndefined()); 221 222 return JSValue::encode(jsMakeNontrivialString(exec, '/', source, '/', flags.data())); 216 if (vm.exception()) 217 return JSValue::encode(jsUndefined()); 218 219 JSValue flagsValue = thisObject->get(exec, vm.propertyNames->flags); 220 if (vm.exception()) 221 return JSValue::encode(jsUndefined()); 222 String flags = flagsValue.toString(exec)->value(exec); 223 if (vm.exception()) 224 return JSValue::encode(jsUndefined()); 225 226 return JSValue::encode(jsMakeNontrivialString(exec, '/', source, '/', flags)); 223 227 } 224 228 -
trunk/Source/JavaScriptCore/tests/es6.yaml
r197970 r197999 995 995 - path: es6/Proxy_internal_get_calls_RegExp.prototype.test.js 996 996 cmd: runES6 :fail 997 - path: es6/Proxy_internal_get_calls_RegExp.prototype.toString.js 998 cmd: runES6 :normal 997 999 - path: es6/Proxy_internal_get_calls_RegExp.prototype[Symbol.match].js 998 1000 cmd: runES6 :fail
Note:
See TracChangeset
for help on using the changeset viewer.