tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

nan-equivalence-define-own-property-reassign.js (2029B)


      1 // Copyright (C) 2016 the V8 project authors. All rights reserved.
      2 // This code is governed by the BSD license found in the LICENSE file.
      3 /*---
      4 esid: sec-ordinary-object-internal-methods-and-internal-slots-defineownproperty-p-desc
      5 description: >
      6  Replaces value field even if they pass in the SameValue algorithm, including
      7  distinct NaN values
      8 info: |
      9  This test does not compare the actual byte values, instead it simply checks that
     10  the value is some valid NaN encoding.
     11 
     12  ---
     13 
     14  Previously, this test compared the "value" field using the SameValue
     15  algorithm (thereby ignoring distinct NaN values)
     16 
     17  ---
     18 
     19  [[DefineOwnProperty]] (P, Desc)
     20 
     21  Return ? OrdinaryDefineOwnProperty(O, P, Desc).
     22 
     23  #sec-ordinarydefineownproperty
     24  OrdinaryDefineOwnProperty ( O, P, Desc )
     25 
     26  1. Let current be ? O.[[GetOwnProperty]](P).
     27  2. Let extensible be O.[[Extensible]].
     28  3. Return ValidateAndApplyPropertyDescriptor(O, P, extensible, Desc,
     29     current).
     30 
     31  #sec-validateandapplypropertydescriptor
     32  ValidateAndApplyPropertyDescriptor ( O, P, extensible, Desc, current )
     33 
     34  ...
     35  7. Else if IsDataDescriptor(current) and IsDataDescriptor(Desc) are both true,
     36     then
     37    a. If current.[[Configurable]] is false and current.[[Writable]] is false,
     38       then
     39      ...
     40  ...
     41  9. If O is not undefined, then
     42    a. For each field of Desc that is present, set the corresponding attribute
     43       of the property named P of object O to the value of the field.
     44  10. Return true.
     45 
     46  #sec-isnan-number
     47 
     48  NOTE: A reliable way for ECMAScript code to test if a value X is a NaN is
     49  an expression of the form  X !== X. The result will be true if and only
     50  if X is a NaN.
     51 includes: [nans.js]
     52 ---*/
     53 
     54 var len = NaNs.length;
     55 
     56 for (var idx = 0; idx < len; ++idx) {
     57  for (var jdx = 0; jdx < len; ++jdx) {
     58    var a = {};
     59 
     60    a.prop = NaNs[idx];
     61    a.prop = NaNs[jdx];
     62 
     63    assert(
     64      a.prop !== a.prop,
     65      `Object property value reassigned to NaN produced by (index=${idx}) results in a valid NaN`
     66    );
     67  }
     68 }
     69 
     70 reportCompare(0, 0);