"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 issues_helpers_js_1 = require("../helpers/issues-helpers.js");
describe('Cookie attribute exceeds max size issues test', () => {
    const clearCookies = async (inspectedPage) => {
        const cookies = await inspectedPage.page.cookies();
        await inspectedPage.page.deleteCookie(...cookies);
    };
    it('should display issue when a cookie has an attribute that exceeds the max size', async ({ devToolsPage, inspectedPage }) => {
        try {
            await (0, issues_helpers_js_1.navigateToIssuesTab)(devToolsPage);
            await inspectedPage.goToResource('empty.html');
            await inspectedPage.evaluate(() => {
                const longValue = 'a'.repeat(1025);
                document.cookie = `exceeds_max_size=yes;max-age=${longValue}`;
            });
            await (0, issues_helpers_js_1.navigateToIssuesTab)(devToolsPage);
            await (0, issues_helpers_js_1.expandIssue)(devToolsPage);
            const issueElement = await (0, issues_helpers_js_1.getIssueByTitle)('Ensure cookie attribute values don’t exceed 1024 characters', devToolsPage);
            chai_1.assert.isOk(issueElement);
            const section = await (0, issues_helpers_js_1.getResourcesElement)('1 cookie', issueElement, '.affected-resource-label', devToolsPage);
            await (0, issues_helpers_js_1.ensureResourceSectionIsExpanded)(section, devToolsPage);
            const expectedTableRows = [
                ['Name', 'Domain & Path'],
                ['exceeds_max_size', 'localhost/test/e2e/resources'],
            ];
            await (0, issues_helpers_js_1.waitForTableFromResourceSectionContents)(section.content, expectedTableRows, devToolsPage);
        }
        finally {
            await clearCookies(inspectedPage);
        }
    });
});
//# sourceMappingURL=cookie-attribute-exceeds-max-size-issues.test.js.map