"use strict";
// Copyright 2020 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('Logging and preview of Trusted Types objects in the Console', () => {
    it('Logging of Trusted Type HTML object', async ({ devToolsPage }) => {
        await devToolsPage.click(console_helpers_js_1.CONSOLE_TAB_SELECTOR);
        await (0, console_helpers_js_1.focusConsolePrompt)(devToolsPage);
        await devToolsPage.pasteText(`policy = trustedTypes.createPolicy("generalPolicy", {
      createHTML: string => string
    });`);
        await devToolsPage.page.keyboard.press('Enter');
        await devToolsPage.page.waitForFunction(() => {
            return document.querySelectorAll('.console-user-command-result').length === 1;
        });
        await devToolsPage.pasteText('x = policy.createHTML("<foo>"); x');
        await devToolsPage.page.keyboard.press('Enter');
        await devToolsPage.page.waitForFunction(() => {
            return document.querySelectorAll('.console-user-command-result').length === 2;
        });
        const evaluateResult = await devToolsPage.evaluate(() => {
            return document.querySelectorAll('.console-user-command-result')[1].textContent;
        });
        chai_1.assert.strictEqual(evaluateResult, 'TrustedHTML \'<foo>\'', 'Trusted Type log is not the expected.');
    });
    it('Preview of Trusted Type HTML object', async ({ devToolsPage }) => {
        await devToolsPage.click(console_helpers_js_1.CONSOLE_TAB_SELECTOR);
        await (0, console_helpers_js_1.focusConsolePrompt)(devToolsPage);
        await devToolsPage.pasteText(`policy = trustedTypes.createPolicy("generalPolicy", {
      createHTML: string => string
    });`);
        await devToolsPage.page.keyboard.press('Enter');
        await devToolsPage.page.waitForFunction(() => {
            return document.querySelectorAll('.console-user-command-result').length === 1;
        });
        await devToolsPage.pasteText('x = policy.createHTML("<foo>")');
        await devToolsPage.page.keyboard.press('Enter');
        await devToolsPage.page.waitForFunction(() => {
            return document.querySelectorAll('.console-user-command-result').length === 2;
        });
        await devToolsPage.pasteText('x');
        await devToolsPage.page.waitForFunction(() => {
            return document.querySelectorAll('.console-eager-inner-preview').length === 1 &&
                document.querySelectorAll('.console-eager-inner-preview')[0].textContent;
        });
        const evaluateResult = await devToolsPage.evaluate(() => {
            return document.querySelectorAll('.console-eager-inner-preview')[0].textContent;
        });
        chai_1.assert.strictEqual(evaluateResult, 'TrustedHTML "<foo>"', 'Trusted Type preview is not the expected');
    });
});
//# sourceMappingURL=console-trusted-types.test.js.map