1// Copyright 2020 The Chromium Authors. All rights reserved.
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
5import {assert} from 'chai';
6
7import {closeAllCloseableTabs, getBrowserAndPages, goToResource} from '../../shared/helper.js';
8import {describe, it} from '../../shared/mocha-extensions.js';
9import {getCurrentConsoleMessages} from '../helpers/console-helpers.js';
10import {openPanelViaMoreTools} from '../helpers/settings-helpers.js';
11
12describe('Browser', async () => {
13  it('can reload a website after all closeable tools are closed', async () => {
14    // Navigate to website
15    const {target} = getBrowserAndPages();
16    await goToResource('cross_tool/default.html');
17
18    // Open a few closeable panels
19    await openPanelViaMoreTools('Animations');
20    await openPanelViaMoreTools('Rendering');
21
22    const messages = await getCurrentConsoleMessages();
23    await closeAllCloseableTabs();
24    await target.reload();
25
26    // Website logs the Date, so it shouldn't be the same
27    const newMessages = await getCurrentConsoleMessages();
28
29    assert.notDeepEqual(messages, newMessages);
30  });
31
32  it('can navigate to a new website after all closeable tools are closed', async () => {
33    // Navigate to website
34    const targetUrl = 'cross_tool/default.html';
35    const secondTargetUrl = 'cross_tool/site_with_errors.html';
36    await goToResource(targetUrl);
37
38    // Open a few closeable panels
39    await openPanelViaMoreTools('Animations');
40    await openPanelViaMoreTools('Rendering');
41
42    await closeAllCloseableTabs();
43    // Navigate to a different website
44    await goToResource(secondTargetUrl);
45  });
46});
47