test: re-enable <webview> tag DOM events emits resize event (#36026)
This commit is contained in:
parent
e660fdf776
commit
76880be6d2
1 changed files with 17 additions and 35 deletions
|
@ -309,6 +309,7 @@ describe('<webview> tag', function () {
|
||||||
const [, { runtimeId, tabId }] = await emittedOnce(ipcMain, 'answer');
|
const [, { runtimeId, tabId }] = await emittedOnce(ipcMain, 'answer');
|
||||||
expect(runtimeId).to.match(/^[a-z]{32}$/);
|
expect(runtimeId).to.match(/^[a-z]{32}$/);
|
||||||
expect(tabId).to.equal(childWebContentsId);
|
expect(tabId).to.equal(childWebContentsId);
|
||||||
|
await w.webContents.executeJavaScript('webview.closeDevTools()');
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -1534,6 +1535,7 @@ describe('<webview> tag', function () {
|
||||||
webview.openDevTools()
|
webview.openDevTools()
|
||||||
webview.addEventListener('devtools-opened', () => resolve(), {once: true})
|
webview.addEventListener('devtools-opened', () => resolve(), {once: true})
|
||||||
})`);
|
})`);
|
||||||
|
await w.executeJavaScript('webview.closeDevTools()');
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -1950,60 +1952,40 @@ describe('<webview> tag', function () {
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('DOM events', () => {
|
describe('DOM events', () => {
|
||||||
/*
|
|
||||||
let div;
|
|
||||||
|
|
||||||
beforeEach(() => {
|
|
||||||
div = document.createElement('div');
|
|
||||||
div.style.width = '100px';
|
|
||||||
div.style.height = '10px';
|
|
||||||
div.style.overflow = 'hidden';
|
|
||||||
webview.style.height = '100%';
|
|
||||||
webview.style.width = '100%';
|
|
||||||
});
|
|
||||||
|
|
||||||
afterEach(() => {
|
|
||||||
if (div != null) div.remove();
|
|
||||||
});
|
|
||||||
*/
|
|
||||||
|
|
||||||
for (const [description, sandbox] of [
|
for (const [description, sandbox] of [
|
||||||
['without sandbox', false] as const,
|
['without sandbox', false] as const,
|
||||||
['with sandbox', true] as const
|
['with sandbox', true] as const
|
||||||
]) {
|
]) {
|
||||||
describe(description, () => {
|
describe(description, () => {
|
||||||
// TODO(nornagon): disabled during chromium roll 2019-06-11 due to a
|
it('emits resize events', async () => {
|
||||||
// 'ResizeObserver loop limit exceeded' error on Windows
|
await loadWebViewAndWaitForEvent(w, {
|
||||||
/*
|
src: `file://${fixtures}/pages/a.html`,
|
||||||
xit('emits resize events', async () => {
|
webpreferences: `sandbox=${sandbox ? 'yes' : 'no'}`
|
||||||
const firstResizeSignal = waitForEvent(webview, 'resize');
|
}, 'dom-ready');
|
||||||
const domReadySignal = waitForEvent(webview, 'dom-ready');
|
|
||||||
|
|
||||||
webview.src = `file://${fixtures}/pages/a.html`;
|
const firstResizeSignal = w.executeJavaScript(`new Promise((resolve, reject) => {
|
||||||
webview.webpreferences = `sandbox=${sandbox ? 'yes' : 'no'}`;
|
webview.addEventListener('resize', (e) => resolve({...e}), {once: true})
|
||||||
div.appendChild(webview);
|
})`);
|
||||||
document.body.appendChild(div);
|
|
||||||
|
const insertedCSS = await w.insertCSS('webview { width: 100px; height: 10px; }');
|
||||||
|
|
||||||
const firstResizeEvent = await firstResizeSignal;
|
const firstResizeEvent = await firstResizeSignal;
|
||||||
expect(firstResizeEvent.target).to.equal(webview);
|
|
||||||
expect(firstResizeEvent.newWidth).to.equal(100);
|
expect(firstResizeEvent.newWidth).to.equal(100);
|
||||||
expect(firstResizeEvent.newHeight).to.equal(10);
|
expect(firstResizeEvent.newHeight).to.equal(10);
|
||||||
|
|
||||||
await domReadySignal;
|
await w.removeInsertedCSS(insertedCSS);
|
||||||
|
|
||||||
const secondResizeSignal = waitForEvent(webview, 'resize');
|
const secondResizeSignal = w.executeJavaScript(`new Promise((resolve, reject) => {
|
||||||
|
webview.addEventListener('resize', (e) => resolve({...e}), {once: true})
|
||||||
|
})`);
|
||||||
|
|
||||||
const newWidth = 1234;
|
const newWidth = 1234;
|
||||||
const newHeight = 789;
|
const newHeight = 789;
|
||||||
div.style.width = `${newWidth}px`;
|
await w.insertCSS(`webview { width: ${newWidth}px; height: ${newHeight}px; }`);
|
||||||
div.style.height = `${newHeight}px`;
|
|
||||||
|
|
||||||
const secondResizeEvent = await secondResizeSignal;
|
const secondResizeEvent = await secondResizeSignal;
|
||||||
expect(secondResizeEvent.target).to.equal(webview);
|
|
||||||
expect(secondResizeEvent.newWidth).to.equal(newWidth);
|
expect(secondResizeEvent.newWidth).to.equal(newWidth);
|
||||||
expect(secondResizeEvent.newHeight).to.equal(newHeight);
|
expect(secondResizeEvent.newHeight).to.equal(newHeight);
|
||||||
});
|
});
|
||||||
*/
|
|
||||||
|
|
||||||
it('emits focus event', async () => {
|
it('emits focus event', async () => {
|
||||||
await loadWebViewAndWaitForEvent(w, {
|
await loadWebViewAndWaitForEvent(w, {
|
||||||
|
|
Loading…
Reference in a new issue