JavaScriptCore:
authorggaren <ggaren@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 14 Jul 2005 17:24:31 +0000 (17:24 +0000)
committerggaren <ggaren@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 14 Jul 2005 17:24:31 +0000 (17:24 +0000)
-landed fix for http://bugzilla.opendarwin.org/show_bug.cgi?id=3412
Object.prototype is missing toLocaleString

- patch by Mark Rowe (bdash) <opendarwin.org@bdash.net.nz>

-layout test info in webcore changelog

        Reviewed by mjs.

        * kjs/object_object.cpp:
        (ObjectPrototypeImp::ObjectPrototypeImp):
        (ObjectProtoFuncImp::call):
        * kjs/object_object.h:
        (KJS::ObjectProtoFuncImp::):

WebCore:

-landed layout test for http://bugzilla.opendarwin.org/show_bug.cgi?id=3412
Object.prototype is missing toLocaleString

        Reviewed by mjs.

        Test cases added:
        * layout-tests/fast/js/object-prototype-toLocaleString-expected.txt: Added.
        * layout-tests/fast/js/object-prototype-toLocaleString.html: Added.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@9758 268f45cc-cd09-0410-ab3c-d52691b4dbfc

JavaScriptCore/ChangeLog
JavaScriptCore/kjs/object_object.cpp
JavaScriptCore/kjs/object_object.h
LayoutTests/fast/js/object-prototype-toLocaleString-expected.txt [new file with mode: 0644]
LayoutTests/fast/js/object-prototype-toLocaleString.html [new file with mode: 0644]
WebCore/ChangeLog-2005-08-23

index edcde0189cee0be4a918326c60209d8865b8450e..f8066a4b6322e21ea7058e531a64ad1af8f0d061 100644 (file)
@@ -1,3 +1,20 @@
+2005-07-14  Geoffrey Garen  <ggaren@apple.com>
+       
+       -landed fix for http://bugzilla.opendarwin.org/show_bug.cgi?id=3412
+       Object.prototype is missing toLocaleString
+
+       - patch by Mark Rowe (bdash) <opendarwin.org@bdash.net.nz>
+       
+       -layout test info in webcore changelog
+
+        Reviewed by mjs.
+
+        * kjs/object_object.cpp:
+        (ObjectPrototypeImp::ObjectPrototypeImp):
+        (ObjectProtoFuncImp::call):
+        * kjs/object_object.h:
+        (KJS::ObjectProtoFuncImp::):
+
 2005-07-12  Geoffrey Garen  <ggaren@apple.com>
 
         Reviewed by mjs.
