Changeset 91224 in webkit
- Timestamp:
- Jul 18, 2011 5:25:49 PM (13 years ago)
- Location:
- trunk
- Files:
-
- 3 added
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r91223 r91224 1 2011-07-18 Gavin Barraclough <barraclough@apple.com> 2 3 https://bugs.webkit.org/show_bug.cgi?id=64678 4 Fix bugs in Object.prototype this handling. 5 6 Reviewed by Oliver Hunt. 7 8 * fast/js/resources/js-test-pre.js: 9 - Updated harness to not call Object.prototype.toString on undefined. 10 * fast/js/eval-var-decl-expected.txt: 11 * fast/js/object-prototype-properties-expected.txt: Added. 12 * fast/js/object-prototype-properties.html: Added. 13 * fast/js/object-prototype-toLocaleString-expected.txt 14 * fast/js/script-tests/eval-var-decl.js: 15 - Fix test case, calling hasProperty with undefined as the this value should throw. 16 * fast/js/script-tests/object-prototype-properties.js: Added. 17 - Place for test cases for Object.prototype properties; to being with, check that calling these methods on undefined throws! 18 * fast/js/script-tests/object-prototype-toLocaleString.js: 19 - Added test cases for correct behaviour when this is a string primitive. 20 * sputnik/Conformance/11_Expressions/11.1_Primary_Expressions/11.1.1_The_this_Keyword/S11.1.1_A2-expected.txt: 21 * sputnik/Conformance/15_Native_Objects/15.5_String/15.5.4/15.5.4.10_String.prototype.match/S15.5.4.10_A1_T3-expected.txt: 22 * sputnik/Conformance/15_Native_Objects/15.5_String/15.5.4/15.5.4.11_String.prototype.replace/S15.5.4.11_A1_T3-expected.txt: 23 * sputnik/Conformance/15_Native_Objects/15.5_String/15.5.4/15.5.4.12_String.prototype.search/S15.5.4.12_A1_T3-expected.txt: 24 * sputnik/Conformance/15_Native_Objects/15.5_String/15.5.4/15.5.4.13_String.prototype.slice/S15.5.4.13_A1_T3-expected.txt: 25 * sputnik/Conformance/15_Native_Objects/15.5_String/15.5.4/15.5.4.14_String.prototype.split/S15.5.4.14_A1_T3-expected.txt: 26 * sputnik/Conformance/15_Native_Objects/15.5_String/15.5.4/15.5.4.15_String.prototype.substring/S15.5.4.15_A1_T3-expected.txt: 27 * sputnik/Conformance/15_Native_Objects/15.5_String/15.5.4/15.5.4.4_String.prototype.charAt/S15.5.4.4_A1_T3-expected.txt: 28 * sputnik/Conformance/15_Native_Objects/15.5_String/15.5.4/15.5.4.5_String.prototype.charCodeAt/S15.5.4.5_A1_T3-expected.txt: 29 * sputnik/Conformance/15_Native_Objects/15.5_String/15.5.4/15.5.4.6_String.prototype.concat/S15.5.4.6_A1_T3-expected.txt: 30 * sputnik/Conformance/15_Native_Objects/15.5_String/15.5.4/15.5.4.7_String.prototype.indexOf/S15.5.4.7_A1_T3-expected.txt: 31 * sputnik/Conformance/15_Native_Objects/15.5_String/15.5.4/15.5.4.8_String.prototype.lastIndexOf/S15.5.4.8_A1_T3-expected.txt: 32 - These test cases are all incorrect. (See https://bugs.ecmascript.org/show_bug.cgi?id=117). 33 We were incorrectly passing 15.5.4.11_String.prototype.replace, this should fail, as the others do. 34 All the other 15.5.4 tests were failing & are still failing, but now have a better error message. 35 S11.1.1_A2 is also invalid, calling toString() passing undefined as this should throw. 36 1 37 2011-07-18 Ryosuke Niwa <rniwa@webkit.org> 2 38 -
trunk/LayoutTests/fast/js/eval-var-decl-expected.txt
r39534 r91224 4 4 5 5 6 PASS hasOwnProperty("foo") is true7 PASS hasOwnProperty("bar") is true6 PASS this.hasOwnProperty("foo") is true 7 PASS this.hasOwnProperty("bar") is true 8 8 PASS firstEvalResult is true 9 9 PASS secondEvalResult is false -
trunk/LayoutTests/fast/js/object-prototype-toLocaleString-expected.txt
r12001 r91224 6 6 PASS o.toLocaleString() is o.toString() 7 7 PASS o.toLocaleString() is "Dynamic toLocaleString()" 8 PASS Object.prototype.toLocaleString.call('Hello, world!') is "Hello, world!" 9 PASS Object.prototype.toLocaleString.call('Hello, world!') is "stringPrototypeToString" 8 10 PASS successfullyParsed is true 9 11 -
trunk/LayoutTests/fast/js/resources/js-test-pre.js
r70794 r91224 66 66 if (typeof(_expected) == "number" && isNaN(_expected)) 67 67 return typeof(_actual) == "number" && isNaN(_actual); 68 if ( Object.prototype.toString.call(_expected) == Object.prototype.toString.call([]))68 if (_expected && (Object.prototype.toString.call(_expected) == Object.prototype.toString.call([]))) 69 69 return areArraysEqual(_actual, _expected); 70 70 return false; -
trunk/LayoutTests/fast/js/script-tests/eval-var-decl.js
r48651 r91224 3 3 ); 4 4 5 shouldBeTrue(' hasOwnProperty("foo")');5 shouldBeTrue('this.hasOwnProperty("foo")'); 6 6 var foo = 3; 7 7 8 8 delete bar; 9 shouldBeTrue(' hasOwnProperty("bar")');9 shouldBeTrue('this.hasOwnProperty("bar")'); 10 10 var bar = 3; 11 11 12 var firstEvalResult = eval('var result = hasOwnProperty("y"); var y = 3; result');12 var firstEvalResult = eval('var result = this.hasOwnProperty("y"); var y = 3; result'); 13 13 shouldBeTrue("firstEvalResult"); 14 14 15 var secondEvalResult = eval('delete x; var result = hasOwnProperty("x"); var x = 3; result');15 var secondEvalResult = eval('delete x; var result = this.hasOwnProperty("x"); var x = 3; result'); 16 16 shouldBeFalse("secondEvalResult"); 17 17 -
trunk/LayoutTests/fast/js/script-tests/object-prototype-toLocaleString.js
r48925 r91224 8 8 shouldBe("o.toLocaleString()", '"Dynamic toLocaleString()"'); 9 9 10 shouldBe("Object.prototype.toLocaleString.call('Hello, world!')", '"Hello, world!"'); 11 12 var stringPrototypeToString = String.prototype.toString; 13 String.prototype.toString = (function(){ return "stringPrototypeToString"; }); 14 shouldBe("Object.prototype.toLocaleString.call('Hello, world!')", '"stringPrototypeToString"'); 15 String.prototype.toString = stringPrototypeToString; 16 10 17 var successfullyParsed = true; -
trunk/Source/JavaScriptCore/ChangeLog
r91218 r91224 1 2011-07-18 Gavin Barraclough <barraclough@apple.com> 2 3 https://bugs.webkit.org/show_bug.cgi?id=64678 4 Fix bugs in Object.prototype this handling. 5 6 Reviewed by Oliver Hunt. 7 8 undefined/null this values should throw TypeErrors, not convert to the global object, 9 also, to toLocaleString should be calling the ToObject & invoking the object's toString 10 function, even for values that are already strings. 11 12 * runtime/ObjectPrototype.cpp: 13 (JSC::objectProtoFuncValueOf): 14 (JSC::objectProtoFuncHasOwnProperty): 15 (JSC::objectProtoFuncIsPrototypeOf): 16 (JSC::objectProtoFuncPropertyIsEnumerable): 17 (JSC::objectProtoFuncToLocaleString): 18 (JSC::objectProtoFuncToString): 19 1 20 2011-07-18 Filip Pizlo <fpizlo@apple.com> 2 21 -
trunk/Source/JavaScriptCore/runtime/ObjectPrototype.cpp
r86727 r91224 105 105 { 106 106 JSValue thisValue = exec->hostThisValue(); 107 return JSValue::encode(thisValue.to ThisObject(exec));107 return JSValue::encode(thisValue.toObject(exec)); 108 108 } 109 109 … … 111 111 { 112 112 JSValue thisValue = exec->hostThisValue(); 113 return JSValue::encode(jsBoolean(thisValue.to ThisObject(exec)->hasOwnProperty(exec, Identifier(exec, exec->argument(0).toString(exec)))));113 return JSValue::encode(jsBoolean(thisValue.toObject(exec)->hasOwnProperty(exec, Identifier(exec, exec->argument(0).toString(exec))))); 114 114 } 115 115 … … 117 117 { 118 118 JSValue thisValue = exec->hostThisValue(); 119 JSObject* thisObj = thisValue.to ThisObject(exec);119 JSObject* thisObj = thisValue.toObject(exec); 120 120 121 121 if (!exec->argument(0).isObject()) … … 168 168 { 169 169 JSValue thisValue = exec->hostThisValue(); 170 return JSValue::encode(jsBoolean(thisValue.toThisObject(exec)->propertyIsEnumerable(exec, Identifier(exec, exec->argument(0).toString(exec))))); 171 } 172 170 return JSValue::encode(jsBoolean(thisValue.toObject(exec)->propertyIsEnumerable(exec, Identifier(exec, exec->argument(0).toString(exec))))); 171 } 172 173 // 15.2.4.3 Object.prototype.toLocaleString() 173 174 EncodedJSValue JSC_HOST_CALL objectProtoFuncToLocaleString(ExecState* exec) 174 175 { 175 JSValue thisValue = exec->hostThisValue(); 176 return JSValue::encode(thisValue.toThisJSString(exec)); 176 // 1. Let O be the result of calling ToObject passing the this value as the argument. 177 JSObject* object = exec->hostThisValue().toObject(exec); 178 if (exec->hadException()) 179 return JSValue::encode(jsUndefined()); 180 181 // 2. Let toString be the result of calling the [[Get]] internal method of O passing "toString" as the argument. 182 JSValue toString = object->get(exec, exec->propertyNames().toString); 183 184 // 3. If IsCallable(toString) is false, throw a TypeError exception. 185 CallData callData; 186 CallType callType = getCallData(toString, callData); 187 if (callType == CallTypeNone) 188 return JSValue::encode(jsUndefined()); 189 190 // 4. Return the result of calling the [[Call]] internal method of toString passing O as the this value and no arguments. 191 return JSValue::encode(call(exec, toString, callType, callData, object, exec->emptyList())); 177 192 } 178 193 … … 180 195 { 181 196 JSValue thisValue = exec->hostThisValue(); 182 return JSValue::encode(jsMakeNontrivialString(exec, "[object ", thisValue.to ThisObject(exec)->className(), "]"));197 return JSValue::encode(jsMakeNontrivialString(exec, "[object ", thisValue.toObject(exec)->className(), "]")); 183 198 } 184 199
Note: See TracChangeset
for help on using the changeset viewer.