tor-browser

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

11.13.1-001.js (2142B)


      1 /* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */
      2 /* This Source Code Form is subject to the terms of the Mozilla Public
      3 * License, v. 2.0. If a copy of the MPL was not distributed with this
      4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
      5 
      6 /*
      7 *
      8 * Date:    08 May 2003
      9 * SUMMARY: JS should evaluate RHS before binding LHS implicit variable
     10 *
     11 * See http://bugzilla.mozilla.org/show_bug.cgi?id=204919
     12 *
     13 */
     14 //-----------------------------------------------------------------------------
     15 var UBound = 0;
     16 var BUGNUMBER = 204919;
     17 var summary = 'JS should evaluate RHS before binding LHS implicit variable';
     18 var TEST_PASSED = 'ReferenceError';
     19 var TEST_FAILED = 'Generated an error, but NOT a ReferenceError!';
     20 var TEST_FAILED_BADLY = 'Did not generate ANY error!!!';
     21 var status = '';
     22 var statusitems = [];
     23 var actual = '';
     24 var actualvalues = [];
     25 var expect= '';
     26 var expectedvalues = [];
     27 
     28 
     29 /*
     30 * global scope -
     31 */
     32 status = inSection(1);
     33 try
     34 {
     35  x = x;
     36  actual = TEST_FAILED_BADLY;
     37 }
     38 catch(e)
     39 {
     40  if (e instanceof ReferenceError)
     41    actual = TEST_PASSED;
     42  else
     43    actual = TEST_FAILED;
     44 }
     45 expect = TEST_PASSED;
     46 addThis();
     47 
     48 
     49 /*
     50 * function scope -
     51 */
     52 status = inSection(2);
     53 try
     54 {
     55  (function() {y = y;})();
     56  actual = TEST_FAILED_BADLY;
     57 }
     58 catch(e)
     59 {
     60  if (e instanceof ReferenceError)
     61    actual = TEST_PASSED;
     62  else
     63    actual = TEST_FAILED;
     64 }
     65 expect = TEST_PASSED;
     66 addThis();
     67 
     68 
     69 /*
     70 * eval scope -
     71 */
     72 status = inSection(3);
     73 try
     74 {
     75  eval('z = z');
     76  actual = TEST_FAILED_BADLY;
     77 }
     78 catch(e)
     79 {
     80  if (e instanceof ReferenceError)
     81    actual = TEST_PASSED;
     82  else
     83    actual = TEST_FAILED;
     84 }
     85 expect = TEST_PASSED;
     86 addThis();
     87 
     88 
     89 
     90 
     91 //-----------------------------------------------------------------------------
     92 test();
     93 //-----------------------------------------------------------------------------
     94 
     95 
     96 
     97 function addThis()
     98 {
     99  statusitems[UBound] = status;
    100  actualvalues[UBound] = actual;
    101  expectedvalues[UBound] = expect;
    102  UBound++;
    103 }
    104 
    105 
    106 function test()
    107 {
    108  printBugNumber(BUGNUMBER);
    109  printStatus(summary);
    110 
    111  for (var i=0; i<UBound; i++)
    112  {
    113    reportCompare(expectedvalues[i], actualvalues[i], statusitems[i]);
    114  }
    115 }