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:
parent
0bc782dfe5
commit
399216580d
3 changed files with 27 additions and 12 deletions
|
@ -1383,8 +1383,7 @@ describe('webContents module', () => {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
// TODO (jkleinsc) - reenable this test on WOA once https://github.com/electron/electron/issues/26045 is resolved
|
describe('did-change-theme-color event', () => {
|
||||||
ifdescribe(process.platform !== 'win32' || process.arch !== 'arm64')('did-change-theme-color event', () => {
|
|
||||||
afterEach(closeAllWindows);
|
afterEach(closeAllWindows);
|
||||||
it('is triggered with correct theme color', (done) => {
|
it('is triggered with correct theme color', (done) => {
|
||||||
const w = new BrowserWindow({ show: true });
|
const w = new BrowserWindow({ show: true });
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
import * as path from 'path';
|
import * as path from 'path';
|
||||||
|
import * as url from 'url';
|
||||||
import { BrowserWindow, session, ipcMain, app, WebContents } from 'electron/main';
|
import { BrowserWindow, session, ipcMain, app, WebContents } from 'electron/main';
|
||||||
import { closeAllWindows } from './window-helpers';
|
import { closeAllWindows } from './window-helpers';
|
||||||
import { emittedOnce, emittedUntil } from './events-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 () => {
|
it('loads devtools extensions registered on the parent window', async () => {
|
||||||
const w = new BrowserWindow({
|
const w = new BrowserWindow({
|
||||||
show: false,
|
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', () => {
|
describe('<webview>.getWebContentsId', () => {
|
||||||
it('can return the WebContents ID', async () => {
|
it('can return the WebContents ID', async () => {
|
||||||
const src = 'about:blank';
|
const src = 'about:blank';
|
||||||
|
|
Loading…
Add table
Reference in a new issue