tor-browser

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

test_rewrap_dead_wrapper.js (977B)


      1 /* This Source Code Form is subject to the terms of the Mozilla Public
      2 * License, v. 2.0. If a copy of the MPL was not distributed with this
      3 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
      4 
      5 /* See https://bugzilla.mozilla.org/show_bug.cgi?id=1354733 */
      6 
      7 const global = this;
      8 
      9 function run_test()
     10 {
     11  var sb = Cu.Sandbox(global);
     12  let obj = new sb.Object();
     13  Cu.nukeSandbox(sb);
     14 
     15  ok(Cu.isDeadWrapper(obj), "object should be a dead wrapper");
     16 
     17  // Create a new sandbox to wrap objects for.
     18 
     19  var sb = Cu.Sandbox(global);
     20  Cu.evalInSandbox(function echo(val) { return val; },
     21                   sb);
     22 
     23  let echoed = sb.echo(obj);
     24  ok(Cu.isDeadWrapper(echoed), "Rewrapped object should be a dead wrapper");
     25  ok(echoed !== obj, "Rewrapped object should be a new dead wrapper");
     26 
     27  ok(obj === obj, "Dead wrapper object should be equal to itself");
     28 
     29  let liveObj = {};
     30  ok(liveObj === sb.echo(liveObj), "Rewrapped live object should be equal to itself");
     31 }