"use strict";
// Copyright 2022 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 helper_js_1 = require("../../shared/helper.js");
const console_helpers_js_1 = require("../helpers/console-helpers.js");
const sources_helpers_js_1 = require("../helpers/sources-helpers.js");
describe('Sources Tab', () => {
    it('pauses the script when clicking the "Pause" button', async ({ devToolsPage, inspectedPage }) => {
        await (0, helper_js_1.step)('navigate to page', async () => {
            await inspectedPage.goToResource('sources/infinity-loop.html');
        });
        await (0, helper_js_1.step)('kick off the infinity loop', async () => {
            await inspectedPage.evaluate('setTimeout(loop, 0)');
        });
        await (0, helper_js_1.step)('wait for the marker console message to show up', async () => {
            await (0, console_helpers_js_1.navigateToConsoleTab)(devToolsPage);
            await (0, console_helpers_js_1.waitForLastConsoleMessageToHaveContent)('Console marker the test can wait for', devToolsPage);
        });
        await (0, helper_js_1.step)('click the pause button', async () => {
            await (0, sources_helpers_js_1.openSourcesPanel)(devToolsPage);
            await devToolsPage.click(sources_helpers_js_1.PAUSE_BUTTON);
        });
        await (0, helper_js_1.step)('wait for the pause in the loop function', async () => {
            await devToolsPage.waitFor(sources_helpers_js_1.PAUSE_INDICATOR_SELECTOR);
            await (0, sources_helpers_js_1.executionLineHighlighted)(devToolsPage);
            await devToolsPage.waitForFunction(async () => {
                const sources = await (0, sources_helpers_js_1.getOpenSources)(devToolsPage);
                return sources.length === 1 && sources[0] === 'infinity-loop.html';
            });
        });
    });
});
//# sourceMappingURL=pause-button.test.js.map