"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 chai_1 = require("chai");
const console_helpers_js_1 = require("../helpers/console-helpers.js");
describe('The Console Tab', () => {
    it('is able to log uncaught promise rejections into console', async ({ devToolsPage, inspectedPage }) => {
        await inspectedPage.goToResource('../resources/console/console-uncaught-promise.html');
        await (0, console_helpers_js_1.navigateToConsoleTab)(devToolsPage);
        await (0, console_helpers_js_1.checkCommandStacktrace)('await promiseTest1();', `
        promiseTest1 @ console-uncaught-promise.html:3
        (anonymous) @ VM26:1
      `, 2, 0, devToolsPage);
        await (0, console_helpers_js_1.checkCommandStacktrace)('await promiseTest2();', `
        promiseTest2 @ console-uncaught-promise.html:23
        (anonymous) @ VM44:1
      `, 2, 0, devToolsPage);
        await (0, console_helpers_js_1.checkCommandStacktrace)('await promiseTest3();', `
        throwDOMException	@	console-uncaught-promise.html:39
        catcher	@	console-uncaught-promise.html:32
        Promise.catch
        promiseTest3	@	console-uncaught-promise.html:31
        (anonymous)	@	VM66:1
      `, 2, 0, devToolsPage);
        await (0, console_helpers_js_1.checkCommandStacktrace)('await promiseTest4();', `
        promiseTest4	@	console-uncaught-promise.html:44
        (anonymous)	@	VM86:1
      `, 2, 0, devToolsPage);
        await (0, console_helpers_js_1.checkCommandStacktrace)('await promiseTest5();', `
        promiseTest5	@	console-uncaught-promise.html:48
        (anonymous)	@	VM104:1
      `, 2, 0, devToolsPage);
        await (0, console_helpers_js_1.checkCommandStacktrace)('await promiseTest6();', `
        promiseTest6	@	console-uncaught-promise.html:52
        (anonymous)	@	VM122:1
      `, 2, 0, devToolsPage);
        await (0, console_helpers_js_1.checkCommandStacktrace)('await promiseTest7();', `
        promiseTest7	@	console-uncaught-promise.html:56
        (anonymous)	@	VM138:1
      `, 2, 0, devToolsPage);
        await (0, console_helpers_js_1.checkCommandStacktrace)('await promiseTest8();', `
        promiseTest8	@	console-uncaught-promise.html:60
        (anonymous)	@	VM150:1
      `, 2, 0, devToolsPage);
        await (0, console_helpers_js_1.typeIntoConsoleAndWaitForResult)('await promiseTest9();', 3, undefined, devToolsPage);
        const lastMessages = (await (0, console_helpers_js_1.getCurrentConsoleMessages)(false, undefined, undefined, devToolsPage)).slice(-2);
        chai_1.assert.include(lastMessages, 'A bad HTTP response code (404) was received when fetching the script.', 'Error message was not displayed correctly for promiseTest9');
        chai_1.assert.include(lastMessages, `Uncaught (in promise) TypeError: Failed to register a ServiceWorker for scope ('https://localhost:${inspectedPage.serverPort}/test/e2e/resources/console/') with script ('https://localhost:${inspectedPage
            .serverPort}/test/e2e/resources/console/404'): A bad HTTP response code (404) was received when fetching the script.`, 'Error message was not displayed correctly for promiseTest9');
    });
});
//# sourceMappingURL=console-uncaught-promise.test.js.map