tor-browser

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

export-expname-binding-index.js (1279B)


      1 // |reftest| module
      2 // Copyright (C) 2021 Alexey Shvayka. All rights reserved.
      3 // This code is governed by the BSD license found in the LICENSE file.
      4 /*---
      5 esid: sec-module-namespace-exotic-objects
      6 description: >
      7  Internal methods of module namespace exotic objects are correct
      8  with non-Identifier bindings that are integer indices.
      9 info: |
     10  [[HasProperty]] ( P )
     11 
     12  [...]
     13  3. If P is an element of exports, return true.
     14  4. Return false.
     15 
     16  [[Get]] ( P, Receiver )
     17 
     18  [...]
     19  13. Return ? targetEnv.GetBindingValue(binding.[[BindingName]], true).
     20 
     21  [[Set]] ( P, V, Receiver )
     22 
     23  1. Return false.
     24 
     25  [[Delete]] ( P )
     26 
     27  [...]
     28  4. If P is an element of exports, return false.
     29  5. Return true.
     30 flags: [module]
     31 features: [arbitrary-module-namespace-names, Reflect]
     32 ---*/
     33 import * as ns from "./export-expname-binding-index_FIXTURE.js";
     34 
     35 assert.sameValue(ns[0], 0);
     36 assert.sameValue(Reflect.get(ns, 1), 1);
     37 assert.sameValue(ns[2], undefined);
     38 
     39 assert.throws(TypeError, () => { ns[0] = 1; });
     40 assert(!Reflect.set(ns, 1, 1));
     41 assert.throws(TypeError, () => { ns[2] = 2; });
     42 
     43 assert(0 in ns);
     44 assert(Reflect.has(ns, 1));
     45 assert(!(2 in ns));
     46 
     47 assert.throws(TypeError, () => { delete ns[0]; });
     48 assert(!Reflect.deleteProperty(ns, 1));
     49 assert(delete ns[2]);
     50 
     51 reportCompare(0, 0);