tor-browser

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

Frame-onPop-return-return.js (1344B)


      1 // |jit-test| error: TestComplete
      2 // onPop can change a normal return into a normal return of a different value.
      3 
      4 var g = newGlobal({newCompartment: true});
      5 var dbg = new Debugger(g);
      6 
      7 function test(type, provocation) {
      8    var log;
      9    var wasConstructing;
     10 
     11    // Help people figure out which 'test' call failed.
     12    print("type:        " + JSON.stringify(type));
     13    print("provocation: " + JSON.stringify(provocation));
     14 
     15    dbg.onDebuggerStatement = function handleDebuggerStatement(f) {
     16        log += 'd';
     17    };
     18 
     19    dbg.onEnterFrame = function handleEnterFrame(f) {
     20        log += '(';
     21        assertEq(f.type, type);
     22        wasConstructing = f.constructing;
     23        f.onPop = function handlePop(c) {
     24            log += ')';
     25            assertEq(c.return, 'compliment');
     26            return { return: 'favor' };
     27        };
     28    };
     29 
     30    log = '';
     31    var result = provocation();
     32    if (wasConstructing)
     33        assertEq(typeof result, "object");
     34    else
     35        assertEq(result, 'favor');
     36    assertEq(log, "(d)");
     37 
     38    print();
     39 }
     40 
     41 g.eval("function f() { debugger; return 'compliment'; }");
     42 test("call", g.f);
     43 test("call", function () { return new g.f; });
     44 test("eval", function () { return g.eval("debugger; \'compliment\';"); });
     45 test("global", function () { return g.evaluate("debugger; \'compliment\';"); });
     46 throw 'TestComplete';