tor-browser

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

browser_dbg-merge-scopes.js (1352B)


      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 // Test that adjacent scopes are merged together as expected.
      6 
      7 "use strict";
      8 
      9 add_task(async function () {
     10  const dbg = await initDebugger("doc-merge-scopes.html");
     11 
     12  invokeInTab("run");
     13  await waitForPaused(dbg, "doc-merge-scopes.html");
     14 
     15  // Function body and function lexical scopes are merged together.
     16  expectLabels(dbg, ["first", "<this>", "arguments", "x", "y", "z"]);
     17 
     18  await resume(dbg);
     19  await waitForPaused(dbg);
     20 
     21  // Function body and inner lexical scopes are not merged together.
     22  await toggleScopeNode(dbg, 4);
     23  expectLabels(dbg, ["Block", "<this>", "y", "second", "arguments", "x"]);
     24 
     25  await resume(dbg);
     26  await waitForPaused(dbg);
     27 
     28  // When there is a function body, function lexical, and inner lexical scope,
     29  // the first two are merged together.
     30  await toggleScopeNode(dbg, 4);
     31  expectLabels(dbg, [
     32    "Block",
     33    "<this>",
     34    "z",
     35    "third",
     36    "arguments",
     37    "v",
     38    "x",
     39    "y",
     40  ]);
     41 });
     42 
     43 function expectLabels(dbg, array) {
     44  for (let i = 0; i < array.length; i++) {
     45    is(
     46      getScopeNodeLabel(dbg, i + 1),
     47      array[i],
     48      `Correct label ${array[i]} for index ${i + 1}`
     49    );
     50  }
     51 }