js/src/jit-test/tests/arrays/sort-getter-only.js

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

     1 // The property assignments in Array.prototype.sort are strict assignments.
     3 load(libdir + "asserts.js");
     5 var a = ["A", , "B", "C", "D"];
     6 var normalArrayElementDesc = Object.getOwnPropertyDescriptor(a, 0);
     7 var getterDesc = {
     8     configurable: false,
     9     enumerable: true,
    10     get: function () { return "F"; },
    11     set: undefined
    12 };
    13 Object.defineProperty(a, 1, getterDesc);
    15 // a.sort is permitted to try to delete a[1] or to try to assign a[1], but it
    16 // must try one or the other. Either one will fail, throwing a TypeError.
    17 assertThrowsInstanceOf(() => a.sort(), TypeError);
    19 // a.sort() is not permitted to delete the nonconfigurable property.
    20 assertDeepEq(Object.getOwnPropertyDescriptor(a, 1), getterDesc);
    22 // The values left in the other elements of a are unspecified; some or all may
    23 // have been deleted.
    24 for (var i = 0; i < a.length; i++) {
    25     if (i !== 1 && a.hasOwnProperty(i)) {
    26         normalArrayElementDesc.value = a[i];
    27         assertDeepEq(Object.getOwnPropertyDescriptor(a, i), normalArrayElementDesc);
    28     }
    29 }

mercurial