зеркало из https://github.com/electron/electron.git
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:
Родитель
0bc782dfe5
Коммит
399216580d
|
@ -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';
|
||||
|
|
Загрузка…
Ссылка в новой задаче