index 3a2c947864d17906eb329afe6fabc2c9e8a78ab0..044320f5924c4dd7bcf4644b22370a6507595efe 100644 (file)
@@ -38,9 +38,10 @@ ObjectPrototypeImp::ObjectPrototypeImp(ExecState *exec,
   : ObjectImp() // [[Prototype]] is Null()
 {
     Value protect(this);
-    putDirect(toStringPropertyName, new ObjectProtoFuncImp(exec,funcProto,ObjectProtoFuncImp::ToString,  0), DontEnum);
-    putDirect(valueOfPropertyName,  new ObjectProtoFuncImp(exec,funcProto,ObjectProtoFuncImp::ValueOf,   0), DontEnum);
-    putDirect("hasOwnProperty", new ObjectProtoFuncImp(exec,funcProto,ObjectProtoFuncImp::HasOwnProperty,1), DontEnum);
+    putDirect(toStringPropertyName, new ObjectProtoFuncImp(exec,funcProto,ObjectProtoFuncImp::ToString,            0), DontEnum);
+    putDirect(toLocaleStringPropertyName, new ObjectProtoFuncImp(exec,funcProto,ObjectProtoFuncImp::ToLocaleString,0), DontEnum);
+    putDirect(valueOfPropertyName,  new ObjectProtoFuncImp(exec,funcProto,ObjectProtoFuncImp::ValueOf,             0), DontEnum);
+    putDirect("hasOwnProperty", new ObjectProtoFuncImp(exec,funcProto,ObjectProtoFuncImp::HasOwnProperty,          1), DontEnum);
 }
 
 
@@ -74,6 +75,8 @@ Value ObjectProtoFuncImp::call(ExecState *exec, Object &thisObj, const List &arg
             bool exists = thisObj.hasOwnProperty(exec, propertyName);
             return Value(exists ? BooleanImp::staticTrue : BooleanImp::staticFalse);
         }
+        case ToLocaleString:
+          return thisObj.imp()->toString(exec);
         case ToString:
         default:
             return String("[object " + thisObj.className() + "]");
index 518917e33ffedf390a4dcf2b69d47c7db0e78bbe..2d4232f999b5bceb0cb2846b1722e2392e51332c 100644 (file)
@@ -53,7 +53,7 @@ namespace KJS {
     virtual bool implementsCall() const;
     virtual Value call(ExecState *exec, Object &thisObj, const List &args);
 
-    enum { ToString, ValueOf, HasOwnProperty };
+    enum { ToString, ToLocaleString, ValueOf, HasOwnProperty };
   private:
     int id;
   };
diff --git a/LayoutTests/fast/js/object-prototype-toLocaleString-expected.txt b/LayoutTests/fast/js/object-prototype-toLocaleString-expected.txt
new file mode 100644 (file)
index 0000000..016ad79
--- /dev/null
@@ -0,0 +1,7 @@
+Tests: Object.prototype.toLocaleString()
+
+Related bug: 3989 JSC doesn't implement Object.prototype.toLocaleString()
+
+Object.toLocaleString() (should be "[object Object]"): [object Object]
+
+Object.toLocaleString() (should be "Dynamic toLocaleString()"): Dynamic toLocaleString()
diff --git a/LayoutTests/fast/js/object-prototype-toLocaleString.html b/LayoutTests/fast/js/object-prototype-toLocaleString.html
new file mode 100644 (file)
index 0000000..c7701dc
--- /dev/null
@@ -0,0 +1,34 @@
+<html>
+<head>
+<script>
+function print(message) {
+       var paragraph = document.createElement("p");
+       paragraph.appendChild(document.createTextNode(message));
+       document.getElementById("console").appendChild(paragraph);
+}
+
+function test() {
+       if (window.layoutTestController) {
+               layoutTestController.dumpAsText();
+       }
+
+    try {
+        var o = new Object();
+        print("Object.toLocaleString() (should be \"" + o.toString() + "\"): " + o.toLocaleString());
+        
+        o.toLocaleString = function () { return "Dynamic toLocaleString()"; }
+        print("Object.toLocaleString() (should be \"Dynamic toLocaleString()\"): " + o.toLocaleString());
+    }
+    catch (e) {
+        print("Test failed. Threw exception: " + e);
+    }
+}
+</script>
+</head>
+<body onload="test();">
+<p>Tests: Object.prototype.toLocaleString()</p>
+<p>Related bug: <a href = "http://bugzilla.opendarwin.org/show_bug.cgi?id=3989">3989 JSC doesn't implement Object.prototype.toLocaleString()</a></p>
+<hr>
+<div id='console'/>
+</body>
+</html>
index 427b44d90c0be2a36105659987bdba8edd442b09..6ad0ffd4e559f3f54026c70d0ab98afc6fa10bee 100644 (file)
@@ -1,3 +1,14 @@
+2005-07-14  Geoffrey Garen  <ggaren@apple.com>
+
+       -landed layout test for http://bugzilla.opendarwin.org/show_bug.cgi?id=3412
+       Object.prototype is missing toLocaleString
+
+        Reviewed by mjs.
+
+        Test cases added:
+        * layout-tests/fast/js/object-prototype-toLocaleString-expected.txt: Added.
+        * layout-tests/fast/js/object-prototype-toLocaleString.html: Added.
+
 2005-07-14  Vicki Murley  <vicki@apple.com>
 
         Reviewed by Kocienda.