tor-browser

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

regress-452742-01.js (1176B)


      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 = 452742;
      8 var summary = 'Do not do overzealous eval inside function optimization in BindNameToSlot';
      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 = actual = 'No Error';
     23 
     24  var obj = { x: -100 };
     25 
     26  function a(x)
     27  {
     28    var orig_x = x;
     29    var orig_obj_x = obj.x;
     30 
     31    with (obj) { eval("x = x + 10"); }
     32 
     33    if (x !== orig_x)
     34      throw "Unexpected mutation of x: " + x;
     35    if (obj.x !== orig_obj_x + 10)
     36      throw "Unexpected mutation of obj.x: " + obj.x;
     37  }
     38 
     39  try
     40  {
     41    a(0);
     42  }
     43  catch(ex)
     44  {
     45    actual = ex + '';
     46  }
     47  reportCompare(expect, actual, summary);
     48 }