tor-browser

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

restricted-properties.js (1356B)


      1 // Copyright (C) 2015 Caitlin Potter. All rights reserved.
      2 // This code is governed by the BSD license found in the LICENSE file.
      3 
      4 /*---
      5 description: >
      6    Functions created using ClassDeclaration syntactic form do not have own
      7    properties "caller" or "arguments", but inherit them from
      8    %FunctionPrototype%.
      9 es6id: 16.1
     10 ---*/
     11 
     12 class BaseClass {}
     13 
     14 assert.sameValue(
     15  BaseClass.hasOwnProperty('caller'), false, 'No "caller" own property'
     16 );
     17 assert.sameValue(
     18  BaseClass.hasOwnProperty('arguments'), false, 'No "arguments" own property'
     19 );
     20 
     21 assert.throws(TypeError, function() {
     22  return BaseClass.caller;
     23 });
     24 
     25 assert.throws(TypeError, function() {
     26  BaseClass.caller = {};
     27 });
     28 
     29 assert.throws(TypeError, function() {
     30  return BaseClass.arguments;
     31 });
     32 
     33 assert.throws(TypeError, function() {
     34  BaseClass.arguments = {};
     35 });
     36 
     37 class SubClass extends BaseClass {}
     38 
     39 assert.sameValue(
     40  SubClass.hasOwnProperty('caller'), false, 'No "caller" own property'
     41 );
     42 assert.sameValue(
     43  SubClass.hasOwnProperty('arguments'), false, 'No "arguments" own property'
     44 );
     45 
     46 assert.throws(TypeError, function() {
     47  return SubClass.caller;
     48 });
     49 
     50 assert.throws(TypeError, function() {
     51  SubClass.caller = {};
     52 });
     53 
     54 assert.throws(TypeError, function() {
     55  return SubClass.arguments;
     56 });
     57 
     58 assert.throws(TypeError, function() {
     59  SubClass.arguments = {};
     60 });
     61 
     62 reportCompare(0, 0);