tor-browser

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

non-object-argument-invalid.js (1053B)


      1 // Copyright (C) 2020 Rick Waldron. All rights reserved.
      2 // This code is governed by the BSD license found in the LICENSE file.
      3 /*---
      4 esid: sec-object.getownpropertynames
      5 description: >
      6    Object.getOwnPropertyNames called with an invalid non-object value
      7 info: |
      8  GetOwnPropertyKeys ( O, type )
      9 
     10  Let obj be ? ToObject(O).
     11  Let keys be ? obj.[[OwnPropertyKeys]]().
     12  Let nameList be a new empty List.
     13  For each element nextKey of keys, do
     14    If Type(nextKey) is Symbol and type is symbol or Type(nextKey) is String and type is string, then
     15      Append nextKey as the last element of nameList.
     16  Return CreateArrayFromList(nameList).
     17 
     18 features: [Symbol]
     19 ---*/
     20 
     21 let count = 0;
     22 
     23 assert.throws(TypeError, () => {
     24  count++;
     25  Object.getOwnPropertyNames(undefined);
     26 }, '`Object.getOwnPropertyNames(undefined)` throws TypeError');
     27 
     28 assert.throws(TypeError, () => {
     29  count++;
     30  Object.getOwnPropertyNames(null);
     31 }, '`Object.getOwnPropertyNames(null)` throws TypeError');
     32 
     33 assert.sameValue(count, 2, 'The value of `count` is 2');
     34 
     35 reportCompare(0, 0);