Title: [267554] trunk
Revision
267554
Author
[email protected]
Date
2020-09-24 19:51:45 -0700 (Thu, 24 Sep 2020)

Log Message

%TypedArray%.prototype.sort must throw if comparator is defined and uncallable
https://bugs.webkit.org/show_bug.cgi?id=216952

Reviewed by Yusuke Suzuki.

JSTests:

* stress/typedarray-sort.js:
Fix test.

* test262/expectations.yaml:
Mark two test cases as passing.

Source/_javascript_Core:

* builtins/TypedArrayPrototype.js:
(sort):

Modified Paths

Diff

Modified: trunk/JSTests/ChangeLog (267553 => 267554)


--- trunk/JSTests/ChangeLog	2020-09-24 23:59:10 UTC (rev 267553)
+++ trunk/JSTests/ChangeLog	2020-09-25 02:51:45 UTC (rev 267554)
@@ -1,5 +1,18 @@
 2020-09-24  Ross Kirsling  <[email protected]>
 
+        %TypedArray%.prototype.sort must throw if comparator is defined and uncallable
+        https://bugs.webkit.org/show_bug.cgi?id=216952
+
+        Reviewed by Yusuke Suzuki.
+
+        * stress/typedarray-sort.js:
+        Fix test.
+
+        * test262/expectations.yaml:
+        Mark two test cases as passing.
+
+2020-09-24  Ross Kirsling  <[email protected]>
+
         %TypedArray%.prototype.{map, filter} should perform TypedArraySpeciesCreate correctly
         https://bugs.webkit.org/show_bug.cgi?id=216938
 

Modified: trunk/JSTests/stress/typedarray-sort.js (267553 => 267554)


--- trunk/JSTests/stress/typedarray-sort.js	2020-09-24 23:59:10 UTC (rev 267553)
+++ trunk/JSTests/stress/typedarray-sort.js	2020-09-25 02:51:45 UTC (rev 267554)
@@ -49,9 +49,9 @@
 debug("");
 
 debug("4.0 Wrong Type for Callback Test");
-shouldBeTrue("testPrototypeFunction('sort', '(8)', [12, 15, 10, 13, 44], [10, 12, 13, 15, 44])");
-shouldBeTrue("testPrototypeFunction('sort', '(\"wrong\")', [12, 15, 10, 13, 44], [10, 12, 13, 15, 44])");
-shouldBeTrue("testPrototypeFunction('sort', '(new Object())', [12, 15, 10, 13, 44], [10, 12, 13, 15, 44])");
-shouldBeTrue("testPrototypeFunction('sort', '(null)', [12, 15, 10, 13, 44], [10, 12, 13, 15, 44])");
+shouldThrow("testPrototypeFunction('sort', '(8)', [12, 15, 10, 13, 44], [10, 12, 13, 15, 44])");
+shouldThrow("testPrototypeFunction('sort', '(\"wrong\")', [12, 15, 10, 13, 44], [10, 12, 13, 15, 44])");
+shouldThrow("testPrototypeFunction('sort', '(new Object())', [12, 15, 10, 13, 44], [10, 12, 13, 15, 44])");
+shouldThrow("testPrototypeFunction('sort', '(null)', [12, 15, 10, 13, 44], [10, 12, 13, 15, 44])");
 debug("");
 finishJSTest();

Modified: trunk/JSTests/test262/expectations.yaml (267553 => 267554)


--- trunk/JSTests/test262/expectations.yaml	2020-09-24 23:59:10 UTC (rev 267553)
+++ trunk/JSTests/test262/expectations.yaml	2020-09-25 02:51:45 UTC (rev 267554)
@@ -1251,9 +1251,6 @@
 test/built-ins/TypedArray/prototype/slice/detached-buffer-zero-count-custom-ctor-same-targettype.js:
   default: 'TypeError: Underlying ArrayBuffer has been detached from the view (Testing with Float64Array.)'
   strict mode: 'TypeError: Underlying ArrayBuffer has been detached from the view (Testing with Float64Array.)'
-test/built-ins/TypedArray/prototype/sort/comparefn-nonfunction-call-throws.js:
-  default: 'Test262Error: Expected a TypeError to be thrown but no exception was thrown at all (Testing with Float64Array.)'
-  strict mode: 'Test262Error: Expected a TypeError to be thrown but no exception was thrown at all (Testing with Float64Array.)'
 test/built-ins/TypedArray/prototype/toLocaleString/calls-tostring-from-each-value.js:
   default: 'Test262Error: should not call valueOf if toString is present (Testing with Float64Array.)'
   strict mode: 'Test262Error: should not call valueOf if toString is present (Testing with Float64Array.)'

Modified: trunk/Source/_javascript_Core/ChangeLog (267553 => 267554)


--- trunk/Source/_javascript_Core/ChangeLog	2020-09-24 23:59:10 UTC (rev 267553)
+++ trunk/Source/_javascript_Core/ChangeLog	2020-09-25 02:51:45 UTC (rev 267554)
@@ -1,5 +1,15 @@
 2020-09-24  Ross Kirsling  <[email protected]>
 
+        %TypedArray%.prototype.sort must throw if comparator is defined and uncallable
+        https://bugs.webkit.org/show_bug.cgi?id=216952
+
+        Reviewed by Yusuke Suzuki.
+
+        * builtins/TypedArrayPrototype.js:
+        (sort):
+
+2020-09-24  Ross Kirsling  <[email protected]>
+
         %TypedArray% methods should perform TypedArraySpeciesCreate correctly
         https://bugs.webkit.org/show_bug.cgi?id=216938
 

Modified: trunk/Source/_javascript_Core/builtins/TypedArrayPrototype.js (267553 => 267554)


--- trunk/Source/_javascript_Core/builtins/TypedArrayPrototype.js	2020-09-24 23:59:10 UTC (rev 267553)
+++ trunk/Source/_javascript_Core/builtins/TypedArrayPrototype.js	2020-09-25 02:51:45 UTC (rev 267554)
@@ -217,16 +217,18 @@
         }
     }
 
+    if (comparator !== @undefined && !@isCallable(comparator))
+        @throwTypeError("TypedArray.prototype.sort requires the comparator argument to be a function or undefined");
+
     var length = @typedArrayLength(this);
-
     if (length < 2)
         return;
 
-    if (@isCallable(comparator))
+    if (comparator !== @undefined)
         mergeSort(this, length, comparator);
     else
         @typedArraySort(this);
-    
+
     return this;
 }
 
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to