diff --git a/test/e2e/resources/sources/BUILD.gn b/test/e2e/resources/sources/BUILD.gn index c19f51eecd..4f827c108b 100644 --- a/test/e2e/resources/sources/BUILD.gn +++ b/test/e2e/resources/sources/BUILD.gn @@ -24,6 +24,7 @@ copy_to_gen("sources") { "filesystem/special-characters.html", "filesystem/with space.js", "filesystem/with%20space.js", + "infinity-loop.html", "inline-variable.html", "inline-variable.js", "live-edit-moving-breakpoint.html", diff --git a/test/e2e/resources/sources/infinity-loop.html b/test/e2e/resources/sources/infinity-loop.html new file mode 100644 index 0000000000..323dae52a0 --- /dev/null +++ b/test/e2e/resources/sources/infinity-loop.html @@ -0,0 +1,10 @@ + + + diff --git a/test/e2e/sources/BUILD.gn b/test/e2e/sources/BUILD.gn index 8e633dac9c..c9cb762f55 100644 --- a/test/e2e/sources/BUILD.gn +++ b/test/e2e/sources/BUILD.gn @@ -25,6 +25,7 @@ node_ts_library("sources") { "live-edit-moving-breakpoint_test.ts", "navigation_test.ts", "overrides_test.ts", + "pause-button_test.ts", "popover_test.ts", "restart-frame_test.ts", "script-in-multiple-workers_test.ts", diff --git a/test/e2e/sources/pause-button_test.ts b/test/e2e/sources/pause-button_test.ts new file mode 100644 index 0000000000..aa8b413732 --- /dev/null +++ b/test/e2e/sources/pause-button_test.ts @@ -0,0 +1,55 @@ +// Copyright 2022 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import {assert} from 'chai'; + +import { + click, + getBrowserAndPages, + goToResource, + step, + waitFor, +} from '../../shared/helper.js'; +import {describe, it} from '../../shared/mocha-extensions.js'; +import { + navigateToConsoleTab, + waitForLastConsoleMessageToHaveContent, +} from '../helpers/console-helpers.js'; +import { + executionLineHighlighted, + getOpenSources, + openSourcesPanel, + PAUSE_BUTTON, + PAUSE_INDICATOR_SELECTOR, +} from '../helpers/sources-helpers.js'; + +describe('Sources Tab', () => { + it('pauses the script when clicking the "Pause" button', async () => { + const {target} = getBrowserAndPages(); + await step('navigate to page', async () => { + await goToResource('sources/infinity-loop.html'); + }); + + await step('kick off the infinity loop', async () => { + await target.evaluate('setTimeout(loop, 0)'); + }); + + await step('wait for the marker console message to show up', async () => { + await navigateToConsoleTab(); + await waitForLastConsoleMessageToHaveContent('Console marker the test can wait for'); + }); + + await step('click the pause button', async () => { + await openSourcesPanel(); + await click(PAUSE_BUTTON); + }); + + await step('wait for the pause in the loop function', async () => { + await waitFor(PAUSE_INDICATOR_SELECTOR); + await executionLineHighlighted(); + + assert.deepStrictEqual(await getOpenSources(), ['infinity-loop.html']); + }); + }); +});