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');
|
||||
expect(runtimeId).to.match(/^[a-z]{32}$/);
|
||||
expect(tabId).to.equal(childWebContentsId);
|
||||
await w.webContents.executeJavaScript('webview.closeDevTools()');
|
||||
});
|
||||
});
|
||||
|
||||
|
@ -1534,6 +1535,7 @@ describe('<webview> tag', function () {
|
|||
webview.openDevTools()
|
||||
webview.addEventListener('devtools-opened', () => resolve(), {once: true})
|
||||
})`);
|
||||
await w.executeJavaScript('webview.closeDevTools()');
|
||||
});
|
||||
});
|
||||
|
||||
|
@ -1950,60 +1952,40 @@ describe('<webview> tag', function () {
|
|||
});
|
||||
|
||||
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 [
|
||||
['without sandbox', false] as const,
|
||||
['with sandbox', true] as const
|
||||
]) {
|
||||
describe(description, () => {
|
||||
// TODO(nornagon): disabled during chromium roll 2019-06-11 due to a
|
||||
// 'ResizeObserver loop limit exceeded' error on Windows
|
||||
/*
|
||||
xit('emits resize events', async () => {
|
||||
const firstResizeSignal = waitForEvent(webview, 'resize');
|
||||
const domReadySignal = waitForEvent(webview, 'dom-ready');
|
||||
it('emits resize events', async () => {
|
||||
await loadWebViewAndWaitForEvent(w, {
|
||||
src: `file://${fixtures}/pages/a.html`,
|
||||
webpreferences: `sandbox=${sandbox ? 'yes' : 'no'}`
|
||||
}, 'dom-ready');
|
||||
|
||||
webview.src = `file://${fixtures}/pages/a.html`;
|
||||
webview.webpreferences = `sandbox=${sandbox ? 'yes' : 'no'}`;
|
||||
div.appendChild(webview);
|
||||
document.body.appendChild(div);
|
||||
const firstResizeSignal = w.executeJavaScript(`new Promise((resolve, reject) => {
|
||||
webview.addEventListener('resize', (e) => resolve({...e}), {once: true})
|
||||
})`);
|
||||
|
||||
const insertedCSS = await w.insertCSS('webview { width: 100px; height: 10px; }');
|
||||
|
||||
const firstResizeEvent = await firstResizeSignal;
|
||||
expect(firstResizeEvent.target).to.equal(webview);
|
||||
expect(firstResizeEvent.newWidth).to.equal(100);
|
||||
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 newHeight = 789;
|
||||
div.style.width = `${newWidth}px`;
|
||||
div.style.height = `${newHeight}px`;
|
||||
|
||||
await w.insertCSS(`webview { width: ${newWidth}px; height: ${newHeight}px; }`);
|
||||
const secondResizeEvent = await secondResizeSignal;
|
||||
expect(secondResizeEvent.target).to.equal(webview);
|
||||
expect(secondResizeEvent.newWidth).to.equal(newWidth);
|
||||
expect(secondResizeEvent.newHeight).to.equal(newHeight);
|
||||
});
|
||||
*/
|
||||
|
||||
it('emits focus event', async () => {
|
||||
await loadWebViewAndWaitForEvent(w, {
|
||||
|
|
Loading…
Reference in a new issue