tor-browser

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

test_frameactor-04.js (1408B)


      1 /* Any copyright is dedicated to the Public Domain.
      2   http://creativecommons.org/publicdomain/zero/1.0/ */
      3 
      4 "use strict";
      5 
      6 /**
      7 * Verify the "frames" request on the thread.
      8 */
      9 
     10 add_task(
     11  threadFrontTest(async ({ threadFront, debuggee }) => {
     12    await executeOnNextTickAndWaitForPause(
     13      () => evalCode(debuggee),
     14      threadFront
     15    );
     16 
     17    const response = await threadFront.getFrames(0, 1000);
     18    for (let i = 0; i < response.frames.length; i++) {
     19      const expected = frameFixtures[i];
     20      const actual = response.frames[i];
     21 
     22      Assert.equal(
     23        expected.displayname,
     24        actual.displayname,
     25        "Frame displayname"
     26      );
     27      Assert.equal(expected.type, actual.type, "Frame displayname");
     28    }
     29 
     30    await threadFront.resume();
     31  })
     32 );
     33 
     34 var frameFixtures = [
     35  // Function calls...
     36  { type: "call", displayName: "depth3" },
     37  { type: "call", displayName: "depth2" },
     38  { type: "call", displayName: "depth1" },
     39 
     40  // Anonymous function call in our eval...
     41  { type: "call", displayName: undefined },
     42 
     43  // The eval itself.
     44  { type: "eval", displayName: "(eval)" },
     45 ];
     46 
     47 function evalCode(debuggee) {
     48  debuggee.eval(
     49    "(" +
     50      function () {
     51        function depth3() {
     52          debugger;
     53        }
     54        function depth2() {
     55          depth3();
     56        }
     57        function depth1() {
     58          depth2();
     59        }
     60        depth1();
     61      } +
     62      ")()"
     63  );
     64 }