[SCM] WebKit Debian packaging branch, debian/experimental, updated. upstream/1.3.3-9427-gc2be6fc

commit-queue at webkit.org commit-queue at webkit.org
Wed Dec 22 13:46:32 UTC 2010


The following commit has been merged in the debian/experimental branch:
commit e323843d46bbf0705a455904a85ec3b212c90d71
Author: commit-queue at webkit.org <commit-queue at webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date:   Sun Sep 26 21:26:24 2010 +0000

    2010-09-26  Mark Hahnenberg  <mhahnenb at gmail.com>
    
            Reviewed by Oliver Hunt.
    
            valueOf called in wrong order in atan2 and date constructors.
            https://bugs.webkit.org/show_bug.cgi?id=26978
    
            Fixed the issue where the parameters to the Date constructor
            were being evaluated to numbers more than once.
    
            * runtime/DateConstructor.cpp:
            (JSC::constructDate):
            (JSC::dateUTC):
    2010-09-26  Mark Hahnenberg  <mhahnenb at gmail.com>
    
            Reviewed by Oliver Hunt.
    
            valueOf called in wrong order in atan2 and date constructors.
            https://bugs.webkit.org/show_bug.cgi?id=26978
    
            Added regression test for the Date constructor issue.
    
            * fast/js/date-constructor-expected.txt:
            * fast/js/script-tests/date-constructor.js:
            (year.valueOf):
            (month.valueOf):
            (date.valueOf):
            (hours.valueOf):
            (minutes.valueOf):
            (seconds.valueOf):
            (ms.valueOf):
    
    git-svn-id: http://svn.webkit.org/repository/webkit/trunk@68347 268f45cc-cd09-0410-ab3c-d52691b4dbfc

diff --git a/JavaScriptCore/ChangeLog b/JavaScriptCore/ChangeLog
index f90b434..32cf06a 100644
--- a/JavaScriptCore/ChangeLog
+++ b/JavaScriptCore/ChangeLog
@@ -1,3 +1,17 @@
+2010-09-26  Mark Hahnenberg  <mhahnenb at gmail.com>
+
+        Reviewed by Oliver Hunt.
+
+        valueOf called in wrong order in atan2 and date constructors.
+        https://bugs.webkit.org/show_bug.cgi?id=26978
+
+        Fixed the issue where the parameters to the Date constructor
+        were being evaluated to numbers more than once.
+
+        * runtime/DateConstructor.cpp:
+        (JSC::constructDate):
+        (JSC::dateUTC):
+
 2010-09-25  Oliver Hunt  <oliver at apple.com>
 
         Fix various builds
diff --git a/JavaScriptCore/runtime/DateConstructor.cpp b/JavaScriptCore/runtime/DateConstructor.cpp
index 5b2f916..49e0405 100644
--- a/JavaScriptCore/runtime/DateConstructor.cpp
+++ b/JavaScriptCore/runtime/DateConstructor.cpp
@@ -90,25 +90,34 @@ JSObject* constructDate(ExecState* exec, const ArgList& args)
                 value = primitive.toNumber(exec);
         }
     } else {
-        if (isnan(args.at(0).toNumber(exec))
-                || isnan(args.at(1).toNumber(exec))
-                || (numArgs >= 3 && isnan(args.at(2).toNumber(exec)))
-                || (numArgs >= 4 && isnan(args.at(3).toNumber(exec)))
-                || (numArgs >= 5 && isnan(args.at(4).toNumber(exec)))
-                || (numArgs >= 6 && isnan(args.at(5).toNumber(exec)))
-                || (numArgs >= 7 && isnan(args.at(6).toNumber(exec))))
+        double doubleArguments[7] = {
+            args.at(0).toNumber(exec), 
+            args.at(1).toNumber(exec), 
+            args.at(2).toNumber(exec), 
+            args.at(3).toNumber(exec), 
+            args.at(4).toNumber(exec), 
+            args.at(5).toNumber(exec), 
+            args.at(6).toNumber(exec)
+        };
+        if (isnan(doubleArguments[0])
+                || isnan(doubleArguments[1])
+                || (numArgs >= 3 && isnan(doubleArguments[2]))
+                || (numArgs >= 4 && isnan(doubleArguments[3]))
+                || (numArgs >= 5 && isnan(doubleArguments[4]))
+                || (numArgs >= 6 && isnan(doubleArguments[5]))
+                || (numArgs >= 7 && isnan(doubleArguments[6])))
             value = NaN;
         else {
             GregorianDateTime t;
-            int year = args.at(0).toInt32(exec);
+            int year = JSC::toInt32(doubleArguments[0]);
             t.year = (year >= 0 && year <= 99) ? year : year - 1900;
-            t.month = args.at(1).toInt32(exec);
-            t.monthDay = (numArgs >= 3) ? args.at(2).toInt32(exec) : 1;
-            t.hour = args.at(3).toInt32(exec);
-            t.minute = args.at(4).toInt32(exec);
-            t.second = args.at(5).toInt32(exec);
+            t.month = JSC::toInt32(doubleArguments[1]);
+            t.monthDay = (numArgs >= 3) ? JSC::toInt32(doubleArguments[2]) : 1;
+            t.hour = JSC::toInt32(doubleArguments[3]);
+            t.minute = JSC::toInt32(doubleArguments[4]);
+            t.second = JSC::toInt32(doubleArguments[5]);
             t.isDST = -1;
-            double ms = (numArgs >= 7) ? args.at(6).toNumber(exec) : 0;
+            double ms = (numArgs >= 7) ? doubleArguments[6] : 0;
             value = gregorianDateTimeToMS(exec, t, ms, false);
         }
     }
