Move PopupProxyHost initialization

This commit is contained in:
toasted-nutbread 2019-12-21 13:27:32 -05:00
parent 7ae0584077
commit a2175f2c29
3 changed files with 11 additions and 10 deletions

View File

@ -47,7 +47,10 @@ class SettingsPopupPreview {
window.apiOptionsGet = (...args) => this.apiOptionsGet(...args); window.apiOptionsGet = (...args) => this.apiOptionsGet(...args);
// Overwrite frontend // Overwrite frontend
const popup = PopupProxyHost.instance.createPopup(null, 0); const popupHost = new PopupProxyHost();
await popupHost.prepare();
const popup = popupHost.createPopup(null, 0);
popup.setChildrenSupported(false); popup.setChildrenSupported(false);
this.frontend = new Frontend(popup); this.frontend = new Frontend(popup);

View File

@ -21,7 +21,13 @@ async function main() {
const data = window.frontendInitializationData || {}; const data = window.frontendInitializationData || {};
const {id, depth=0, parentFrameId, ignoreNodes, url, proxy=false} = data; const {id, depth=0, parentFrameId, ignoreNodes, url, proxy=false} = data;
const popup = proxy ? new PopupProxy(depth + 1, id, parentFrameId, url) : PopupProxyHost.instance.createPopup(null, depth); let popupHost = null;
if (!proxy) {
popupHost = new PopupProxyHost();
await popupHost.prepare();
}
const popup = proxy ? new PopupProxy(depth + 1, id, parentFrameId, url) : popupHost.createPopup(null, depth);
const frontend = new Frontend(popup, ignoreNodes); const frontend = new Frontend(popup, ignoreNodes);
await frontend.prepare(); await frontend.prepare();
} }

View File

@ -27,12 +27,6 @@ class PopupProxyHost {
// Public functions // Public functions
static create() {
const popupProxyHost = new PopupProxyHost();
popupProxyHost.prepare();
return popupProxyHost;
}
async prepare() { async prepare() {
this._frameIdPromise = apiFrameInformationGet(); this._frameIdPromise = apiFrameInformationGet();
const {frameId} = await this._frameIdPromise; const {frameId} = await this._frameIdPromise;
@ -143,5 +137,3 @@ class PopupProxyHost {
return popup.parent === null || popup.parent.isVisibleSync(); return popup.parent === null || popup.parent.isVisibleSync();
} }
} }
PopupProxyHost.instance = PopupProxyHost.create();