tor-browser

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

S12.10_A1.2_T4.js (3858B)


      1 // Copyright 2009 the Sputnik authors.  All rights reserved.
      2 // This code is governed by the BSD license found in the LICENSE file.
      3 
      4 /*---
      5 info: |
      6    The with statement adds a computed object to the front of the
      7    scope chain of the current execution context
      8 es5id: 12.10_A1.2_T4
      9 description: >
     10    Calling a function without "with" statement when the statement
     11    itself is declared within the function declaration, leading to
     12    completion by exception
     13 flags: [noStrict]
     14 ---*/
     15 
     16 this.p1 = 1;
     17 this.p2 = 2;
     18 this.p3 = 3;
     19 var result = "result";
     20 var myObj = {p1: 'a', 
     21             p2: 'b', 
     22             p3: 'c',
     23             value: 'myObj_value',
     24             valueOf : function(){return 'obj_valueOf';},
     25             parseInt : function(){return 'obj_parseInt';},
     26             NaN : 'obj_NaN',
     27             Infinity : 'obj_Infinity',
     28             eval     : function(){return 'obj_eval';},
     29             parseFloat : function(){return 'obj_parseFloat';},
     30             isNaN      : function(){return 'obj_isNaN';},
     31             isFinite   : function(){return 'obj_isFinite';}
     32 }
     33 var del;
     34 var st_p1 = "p1";
     35 var st_p2 = "p2";
     36 var st_p3 = "p3";
     37 var st_parseInt = "parseInt";
     38 var st_NaN = "NaN";
     39 var st_Infinity = "Infinity";
     40 var st_eval = "eval";
     41 var st_parseFloat = "parseFloat";
     42 var st_isNaN = "isNaN";
     43 var st_isFinite = "isFinite";
     44 
     45 try {
     46  var f = function(){
     47    with(myObj){
     48      st_p1 = p1;
     49      st_p2 = p2;
     50      st_p3 = p3;
     51      st_parseInt = parseInt;
     52      st_NaN = NaN;
     53      st_Infinity = Infinity;
     54      st_eval = eval;
     55      st_parseFloat = parseFloat;
     56      st_isNaN = isNaN;
     57      st_isFinite = isFinite;
     58      p1 = 'x1';
     59      this.p2 = 'x2';
     60      del = delete p3;
     61      var p4 = 'x4';
     62      p5 = 'x5';
     63      var value = 'value';
     64      throw value;
     65    }
     66  }
     67  f();
     68 } catch(e){
     69  result = e;
     70 }
     71 
     72 if(!(result === "value")){
     73  throw new Test262Error('#0: result === "value". Actual:  result ==='+ result  );
     74 }
     75 
     76 if(!(p1 === 1)){
     77  throw new Test262Error('#1: p1 === 1. Actual:  p1 ==='+ p1  );
     78 }
     79 
     80 if(!(p2 === "x2")){
     81  throw new Test262Error('#2: p2 === "x2". Actual:  p2 ==='+ p2  );
     82 }
     83 
     84 if(!(p3 === 3)){
     85  throw new Test262Error('#3: p3 === 3. Actual:  p3 ==='+ p3  );
     86 }
     87 
     88 try {
     89  p4;
     90  throw new Test262Error('#4: p4 is not defined');
     91 } catch(e) {    
     92 }
     93 
     94 if(!(p5 === "x5")){
     95  throw new Test262Error('#5: p5 === "x5". Actual:  p5 ==='+ p5  );
     96 }
     97 
     98 if(!(myObj.p1 === "x1")){
     99  throw new Test262Error('#6: myObj.p1 === "x1". Actual:  myObj.p1 ==='+ myObj.p1  );
    100 }
    101 
    102 if(!(myObj.p2 === "b")){
    103  throw new Test262Error('#7: myObj.p2 === "b". Actual:  myObj.p2 ==='+ myObj.p2  );
    104 }
    105 
    106 if(!(myObj.p3 === undefined)){
    107  throw new Test262Error('#8: myObj.p3 === undefined. Actual:  myObj.p3 ==='+ myObj.p3  );
    108 }
    109 
    110 if(!(myObj.p4 === undefined)){
    111  throw new Test262Error('#9: myObj.p4 === undefined. Actual:  myObj.p4 ==='+ myObj.p4  );
    112 }
    113 
    114 if(!(myObj.p5 === undefined)){
    115  throw new Test262Error('#10: myObj.p5 === undefined. Actual:  myObj.p5 ==='+ myObj.p5  );
    116 }
    117 
    118 if(!(st_parseInt !== parseInt)){
    119  throw new Test262Error('#11: myObj.parseInt !== parseInt');
    120 }
    121 
    122 if(!(st_NaN === "obj_NaN")){
    123  throw new Test262Error('#12: myObj.NaN !== NaN');
    124 }
    125 
    126 if(!(st_Infinity !== Infinity)){
    127  throw new Test262Error('#13: myObj.Infinity !== Infinity');
    128 }
    129 
    130 if(!(st_eval !== eval)){
    131  throw new Test262Error('#14: myObj.eval !== eval');
    132 }
    133 
    134 if(!(st_parseFloat !== parseFloat)){
    135  throw new Test262Error('#15: myObj.parseFloat !== parseFloat');
    136 }
    137 
    138 if(!(st_isNaN !== isNaN)){
    139  throw new Test262Error('#16: myObj.isNaN !== isNaN');
    140 }
    141 
    142 if(!(st_isFinite !== isFinite)){
    143  throw new Test262Error('#17: myObj.isFinite !== isFinite');
    144 }
    145 
    146 try{
    147  value;
    148  throw new Test262Error('#18: value is not defined');
    149 }
    150 catch(e){
    151 }
    152 
    153 if(!(myObj.value === "value")){
    154  throw new Test262Error('#19: myObj.value === "value". Actual:  myObj.value ==='+ myObj.value  );
    155 }
    156 
    157 reportCompare(0, 0);