Title: [105811] trunk
- Revision
- 105811
- Author
- [email protected]
- Date
- 2012-01-24 14:31:41 -0800 (Tue, 24 Jan 2012)
Log Message
JSValue::toString() should return a JSString* instead of a UString
https://bugs.webkit.org/show_bug.cgi?id=76861
Source/_javascript_Core:
Fixed two failing layout tests after my last patch.
Reviewed by Gavin Barraclough.
* runtime/ArrayPrototype.cpp:
(JSC::arrayProtoFuncSort): Call value() after calling toString(), as
in all other cases.
I missed this case because the JSString* type has a valid operator<,
so the compiler didn't complain.
LayoutTests:
Reviewed by Gavin Barraclough.
Added a unit test for something I got wrong while writing this patch.
* fast/js/add-to-primitive-expected.txt: Added.
* fast/js/add-to-primitive.html: Added.
Modified Paths
Added Paths
Diff
Modified: trunk/LayoutTests/ChangeLog (105810 => 105811)
--- trunk/LayoutTests/ChangeLog 2012-01-24 22:25:32 UTC (rev 105810)
+++ trunk/LayoutTests/ChangeLog 2012-01-24 22:31:41 UTC (rev 105811)
@@ -1,3 +1,15 @@
+2012-01-24 Geoffrey Garen <[email protected]>
+
+ JSValue::toString() should return a JSString* instead of a UString
+ https://bugs.webkit.org/show_bug.cgi?id=76861
+
+ Reviewed by Gavin Barraclough.
+
+ Added a unit test for something I got wrong while writing this patch.
+
+ * fast/js/add-to-primitive-expected.txt: Added.
+ * fast/js/add-to-primitive.html: Added.
+
2012-01-24 Adam Barth <[email protected]>
Add expected results for test introduced in http://trac.webkit.org/changeset/105769
Added: trunk/LayoutTests/fast/js/add-to-primitive-expected.txt (0 => 105811)
--- trunk/LayoutTests/fast/js/add-to-primitive-expected.txt (rev 0)
+++ trunk/LayoutTests/fast/js/add-to-primitive-expected.txt 2012-01-24 22:31:41 UTC (rev 105811)
@@ -0,0 +1,4 @@
+This page tests that string addition prefers valueOf() over toString() for conversion. If the test passes, you'll see a PASS message below.
+
+PASS: '1' + valueOfIsZero should be 10 and is.
+
Added: trunk/LayoutTests/fast/js/add-to-primitive.html (0 => 105811)
--- trunk/LayoutTests/fast/js/add-to-primitive.html (rev 0)
+++ trunk/LayoutTests/fast/js/add-to-primitive.html 2012-01-24 22:31:41 UTC (rev 105811)
@@ -0,0 +1,29 @@
+<p>This page tests that string addition prefers valueOf() over toString() for conversion. If the test passes, you'll see a PASS message below.</p>
+
+<pre id="console"></pre>
+
+<script>
+function log(s)
+{
+ document.getElementById("console").appendChild(document.createTextNode(s + "\n"));
+}
+
+function shouldBe(a, aDescription, b)
+{
+ if (a === b)
+ log("PASS: " + aDescription + " should be " + b + " and is.");
+ else
+ log("FAIL: " + aDescription + " should be " + b + " but instead is " + a + ".");
+}
+
+if (this.layoutTestController)
+ layoutTestController.dumpAsText();
+
+var valueOfIsZero = {
+ valueOf: function valueOf() { return 0; },
+ toString: function toString() { return 1; }
+};
+
+shouldBe('1' + valueOfIsZero, "'1' + valueOfIsZero", "10");
+
+</script>
Modified: trunk/Source/_javascript_Core/ChangeLog (105810 => 105811)
--- trunk/Source/_javascript_Core/ChangeLog 2012-01-24 22:25:32 UTC (rev 105810)
+++ trunk/Source/_javascript_Core/ChangeLog 2012-01-24 22:31:41 UTC (rev 105811)
@@ -1,3 +1,19 @@
+2012-01-24 Geoffrey Garen <[email protected]>
+
+ JSValue::toString() should return a JSString* instead of a UString
+ https://bugs.webkit.org/show_bug.cgi?id=76861
+
+ Fixed two failing layout tests after my last patch.
+
+ Reviewed by Gavin Barraclough.
+
+ * runtime/ArrayPrototype.cpp:
+ (JSC::arrayProtoFuncSort): Call value() after calling toString(), as
+ in all other cases.
+
+ I missed this case because the JSString* type has a valid operator<,
+ so the compiler didn't complain.
+
2012-01-24 Kenichi Ishibashi <[email protected]>
[V8] Add Uint8ClampedArray support
Modified: trunk/Source/_javascript_Core/runtime/ArrayPrototype.cpp (105810 => 105811)
--- trunk/Source/_javascript_Core/runtime/ArrayPrototype.cpp 2012-01-24 22:25:32 UTC (rev 105810)
+++ trunk/Source/_javascript_Core/runtime/ArrayPrototype.cpp 2012-01-24 22:31:41 UTC (rev 105811)
@@ -571,7 +571,7 @@
l.append(minObj);
compareResult = call(exec, function, callType, callData, jsUndefined(), l).toNumber(exec);
} else
- compareResult = (jObj.toString(exec) < minObj.toString(exec)) ? -1 : 1;
+ compareResult = (jObj.toString(exec)->value(exec) < minObj.toString(exec)->value(exec)) ? -1 : 1;
if (compareResult < 0) {
themin = j;
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes