提交 10f5103a 编写于 作者: M Matt Bierner

Add explicit wait for dom-ready in webviews

For #92127
上级 f7011ef7
......@@ -216,6 +216,8 @@ export class ElectronWebviewBasedWebview extends BaseWebview<WebviewTag> impleme
public extension: WebviewExtensionDescription | undefined;
private readonly _protocolProvider: WebviewProtocolProvider;
private readonly _domReady: Promise<void>;
constructor(
id: string,
options: WebviewOptions,
......@@ -248,6 +250,13 @@ export class ElectronWebviewBasedWebview extends BaseWebview<WebviewTag> impleme
this._register(new WebviewKeyboardHandler(webviewAndContents));
this._domReady = new Promise(resolve => {
const subscription = this._register(this.on(WebviewMessageChannels.webviewReady, () => {
subscription.dispose();
resolve();
}));
});
this._register(addDisposableListener(this.element!, 'console-message', function (e: { level: number; message: string; line: number; sourceId: string; }) {
console.log(`[Embedded Page] ${e.message}`);
}));
......@@ -334,7 +343,10 @@ export class ElectronWebviewBasedWebview extends BaseWebview<WebviewTag> impleme
}
protected async postMessage(channel: string, data?: any): Promise<void> {
await this._protocolProvider.ready;
await Promise.all([
this._protocolProvider.ready,
this._domReady,
]);
this.element?.send(channel, data);
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册