Diff
Modified: trunk/LayoutTests/ChangeLog (91343 => 91344)
--- trunk/LayoutTests/ChangeLog 2011-07-20 07:32:54 UTC (rev 91343)
+++ trunk/LayoutTests/ChangeLog 2011-07-20 07:50:57 UTC (rev 91344)
@@ -1,3 +1,27 @@
+2011-07-19 Gavin Barraclough <barraclo...@apple.com>
+
+ https://bugs.webkit.org/show_bug.cgi?id=64678
+ Fix bugs in Object.prototype this handling.
+
+ Reviewed by Darin Adler.
+
+ * fast/js/object-prototype-properties-expected.txt:
+ * fast/js/script-tests/object-prototype-properties.js:
+ - Fix these tests to check Object.prototype explicitly, not the Global Object, and expect ES5.1 correct results.
+ * sputnik/Conformance/11_Expressions/11.1_Primary_Expressions/11.1.1_The_this_Keyword/S11.1.1_A2-expected.txt:
+ * 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:
+ * 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:
+ * 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:
+ * 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:
+ * 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:
+ * 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:
+ * 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:
+ * 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:
+ * 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:
+ * 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:
+ * 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:
+ - Slight change in expected results, these tests are all incorrect, were all FAILing, and are still all FAILing.
+
2011-07-20 Hayato Ito <hay...@chromium.org>
Fix Chromium test expectations for r91331.
Modified: trunk/LayoutTests/fast/js/object-prototype-properties-expected.txt (91343 => 91344)
--- trunk/LayoutTests/fast/js/object-prototype-properties-expected.txt 2011-07-20 07:32:54 UTC (rev 91343)
+++ trunk/LayoutTests/fast/js/object-prototype-properties-expected.txt 2011-07-20 07:50:57 UTC (rev 91344)
@@ -3,12 +3,13 @@
On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
-PASS toString() threw exception TypeError: 'undefined' is not an object (evaluating 'toString()').
-PASS toLocaleString() threw exception TypeError: 'undefined' is not an object (evaluating 'toLocaleString()').
-PASS valueOf() threw exception TypeError: 'undefined' is not an object (evaluating 'valueOf()').
-PASS hasProperty('hasProperty') threw exception ReferenceError: Can't find variable: hasProperty.
-PASS propertyIsEnumerable('hasProperty') threw exception TypeError: 'undefined' is not an object (evaluating 'propertyIsEnumerable('hasProperty')').
-PASS isPrototypeOf(this) threw exception TypeError: 'undefined' is not an object (evaluating 'isPrototypeOf(this)').
+PASS Object.prototype.toString.call(undefined) is "[object Undefined]"
+PASS Object.prototype.toString.call(null) is "[object Null]"
+PASS Object.prototype.toLocaleString.call(undefined) threw exception TypeError: 'undefined' is not an object (evaluating 'Object.prototype.toLocaleString.call(undefined)').
+PASS Object.prototype.valueOf.call(undefined) threw exception TypeError: 'undefined' is not an object (evaluating 'Object.prototype.valueOf.call(undefined)').
+PASS Object.prototype.hasOwnProperty.call(undefined, 'hasOwnProperty') threw exception TypeError: 'undefined' is not an object (evaluating 'Object.prototype.hasOwnProperty.call(undefined, 'hasOwnProperty')').
+PASS Object.prototype.propertyIsEnumerable.call(undefined, 'propertyIsEnumerable') threw exception TypeError: 'undefined' is not an object (evaluating 'Object.prototype.propertyIsEnumerable.call(undefined, 'propertyIsEnumerable')').
+PASS Object.prototype.isPrototypeOf.call(undefined, this) threw exception TypeError: 'undefined' is not an object (evaluating 'Object.prototype.isPrototypeOf.call(undefined, this)').
PASS successfullyParsed is true
TEST COMPLETE
Modified: trunk/LayoutTests/fast/js/script-tests/object-prototype-properties.js (91343 => 91344)
--- trunk/LayoutTests/fast/js/script-tests/object-prototype-properties.js 2011-07-20 07:32:54 UTC (rev 91343)
+++ trunk/LayoutTests/fast/js/script-tests/object-prototype-properties.js 2011-07-20 07:50:57 UTC (rev 91344)
@@ -2,12 +2,15 @@
'This is a test case for <a https://bugs.webkit.org/show_bug.cgi?id=64678">bug 64678</a>.'
);
-// These call pass undefined as this value, and as such should show in toObject.
-shouldThrow("toString()");
-shouldThrow("toLocaleString()");
-shouldThrow("valueOf()");
-shouldThrow("hasProperty('hasProperty')");
-shouldThrow("propertyIsEnumerable('hasProperty')");
-shouldThrow("isPrototypeOf(this)");
+//ES 5.1 allows for Object.prototype.toString being called with undefined/null.
+shouldBe("Object.prototype.toString.call(undefined)", '"[object Undefined]"');
+shouldBe("Object.prototype.toString.call(null)", '"[object Null]"');
+// These calls pass undefined as this value, and as such should throw in toObject.
+shouldThrow("Object.prototype.toLocaleString.call(undefined)");
+shouldThrow("Object.prototype.valueOf.call(undefined)");
+shouldThrow("Object.prototype.hasOwnProperty.call(undefined, 'hasOwnProperty')");
+shouldThrow("Object.prototype.propertyIsEnumerable.call(undefined, 'propertyIsEnumerable')");
+shouldThrow("Object.prototype.isPrototypeOf.call(undefined, this)");
+
var successfullyParsed = true;
Modified: trunk/LayoutTests/sputnik/Conformance/11_Expressions/11.1_Primary_Expressions/11.1.1_The_this_Keyword/S11.1.1_A2-expected.txt (91343 => 91344)
--- trunk/LayoutTests/sputnik/Conformance/11_Expressions/11.1_Primary_Expressions/11.1.1_The_this_Keyword/S11.1.1_A2-expected.txt 2011-07-20 07:32:54 UTC (rev 91343)
+++ trunk/LayoutTests/sputnik/Conformance/11_Expressions/11.1_Primary_Expressions/11.1.1_The_this_Keyword/S11.1.1_A2-expected.txt 2011-07-20 07:50:57 UTC (rev 91344)
@@ -1,6 +1,6 @@
S11.1.1_A2
-FAIL TypeError: 'undefined' is not an object (evaluating 'toString()')
+FAIL SputnikError: #1: this.toString() === toString(). Actual: [object DOMWindow]
TEST COMPLETE
Modified: trunk/LayoutTests/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 (91343 => 91344)
--- trunk/LayoutTests/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 2011-07-20 07:32:54 UTC (rev 91343)
+++ trunk/LayoutTests/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 2011-07-20 07:50:57 UTC (rev 91344)
@@ -1,6 +1,6 @@
S15.5.4.10_A1_T3
-FAIL TypeError: 'undefined' is not an object (evaluating 'toString()')
+FAIL TypeError: Type error
TEST COMPLETE
Modified: trunk/LayoutTests/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 (91343 => 91344)
--- trunk/LayoutTests/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 2011-07-20 07:32:54 UTC (rev 91343)
+++ trunk/LayoutTests/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 2011-07-20 07:50:57 UTC (rev 91344)
@@ -1,6 +1,6 @@
S15.5.4.11_A1_T3
-FAIL TypeError: 'undefined' is not an object (evaluating 'toString()')
+FAIL TypeError: Type error
TEST COMPLETE
Modified: trunk/LayoutTests/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 (91343 => 91344)
--- trunk/LayoutTests/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 2011-07-20 07:32:54 UTC (rev 91343)
+++ trunk/LayoutTests/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 2011-07-20 07:50:57 UTC (rev 91344)
@@ -1,6 +1,6 @@
S15.5.4.12_A1_T3
-FAIL TypeError: 'undefined' is not an object (evaluating 'toString()')
+FAIL TypeError: Type error
TEST COMPLETE
Modified: trunk/LayoutTests/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 (91343 => 91344)
--- trunk/LayoutTests/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 2011-07-20 07:32:54 UTC (rev 91343)
+++ trunk/LayoutTests/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 2011-07-20 07:50:57 UTC (rev 91344)
@@ -1,6 +1,6 @@
S15.5.4.13_A1_T3
-FAIL TypeError: 'undefined' is not an object (evaluating 'toString()')
+FAIL TypeError: Type error
TEST COMPLETE
Modified: trunk/LayoutTests/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 (91343 => 91344)
--- trunk/LayoutTests/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 2011-07-20 07:32:54 UTC (rev 91343)
+++ trunk/LayoutTests/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 2011-07-20 07:50:57 UTC (rev 91344)
@@ -1,6 +1,6 @@
S15.5.4.14_A1_T3
-FAIL TypeError: 'undefined' is not an object (evaluating 'toString()')
+FAIL TypeError: Type error
TEST COMPLETE
Modified: trunk/LayoutTests/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 (91343 => 91344)
--- trunk/LayoutTests/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 2011-07-20 07:32:54 UTC (rev 91343)
+++ trunk/LayoutTests/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 2011-07-20 07:50:57 UTC (rev 91344)
@@ -1,6 +1,6 @@
S15.5.4.15_A1_T3
-FAIL TypeError: 'undefined' is not an object (evaluating 'toString()')
+FAIL TypeError: Type error
TEST COMPLETE
Modified: trunk/LayoutTests/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 (91343 => 91344)
--- trunk/LayoutTests/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 2011-07-20 07:32:54 UTC (rev 91343)
+++ trunk/LayoutTests/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 2011-07-20 07:50:57 UTC (rev 91344)
@@ -1,6 +1,6 @@
S15.5.4.4_A1_T3
-FAIL TypeError: 'undefined' is not an object (evaluating 'toString()')
+FAIL TypeError: Type error
TEST COMPLETE
Modified: trunk/LayoutTests/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 (91343 => 91344)
--- trunk/LayoutTests/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 2011-07-20 07:32:54 UTC (rev 91343)
+++ trunk/LayoutTests/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 2011-07-20 07:50:57 UTC (rev 91344)
@@ -1,6 +1,6 @@
S15.5.4.5_A1_T3
-FAIL TypeError: 'undefined' is not an object (evaluating 'toString()')
+FAIL TypeError: Type error
TEST COMPLETE
Modified: trunk/LayoutTests/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 (91343 => 91344)
--- trunk/LayoutTests/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 2011-07-20 07:32:54 UTC (rev 91343)
+++ trunk/LayoutTests/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 2011-07-20 07:50:57 UTC (rev 91344)
@@ -1,6 +1,6 @@
S15.5.4.6_A1_T3
-FAIL TypeError: 'undefined' is not an object (evaluating 'toString()')
+FAIL TypeError: Type error
TEST COMPLETE
Modified: trunk/LayoutTests/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 (91343 => 91344)
--- trunk/LayoutTests/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 2011-07-20 07:32:54 UTC (rev 91343)
+++ trunk/LayoutTests/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 2011-07-20 07:50:57 UTC (rev 91344)
@@ -1,6 +1,6 @@
S15.5.4.7_A1_T3
-FAIL TypeError: 'undefined' is not an object (evaluating 'toString()')
+FAIL TypeError: Type error
TEST COMPLETE
Modified: trunk/LayoutTests/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 (91343 => 91344)
--- trunk/LayoutTests/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 2011-07-20 07:32:54 UTC (rev 91343)
+++ trunk/LayoutTests/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 2011-07-20 07:50:57 UTC (rev 91344)
@@ -1,6 +1,6 @@
S15.5.4.8_A1_T3
-FAIL TypeError: 'undefined' is not an object (evaluating 'toString()')
+FAIL TypeError: Type error
TEST COMPLETE
Modified: trunk/Source/_javascript_Core/ChangeLog (91343 => 91344)
--- trunk/Source/_javascript_Core/ChangeLog 2011-07-20 07:32:54 UTC (rev 91343)
+++ trunk/Source/_javascript_Core/ChangeLog 2011-07-20 07:50:57 UTC (rev 91344)
@@ -1,3 +1,16 @@
+2011-07-19 Gavin Barraclough <barraclo...@apple.com>
+
+ https://bugs.webkit.org/show_bug.cgi?id=64678
+ Fix bugs in Object.prototype this handling.
+
+ Reviewed by Darin Adler.
+
+ Fix ES5.1 correctness issues identified by Mads Ager.
+
+ * runtime/ObjectPrototype.cpp:
+ (JSC::objectProtoFuncToString):
+ - ES5.1 expects toString of undefined/null to produce "[object Undefined]"/"[object Null]".
+
2011-07-19 Mark Hahnenberg <mhahnenb...@apple.com>
[JSC] WebKit allocates gigabytes of memory when doing repeated string concatenation
Modified: trunk/Source/_javascript_Core/runtime/ObjectPrototype.cpp (91343 => 91344)
--- trunk/Source/_javascript_Core/runtime/ObjectPrototype.cpp 2011-07-20 07:32:54 UTC (rev 91343)
+++ trunk/Source/_javascript_Core/runtime/ObjectPrototype.cpp 2011-07-20 07:50:57 UTC (rev 91344)
@@ -194,6 +194,8 @@
EncodedJSValue JSC_HOST_CALL objectProtoFuncToString(ExecState* exec)
{
JSValue thisValue = exec->hostThisValue();
+ if (thisValue.isUndefinedOrNull())
+ return jsNontrivialString(exec, thisValue.isUndefined() ? "[object Undefined]" : "[object Null]");
return JSValue::encode(jsMakeNontrivialString(exec, "[object ", thisValue.toObject(exec)->className(), "]"));
}