tor-browser

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

symbol-hasinstance-invocation.js (883B)


      1 // Copyright (C) 2015 the V8 project authors. All rights reserved.
      2 // This code is governed by the BSD license found in the LICENSE file.
      3 
      4 /*---
      5 es6id: 12.9.4
      6 description: >
      7    Arguments and 'this' value when invoking constructor's @@hasInstance property
      8 info: |
      9    1. If Type(C) is not Object, throw a TypeError exception.
     10    2. Let instOfHandler be GetMethod(C,@@hasInstance).
     11    3. ReturnIfAbrupt(instOfHandler).
     12    4. If instOfHandler is not undefined, then
     13       a. Return ToBoolean(Call(instOfHandler, C, «O»)).
     14 features: [Symbol.hasInstance]
     15 ---*/
     16 
     17 var F = {};
     18 var callCount = 0;
     19 var thisValue, args;
     20 
     21 F[Symbol.hasInstance] = function() {
     22  thisValue = this;
     23  args = arguments;
     24  callCount += 1;
     25 };
     26 
     27 0 instanceof F;
     28 
     29 assert.sameValue(callCount, 1);
     30 assert.sameValue(thisValue, F);
     31 assert.sameValue(args.length, 1);
     32 assert.sameValue(args[0], 0);
     33 
     34 reportCompare(0, 0);