tor-browser

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

Frame-onPop-17.js (1332B)


      1 // onPop surfaces.
      2 load(libdir + "asserts.js");
      3 
      4 var g = newGlobal({newCompartment: true});
      5 var dbg = new Debugger(g);
      6 
      7 // Assigning a bogus value to Debugger.Frame.prototype.onPop raises a TypeError.
      8 function test(badValue) {
      9    print("store " + JSON.stringify(badValue) + " in Debugger.Frame.prototype.onPop");
     10 
     11    var log;
     12    dbg.onDebuggerStatement = function handleDebugger(frame) {
     13        log += "d";
     14        assertThrowsInstanceOf(function () { frame.onPop = badValue; }, TypeError);
     15    };
     16 
     17    log = "";
     18    g.eval("debugger");
     19    assertEq(log, "d");
     20 }
     21 
     22 test(null);
     23 test(false);
     24 test(1);
     25 test("stringy");
     26 test(Symbol("symbolic"));
     27 test({});
     28 test([]);
     29 
     30 // Getting and setting the prototype's onPop is an error.
     31 assertThrowsInstanceOf(function () { Debugger.Frame.prototype.onPop; }, TypeError);
     32 assertThrowsInstanceOf(
     33    function () { Debugger.Frame.prototype.onPop = function () {}; },
     34    TypeError);
     35 
     36 // The getters and setters correctly check the type of their 'this' argument.
     37 var descriptor = Object.getOwnPropertyDescriptor(Debugger.Frame.prototype, 'onPop');
     38 assertEq(descriptor.configurable, true);
     39 assertEq(descriptor.enumerable, false);
     40 assertThrowsInstanceOf(function () { descriptor.get.call({}); }, TypeError);
     41 assertThrowsInstanceOf(function () { descriptor.set.call({}, function() {}); }, TypeError);