test: fix flaky did-change-theme-color test (#27739)

* test: move did-change-theme-color test to main

* test: enable did-change-theme-color test for WOA
This commit is contained in:
Cheng Zhao 2021-02-17 07:21:40 +09:00 коммит произвёл GitHub
Родитель 0bc782dfe5
Коммит 399216580d
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
3 изменённых файлов: 27 добавлений и 12 удалений

Просмотреть файл

@ -1383,8 +1383,7 @@ describe('webContents module', () => {
}
});
// TODO (jkleinsc) - reenable this test on WOA once https://github.com/electron/electron/issues/26045 is resolved
ifdescribe(process.platform !== 'win32' || process.arch !== 'arm64')('did-change-theme-color event', () => {
describe('did-change-theme-color event', () => {
afterEach(closeAllWindows);
it('is triggered with correct theme color', (done) => {
const w = new BrowserWindow({ show: true });

Просмотреть файл

@ -1,4 +1,5 @@
import * as path from 'path';
import * as url from 'url';
import { BrowserWindow, session, ipcMain, app, WebContents } from 'electron/main';
import { closeAllWindows } from './window-helpers';
import { emittedOnce, emittedUntil } from './events-helpers';
@ -181,6 +182,31 @@ describe('<webview> tag', function () {
});
});
describe('did-change-theme-color event', () => {
it('emits when theme color changes', async () => {
const w = new BrowserWindow({
webPreferences: {
webviewTag: true
}
});
await w.loadURL('about:blank');
const src = url.format({
pathname: `${fixtures.replace(/\\/g, '/')}/pages/theme-color.html`,
protocol: 'file',
slashes: true
});
const message = await w.webContents.executeJavaScript(`new Promise((resolve, reject) => {
const webview = new WebView()
webview.setAttribute('src', '${src}')
webview.addEventListener('did-change-theme-color', (e) => {
resolve('ok')
})
document.body.appendChild(webview)
})`);
expect(message).to.equal('ok');
});
});
it('loads devtools extensions registered on the parent window', async () => {
const w = new BrowserWindow({
show: false,

Просмотреть файл

@ -992,16 +992,6 @@ describe('<webview> tag', function () {
});
});
// TODO (jkleinsc) - reenable this test on WOA once https://github.com/electron/electron/issues/26045 is resolved
ifdescribe(process.platform !== 'win32' || process.arch !== 'arm64')('did-change-theme-color event', () => {
it('emits when theme color changes', async () => {
loadWebView(webview, {
src: `file://${fixtures}/pages/theme-color.html`
});
await waitForEvent(webview, 'did-change-theme-color');
});
});
describe('<webview>.getWebContentsId', () => {
it('can return the WebContents ID', async () => {
const src = 'about:blank';