blob: 21e312e97207fa6b05311c1761760c3bc7cc490f [file] [edit]
// Copyright 2021 The Chromium Authors
// 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 type {ElementHandle} from 'puppeteer-core';
import {describe, it, setup} from '../conductor/mocha-interface.js';
import {navigateToApplicationTab} from '../helpers/application-helpers.js';
const TEST_HTML_FILE = 'window-controls';
async function assertChecked(checkbox: ElementHandle<HTMLInputElement>, expected: boolean) {
const checked = await checkbox.evaluate(el => el.checked);
assert.strictEqual(checked, expected);
}
describe('The Window Controls Overlay', () => {
// TODO (liviurau): Update navigateToApplicationTab helper to work in docked
// mode and remove the setup below.
setup({dockingMode: 'undocked'});
it('shows emulation controls when manifest with property display_overide is present',
async ({devToolsPage, inspectedPage}) => {
await navigateToApplicationTab(devToolsPage, inspectedPage, TEST_HTML_FILE);
const windowControlsCheckbox =
await (await devToolsPage.waitFor('[title="Emulate Window Controls Overlay"]')).toElement('input');
const controlsDropDown = await devToolsPage.waitFor('select');
// Verify dropdown options
const options = await controlsDropDown.$$('option');
const values = await Promise.all(options.map(option => option.evaluate(el => el.value)));
assert.deepEqual(values, ['Windows', 'Mac', 'Linux']);
// Verify selecting an option
void (await controlsDropDown.toElement('select')).select('Linux');
const selectedOption = await controlsDropDown.evaluate(input => input.value);
assert.strictEqual(selectedOption, 'Linux');
// Verify clicking the checkbox
await assertChecked(windowControlsCheckbox, false);
await windowControlsCheckbox.click();
await assertChecked(windowControlsCheckbox, true);
});
});