tor-browser

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

test_bug872772.js (1290B)


      1 function run_test() {
      2 
      3  // Make a content sandbox with an Xrayable object.
      4  // NB: We use an nsEP here so that we can have access to Components, but still
      5  // have Xray behavior from this scope.
      6  var contentSB = new Cu.Sandbox(['http://www.google.com'],
      7                                 { wantGlobalProperties: ["XMLHttpRequest"] });
      8 
      9  // Make an XHR in the content sandbox.
     10  Cu.evalInSandbox('xhr = new XMLHttpRequest();', contentSB);
     11 
     12  // Make sure that waivers can be set as Xray expandos.
     13  var xhr = contentSB.xhr;
     14  Assert.ok(Cu.isXrayWrapper(xhr));
     15  xhr.unwaivedExpando = xhr;
     16  Assert.ok(Cu.isXrayWrapper(xhr.unwaivedExpando));
     17  var waived = xhr.wrappedJSObject;
     18  Assert.ok(!Cu.isXrayWrapper(waived));
     19  xhr.waivedExpando = waived;
     20  Assert.ok(!Cu.isXrayWrapper(xhr.waivedExpando));
     21 
     22  // Try the same thing for getters/setters, even though that's kind of
     23  // contrived.
     24  Cu.evalInSandbox('function f() {}', contentSB);
     25  var f = contentSB.f;
     26  var fWaiver = Cu.waiveXrays(f);
     27  Assert.ok(f != fWaiver);
     28  Assert.ok(Cu.unwaiveXrays(fWaiver) === f);
     29  Object.defineProperty(xhr, 'waivedAccessors', {get: fWaiver, set: fWaiver});
     30  var desc = Object.getOwnPropertyDescriptor(xhr, 'waivedAccessors');
     31  Assert.ok(desc.get === fWaiver);
     32  Assert.ok(desc.set === fWaiver);
     33 }