tor-browser

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

call-bind-this-realm-value.js (1536B)


      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-ecmascript-function-objects-call-thisargument-argumentslist
      5 description: The "this" value is wrapped in an object using the callee realm
      6 info: |
      7  [...]
      8  6. Perform OrdinaryCallBindThis(F, calleeContext, thisArgument).
      9  [...]
     10 
     11  9.2.1.2OrdinaryCallBindThis ( F, calleeContext, thisArgument )#
     12 
     13  [...]
     14  5. If thisMode is strict, let thisValue be thisArgument.
     15  6. Else,
     16     a. If thisArgument is null or undefined, then
     17        [...]
     18     b. Else,
     19        i. Let thisValue be ! ToObject(thisArgument).
     20        ii. NOTE ToObject produces wrapper objects using calleeRealm.
     21  [...]
     22 features: [cross-realm]
     23 ---*/
     24 
     25 var other = $262.createRealm().global;
     26 var func = new other.Function('return this;');
     27 var subject;
     28 
     29 subject = func.call(true);
     30 assert.sameValue(subject.constructor, other.Boolean, 'boolean constructor');
     31 assert(subject instanceof other.Boolean, 'boolean instanceof');
     32 
     33 subject = func.call(1);
     34 assert.sameValue(subject.constructor, other.Number, 'number constructor');
     35 assert(subject instanceof other.Number, 'number instanceof');
     36 
     37 subject = func.call('');
     38 assert.sameValue(subject.constructor, other.String, 'string constructor');
     39 assert(subject instanceof other.String, 'string instanceof');
     40 
     41 subject = func.call({});
     42 assert.sameValue(subject.constructor, Object, 'object constructor');
     43 assert(subject instanceof Object, 'object instanceof');
     44 
     45 reportCompare(0, 0);