fix: remove undocumented feature and flaky test for webview resize event (#36154)

This commit is contained in:
Jeremy Rose 2022-10-27 16:44:53 -07:00 committed by GitHub
parent 67a0c702fa
commit b9464d89b8
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 0 additions and 43 deletions

View file

@ -24,7 +24,6 @@ export class WebViewImpl {
public guestInstanceId?: number public guestInstanceId?: number
public hasFocus = false public hasFocus = false
public internalInstanceId?: number; public internalInstanceId?: number;
public resizeObserver?: ResizeObserver;
public viewInstanceId: number public viewInstanceId: number
// on* Event handlers. // on* Event handlers.
@ -103,14 +102,6 @@ export class WebViewImpl {
this.attributes.get(attributeName)!.handleMutation(oldValue, newValue); this.attributes.get(attributeName)!.handleMutation(oldValue, newValue);
} }
onElementResize () {
const props = {
newWidth: this.webviewNode.clientWidth,
newHeight: this.webviewNode.clientHeight
};
this.dispatchEvent('resize', props);
}
createGuest () { createGuest () {
this.internalInstanceId = getNextId(); this.internalInstanceId = getNextId();
this.hooks.guestViewInternal.createGuest(this.internalElement, this.internalInstanceId, this.buildParams()) this.hooks.guestViewInternal.createGuest(this.internalElement, this.internalInstanceId, this.buildParams())
@ -203,10 +194,6 @@ export class WebViewImpl {
} }
this.guestInstanceId = guestInstanceId; this.guestInstanceId = guestInstanceId;
// TODO(zcbenz): Should we deprecate the "resize" event? Wait, it is not
// even documented.
this.resizeObserver = new ResizeObserver(this.onElementResize.bind(this));
this.resizeObserver.observe(this.internalElement);
} }
} }

View file

@ -1957,36 +1957,6 @@ describe('<webview> tag', function () {
['with sandbox', true] as const ['with sandbox', true] as const
]) { ]) {
describe(description, () => { describe(description, () => {
it('emits resize events', async () => {
await loadWebViewAndWaitForEvent(w, {
src: `file://${fixtures}/pages/a.html`,
webpreferences: `sandbox=${sandbox ? 'yes' : 'no'}`
}, 'dom-ready');
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.newWidth).to.equal(100);
expect(firstResizeEvent.newHeight).to.equal(10);
await w.removeInsertedCSS(insertedCSS);
const secondResizeSignal = w.executeJavaScript(`new Promise((resolve, reject) => {
webview.addEventListener('resize', (e) => resolve({...e}), {once: true})
})`);
const newWidth = 1234;
const newHeight = 789;
await w.insertCSS(`webview { width: ${newWidth}px; height: ${newHeight}px; }`);
const secondResizeEvent = await secondResizeSignal;
expect(secondResizeEvent.newWidth).to.equal(newWidth);
expect(secondResizeEvent.newHeight).to.equal(newHeight);
});
it('emits focus event', async () => { it('emits focus event', async () => {
await loadWebViewAndWaitForEvent(w, { await loadWebViewAndWaitForEvent(w, {
src: `file://${fixtures}/pages/a.html`, src: `file://${fixtures}/pages/a.html`,