tor-browser

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

scope-001.js (1887B)


      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 = '53268';
      8 var status = 'Testing scope after changing obj.__proto__';
      9 var expect= '';
     10 var actual = '';
     11 var obj = {};
     12 
     13 Object.defineProperty(this, "five", {
     14  value: 5,
     15  enumerable: true,
     16  writable: false
     17 });
     18 
     19 
     20 //-----------------------------------------------------------------------------
     21 test();
     22 //-----------------------------------------------------------------------------
     23 
     24 
     25 function test()
     26 {
     27  printBugNumber(BUGNUMBER);
     28  printStatus (status);
     29 
     30 
     31  status= 'Step 1:  setting obj.__proto__ = global object';
     32  obj.__proto__ = this;
     33 
     34  actual = obj.five;
     35  expect=5;
     36  reportCompare (expect, actual, status);
     37 
     38  obj.five=1;
     39  actual = obj.five;
     40  expect=5;
     41  reportCompare (expect, actual, status);
     42 
     43 
     44 
     45  status= 'Step 2:  setting obj.__proto__ = null';
     46  obj.__proto__ = null;
     47 
     48  actual = obj.five;
     49  expect=undefined;
     50  reportCompare (expect, actual, status);
     51 
     52  obj.five=2;
     53  actual = obj.five;
     54  expect=2;
     55  reportCompare (expect, actual, status);
     56 
     57 
     58 
     59  status= 'Step 3:  setting obj.__proto__  to global object again';
     60  obj.__proto__ = this;
     61 
     62  actual = obj.five;
     63  expect=2;  //<--- (FROM STEP 2 ABOVE)
     64  reportCompare (expect, actual, status);
     65 
     66  obj.five=3;
     67  actual = obj.five;
     68  expect=3;
     69  reportCompare (expect, actual, status);
     70 
     71 
     72 
     73  status= 'Step 4:  setting obj.__proto__   to  null again';
     74  obj.__proto__ = null;
     75 
     76  actual = obj.five;
     77  expect=3;  //<--- (FROM STEP 3 ABOVE)
     78  reportCompare (expect, actual, status);
     79 
     80  obj.five=4;
     81  actual = obj.five;
     82  expect=4;
     83  reportCompare (expect, actual, status);
     84 }