@@ -160,25 +169,34 @@ static EncodedJSValue JSC_HOST_CALL dateNow(ExecState* exec)
 
 static EncodedJSValue JSC_HOST_CALL dateUTC(ExecState* exec) 
 {
+    double doubleArguments[7] = {
+        exec->argument(0).toNumber(exec), 
+        exec->argument(1).toNumber(exec), 
+        exec->argument(2).toNumber(exec), 
+        exec->argument(3).toNumber(exec), 
+        exec->argument(4).toNumber(exec), 
+        exec->argument(5).toNumber(exec), 
+        exec->argument(6).toNumber(exec)
+    };
     int n = exec->argumentCount();
-    if (isnan(exec->argument(0).toNumber(exec))
-            || isnan(exec->argument(1).toNumber(exec))
-            || (n >= 3 && isnan(exec->argument(2).toNumber(exec)))
-            || (n >= 4 && isnan(exec->argument(3).toNumber(exec)))
-            || (n >= 5 && isnan(exec->argument(4).toNumber(exec)))
-            || (n >= 6 && isnan(exec->argument(5).toNumber(exec)))
-            || (n >= 7 && isnan(exec->argument(6).toNumber(exec))))
+    if (isnan(doubleArguments[0])
+            || isnan(doubleArguments[1])
+            || (n >= 3 && isnan(doubleArguments[2]))
+            || (n >= 4 && isnan(doubleArguments[3]))
+            || (n >= 5 && isnan(doubleArguments[4]))
+            || (n >= 6 && isnan(doubleArguments[5]))
+            || (n >= 7 && isnan(doubleArguments[6])))
         return JSValue::encode(jsNaN(exec));
 
     GregorianDateTime t;
-    int year = exec->argument(0).toInt32(exec);
+    int year = JSC::toInt32(doubleArguments[0]);
     t.year = (year >= 0 && year <= 99) ? year : year - 1900;
-    t.month = exec->argument(1).toInt32(exec);
-    t.monthDay = (n >= 3) ? exec->argument(2).toInt32(exec) : 1;
-    t.hour = exec->argument(3).toInt32(exec);
-    t.minute = exec->argument(4).toInt32(exec);
-    t.second = exec->argument(5).toInt32(exec);
-    double ms = (n >= 7) ? exec->argument(6).toNumber(exec) : 0;
+    t.month = JSC::toInt32(doubleArguments[1]);
+    t.monthDay = (n >= 3) ? JSC::toInt32(doubleArguments[2]) : 1;
+    t.hour = JSC::toInt32(doubleArguments[3]);
+    t.minute = JSC::toInt32(doubleArguments[4]);
+    t.second = JSC::toInt32(doubleArguments[5]);
+    double ms = (n >= 7) ? doubleArguments[6] : 0;
     return JSValue::encode(jsNumber(exec, timeClip(gregorianDateTimeToMS(exec, t, ms, true))));
 }
 
