tor-browser

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

regress-231518.js (1924B)


      1 // |reftest| skip-if(!this.uneval)
      2 
      3 /* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */
      4 /* This Source Code Form is subject to the terms of the Mozilla Public
      5 * License, v. 2.0. If a copy of the MPL was not distributed with this
      6 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
      7 
      8 //-----------------------------------------------------------------------------
      9 var BUGNUMBER = 231518;
     10 var summary = 'decompiler must quote keywords and non-identifier property names';
     11 var actual = '';
     12 var expect = 'no error';
     13 var status;
     14 var object;
     15 var result;
     16 
     17 printBugNumber(BUGNUMBER);
     18 printStatus (summary);
     19 
     20  status = inSection(1) + ' eval(uneval({"if": false}))';
     21 
     22  try
     23  {
     24    object = {'if': false };
     25    result = uneval(object);
     26    printStatus('uneval returns ' + result);
     27    eval(result);
     28    actual = 'no error';
     29  }
     30  catch(e)
     31  {
     32    actual = 'error';
     33  }
     34 
     35  reportCompare(expect, actual, status);
     36 
     37  status = inSection(2) + ' eval(uneval({"if": "then"}))';
     38 
     39  try
     40  {
     41    object = {'if': "then" };
     42    result = uneval(object);
     43    printStatus('uneval returns ' + result);
     44    eval(result);
     45    actual = 'no error';
     46  }
     47  catch(e)
     48  {
     49    actual = 'error';
     50  }
     51 
     52  reportCompare(expect, actual, status);
     53 
     54  status = inSection(3) + ' eval(uneval(f))';
     55 
     56  try
     57  {
     58    result = uneval(f);
     59    printStatus('uneval returns ' + result);
     60    eval(result);
     61    actual = 'no error';
     62  }
     63  catch(e)
     64  {
     65    actual = 'error';
     66  }
     67 
     68  reportCompare(expect, actual, status);
     69 
     70  status = inSection(2) + ' eval(uneval(g))';
     71 
     72  try
     73  {
     74    result = uneval(g);
     75    printStatus('uneval returns ' + result);
     76    eval(result);
     77    actual = 'no error';
     78  }
     79  catch(e)
     80  {
     81    actual = 'error';
     82  }
     83 
     84  reportCompare(expect, actual, status);
     85 
     86 function f()
     87 {
     88  var obj = new Object();
     89 
     90  obj['name']      = 'Just a name';
     91  obj['if']        = false;
     92  obj['some text'] = 'correct';
     93 }
     94 
     95 function g()
     96 {
     97  return {'if': "then"};
     98 }