diff --git a/js/src/builtin/TypedArray.js b/js/src/builtin/TypedArray.js index d4feb13e730b..a1c17c0b89cc 100644 --- a/js/src/builtin/TypedArray.js +++ b/js/src/builtin/TypedArray.js @@ -1018,26 +1018,10 @@ function TypedArraySort(comparefn) { var v = +comparefn(x, y); // Step b. - var length; - if (isTypedArray) { - length = TypedArrayLength(obj); - } else { - length = callFunction(CallTypedArrayMethodIfWrapped, obj, "TypedArrayLengthMethod"); - } - - // It's faster for us to check the typed array's length than to check - // for detached buffers. - if (length === 0) { - assert(PossiblyWrappedTypedArrayHasDetachedBuffer(obj), - "Length can only change from non-zero to zero when the buffer was detached"); - ThrowTypeError(JSMSG_TYPED_ARRAY_DETACHED); - } - - // Step c. if (v !== v) return 0; - // Step d. + // Step c. return v; }; diff --git a/js/src/tests/jstests.list b/js/src/tests/jstests.list index 3df6cbaa1004..6d9c5b613cca 100644 --- a/js/src/tests/jstests.list +++ b/js/src/tests/jstests.list @@ -609,9 +609,6 @@ skip script test262/built-ins/RegExp/named-groups/non-unicode-property-names-val # https://bugzilla.mozilla.org/show_bug.cgi?id=1761989 skip script test262/built-ins/TypedArrayConstructors/ctors/no-species.js -# https://bugzilla.mozilla.org/show_bug.cgi?id=1763606 -skip script test262/built-ins/TypedArray/prototype/sort/sort-tonumber.js - ########################################################### # Tests disabled due to issues in test262 importer script # diff --git a/js/src/tests/non262/TypedArray/sort_errors.js b/js/src/tests/non262/TypedArray/sort_errors.js index 603768e39241..f3bdc05b2012 100644 --- a/js/src/tests/non262/TypedArray/sort_errors.js +++ b/js/src/tests/non262/TypedArray/sort_errors.js @@ -8,18 +8,18 @@ if (typeof detachArrayBuffer === "function") { }, TypeError); } -// Ensure detachment check works when buffer is detached in comparator. +// Ensure detaching buffer in comparator doesn't throw an error. if (typeof detachArrayBuffer === "function") { let detached = false; let ta = new Int32Array(3); - assertThrowsInstanceOf(() => { - ta.sort(function(a, b) { - assertEq(detached, false); + ta.sort(function(a, b) { + if (!detached) { detached = true; detachArrayBuffer(ta.buffer); - return a - b; - }); - }, TypeError); + } + return a - b; + }); + assertEq(detached, true); } // Ensure detachment check doesn't choke on wrapped typed array. @@ -31,19 +31,19 @@ if (typeof newGlobal === "function") { }); } -// Ensure detachment check works for wrapped typed arrays. +// Ensure detaching buffer in comparator doesn't throw an error when the typed array is wrapped. if (typeof newGlobal === "function" && typeof detachArrayBuffer === "function") { let detached = false; let ta = new Int32Array(3); let otherGlobal = newGlobal(); - assertThrowsInstanceOf(() => { - otherGlobal.Int32Array.prototype.sort.call(ta, function(a,b) { - assertEq(detached, false); + otherGlobal.Int32Array.prototype.sort.call(ta, function(a,b) { + if (!detached) { detached = true; detachArrayBuffer(ta.buffer); - return a - b; - }); - }, otherGlobal.TypeError); + } + return a - b; + }); + assertEq(detached, true); } // Ensure that TypedArray.prototype.sort will not sort non-TypedArrays