diff --git a/LayoutTests/ChangeLog b/LayoutTests/ChangeLog
index 849a2ea..de70931 100644
--- a/LayoutTests/ChangeLog
+++ b/LayoutTests/ChangeLog
@@ -1,3 +1,22 @@
+2010-09-26  Mark Hahnenberg  <mhahnenb at gmail.com>
+
+        Reviewed by Oliver Hunt.
+
+        valueOf called in wrong order in atan2 and date constructors.
+        https://bugs.webkit.org/show_bug.cgi?id=26978
+
+        Added regression test for the Date constructor issue.
+
+        * fast/js/date-constructor-expected.txt:
+        * fast/js/script-tests/date-constructor.js:
+        (year.valueOf):
+        (month.valueOf):
+        (date.valueOf):
+        (hours.valueOf):
+        (minutes.valueOf):
+        (seconds.valueOf):
+        (ms.valueOf):
+
 2010-09-26  Sheriff Bot  <webkit.review.bot at gmail.com>
 
         Unreviewed, rolling out r68343.
diff --git a/LayoutTests/fast/js/date-constructor-expected.txt b/LayoutTests/fast/js/date-constructor-expected.txt
index 233c999..efcc006 100644
--- a/LayoutTests/fast/js/date-constructor-expected.txt
+++ b/LayoutTests/fast/js/date-constructor-expected.txt
@@ -24,6 +24,8 @@ PASS new Date(new Date(1111, 1, 1, 1, 1, 1)).getTime() - timeZoneOffset is -2710
 PASS new Date(new Date(1111, 1, 1, 1, 1, 1, 1)).getTime() - timeZoneOffset is -27104799538999
 PASS new Date(new Date(1111, 1, 1, 1, 1, 1, 1, 1)).getTime() - timeZoneOffset is -27104799538999
 PASS new Date(new Date(1111, 1, 1, 1, 1, 1, 1, 1, 1)).getTime() - timeZoneOffset is -27104799538999
+PASS testStr is "1234567"
+PASS testStr is "1234567"
 PASS successfullyParsed is true
 
 TEST COMPLETE
diff --git a/LayoutTests/fast/js/script-tests/date-constructor.js b/LayoutTests/fast/js/script-tests/date-constructor.js
index ffe0b0a..203d49d 100644
--- a/LayoutTests/fast/js/script-tests/date-constructor.js
+++ b/LayoutTests/fast/js/script-tests/date-constructor.js
@@ -40,4 +40,22 @@ shouldBe('new Date(new Date(1111, 1, 1, 1, 1, 1, 1, 1, 1)).getTime() - timeZoneO
 // shouldBe('new Date(1111, 1111, 1111, 1111, 1111, 1111, 1111, 1111).getTime() - timeZoneOffset', '-24085894227889');
 // shouldBe('new Date(new Date(1111, 1111, 1111, 1111, 1111, 1111, 1111, 1111)).getTime() - timeZoneOffset', '-24085894227889');
 
+// Regression test for Bug 26978 (https://bugs.webkit.org/show_bug.cgi?id=26978)
+var testStr = "";
+var year = { valueOf: function() { testStr += 1; return 2007; } };
+var month = { valueOf: function() { testStr += 2; return 2; } };
+var date = { valueOf: function() { testStr += 3; return 4; } };
+var hours = { valueOf: function() { testStr += 4; return 13; } };
+var minutes = { valueOf: function() { testStr += 5; return 50; } };
+var seconds = { valueOf: function() { testStr += 6; return 0; } };
+var ms = { valueOf: function() { testStr += 7; return 999; } };
+
+testStr = "";
+new Date(year, month, date, hours, minutes, seconds, ms);
+shouldBe('testStr', '\"1234567\"');
+
+testStr = "";
+Date.UTC(year, month, date, hours, minutes, seconds, ms);
+shouldBe('testStr', '\"1234567\"');
+
 var successfullyParsed = true;

-- 
WebKit Debian packaging



More information about the Pkg-webkit-commits mailing list