/* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at . */ // Test that adjacent scopes are merged together as expected. "use strict"; add_task(async function () { const dbg = await initDebugger("doc-merge-scopes.html"); invokeInTab("run"); await waitForPaused(dbg, "doc-merge-scopes.html"); // Function body and function lexical scopes are merged together. expectLabels(dbg, ["first", "", "arguments", "x", "y", "z"]); await resume(dbg); await waitForPaused(dbg); // Function body and inner lexical scopes are not merged together. await toggleScopeNode(dbg, 4); expectLabels(dbg, ["Block", "", "y", "second", "arguments", "x"]); await resume(dbg); await waitForPaused(dbg); // When there is a function body, function lexical, and inner lexical scope, // the first two are merged together. await toggleScopeNode(dbg, 4); expectLabels(dbg, [ "Block", "", "z", "third", "arguments", "v", "x", "y", ]); }); function getLabel(dbg, index) { return findElement(dbg, "scopeNode", index).innerText; } function expectLabels(dbg, array) { for (let i = 0; i < array.length; i++) { is( getLabel(dbg, i + 1), array[i], `Correct label ${array[i]} for index ${i + 1}` ); } }