"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 fetching when XMLHttpRequest Logging is enabled', async ({ devToolsPage, inspectedPage }) => {
        await inspectedPage.goToResource('../resources/console/console-fetch-logging.html');
        await (0, console_helpers_js_1.navigateToConsoleTab)(devToolsPage);
        await (0, console_helpers_js_1.toggleShowLogXmlHttpRequests)(devToolsPage);
        const expectedResults = [
            `Fetch finished loading: GET "https://localhost:${inspectedPage.serverPort}/test/e2e/resources/console/xhr-exists.html".`,
            `Fetch failed loading: GET "https://localhost:${inspectedPage.serverPort}/test/e2e/resources/console/xhr-does-not-exist.html".`,
            `Fetch finished loading: POST "https://localhost:${inspectedPage.serverPort}/test/e2e/resources/console/post-target.rawresponse".`,
            'Fetch failed loading: GET "http://localhost:8000/devtools/resources/xhr-exists.html".',
        ];
        await (0, console_helpers_js_1.typeIntoConsoleAndWaitForResult)('await makeRequests();', 4, console_helpers_js_1.Level.Info, devToolsPage);
        const result = await (0, console_helpers_js_1.getCurrentConsoleMessages)(false, console_helpers_js_1.Level.Info, undefined, devToolsPage);
        chai_1.assert.deepEqual(result.slice(0, -1), expectedResults, 'Fetching was not logged correctly');
    });
    it('does not log fetching when XMLHttpRequest Logging is disabled', async ({ devToolsPage, inspectedPage }) => {
        await inspectedPage.goToResource('../resources/console/console-fetch-logging.html');
        await (0, console_helpers_js_1.navigateToConsoleTab)(devToolsPage);
        const expectedResults = [
            `Fetch finished loading: GET "https://localhost:${inspectedPage.serverPort}/test/e2e/resources/console/xhr-exists.html".`,
            `Fetch failed loading: GET "https://localhost:${inspectedPage.serverPort}/test/e2e/resources/console/xhr-does-not-exist.html".`,
            `Fetch finished loading: POST "https://localhost:${inspectedPage.serverPort}/test/e2e/resources/console/post-target.rawresponse".`,
            'Fetch failed loading: GET "http://localhost:8000/devtools/resources/xhr-exists.html".',
        ];
        await (0, console_helpers_js_1.typeIntoConsoleAndWaitForResult)('await makeRequests();', 1, console_helpers_js_1.Level.Info, devToolsPage);
        const result = await (0, console_helpers_js_1.getCurrentConsoleMessages)(false, console_helpers_js_1.Level.Info, undefined, devToolsPage);
        // Check that fetching is not logged
        chai_1.assert.isEmpty(result.slice(0, -1).filter(value => expectedResults.includes(value)), 'Fetching was logged after it was turned off');
    });
});
//# sourceMappingURL=console-fetch-logging.test.js.map