"use strict";
// Copyright 2025 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
Object.defineProperty(exports, "__esModule", { value: true });
const console_helpers_js_1 = require("../helpers/console-helpers.js");
const settings_helpers_js_1 = require("../helpers/settings-helpers.js");
const sources_helpers_js_1 = require("../helpers/sources-helpers.js");
async function breakAndCheckFocusedPanel(expectedPanel, devToolsPage, inspectedPage) {
    await (0, sources_helpers_js_1.openSourceCodeEditorForFile)('click-breakpoint.js', 'click-breakpoint.html', devToolsPage, inspectedPage);
    await (0, sources_helpers_js_1.addBreakpointForLine)(4, devToolsPage);
    await (0, console_helpers_js_1.navigateToConsoleTab)(devToolsPage);
    void inspectedPage.evaluate('f2();');
    await devToolsPage.waitForFunction(() => devToolsPage.getPendingEvents(sources_helpers_js_1.DEBUGGER_PAUSED_EVENT));
    await devToolsPage.waitFor(`.panel[aria-label="${expectedPanel}"]`);
}
describe('Sources Panel', () => {
    it('is not opened on Debugger.paused if autoFocusOnDebuggerPausedEnabled is false', async ({ devToolsPage, inspectedPage }) => {
        await devToolsPage.installEventListener(sources_helpers_js_1.DEBUGGER_PAUSED_EVENT);
        await (0, settings_helpers_js_1.togglePreferenceInSettingsTab)('Focus Sources panel when triggering a breakpoint', undefined, devToolsPage);
        // Note: This test checks if we *do not* switch panels after receiving
        // a Debugger.paused event. If this functionality that we are testing is not
        // working anymore, then this test may become flaky (sometimes we check before switching,
        // sometimes after switching to the sources panel).
        await breakAndCheckFocusedPanel('console', devToolsPage, inspectedPage);
    });
    it('is opened on Debugger.pause if autoFocusOnDebuggerPausedEnabled is true (default)', async ({ devToolsPage, inspectedPage }) => {
        await devToolsPage.installEventListener(sources_helpers_js_1.DEBUGGER_PAUSED_EVENT);
        await breakAndCheckFocusedPanel('sources', devToolsPage, inspectedPage);
    });
});
//# sourceMappingURL=can-disable-auto-sources-focus.test.js.map