tor-browser

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

browser_dbg-step-in-uninitialized.js (1355B)


      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 // When stepping into a function, 'let' variables should show as uninitialized
      6 // instead of undefined.
      7 
      8 "use strict";
      9 
     10 add_task(async function test() {
     11  const dbg = await initDebugger("doc-step-in-uninitialized.html");
     12  invokeInTab("main");
     13  await waitForPaused(dbg, "doc-step-in-uninitialized.html");
     14 
     15  await stepOver(dbg);
     16  await stepIn(dbg);
     17 
     18  await assertPausedAtSourceAndLine(
     19    dbg,
     20    findSource(dbg, "doc-step-in-uninitialized.html").id,
     21    8
     22  );
     23 
     24  // We step past the 'let x' at the start of the function because it is not
     25  // a breakpoint position.
     26  Assert.equal(findNodeValue(dbg, "x"), "undefined", "x undefined");
     27  Assert.equal(findNodeValue(dbg, "y"), "(uninitialized)", "y uninitialized");
     28 
     29  await stepOver(dbg);
     30 
     31  await assertPausedAtSourceAndLine(
     32    dbg,
     33    findSource(dbg, "doc-step-in-uninitialized.html").id,
     34    9
     35  );
     36 
     37  Assert.equal(findNodeValue(dbg, "y"), "3", "y initialized");
     38 });
     39 
     40 function findNodeValue(dbg, text) {
     41  for (let index = 0; ; index++) {
     42    const elem = findElement(dbg, "scopeNode", index);
     43    if (elem?.innerText == text) {
     44      return getScopeNodeValue(dbg, index);
     45    }
     46  }
     47 }