tor-browser

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

regress-353116.js (1540B)


      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 var BUGNUMBER = 353116;
      8 var summary = 'Improve errors messages for null, undefined properties';
      9 var actual = '';
     10 var expect = '';
     11 
     12 
     13 //-----------------------------------------------------------------------------
     14 test();
     15 //-----------------------------------------------------------------------------
     16 
     17 function test()
     18 {
     19  printBugNumber(BUGNUMBER);
     20  printStatus (summary);
     21 
     22  expect = /TypeError: (undefined has no properties|can't access property "y" of undefined)/;
     23  actual = 'No Error';
     24 
     25  try
     26  {
     27    undefined.y;
     28  }
     29  catch(ex)
     30  {
     31    actual = ex + '';
     32  }
     33  reportMatch(expect, actual, summary);
     34 
     35  expect = /TypeError: (null has no properties|can't access property "y" of null)/;
     36  actual = 'No Error';
     37 
     38  try
     39  {
     40    null.y;
     41  }
     42  catch(ex)
     43  {
     44    actual = ex + '';
     45  }
     46  reportMatch(expect, actual, summary);
     47 
     48  expect = /TypeError: .*x is undefined/;
     49  actual = 'No Error';
     50 
     51  try
     52  {
     53    x = undefined; 
     54    x.y;
     55  }
     56  catch(ex)
     57  {
     58    actual = ex + '';
     59  }
     60  reportMatch(expect, actual, summary);
     61 
     62  expect = /TypeError: .*x is null/;
     63  actual = 'No Error';
     64 
     65  try
     66  {
     67    x = null; 
     68    x.y;
     69  }
     70  catch(ex)
     71  {
     72    actual = ex + '';
     73  }
     74  reportMatch(expect, actual, summary);
     75 }