aboutsummaryrefslogtreecommitdiff
path: root/ext/fg/js/frontend.js
diff options
context:
space:
mode:
Diffstat (limited to 'ext/fg/js/frontend.js')
-rw-r--r--ext/fg/js/frontend.js47
1 files changed, 35 insertions, 12 deletions
diff --git a/ext/fg/js/frontend.js b/ext/fg/js/frontend.js
index 36b1898b..e7fb7f47 100644
--- a/ext/fg/js/frontend.js
+++ b/ext/fg/js/frontend.js
@@ -167,6 +167,7 @@ class Frontend {
// Message handlers
_onMessagePopupSetVisibleOverride({visible}) {
+ if (this._popup === null) { return; }
this._popup.setVisibleOverride(visible);
}
@@ -226,15 +227,17 @@ class Frontend {
}
_onClearSelection({passive}) {
- this._popup.hide(!passive);
- this._popup.clearAutoPlayTimer();
+ if (this._popup !== null) {
+ this._popup.hide(!passive);
+ this._popup.clearAutoPlayTimer();
+ }
this._updatePendingOptions();
}
async _onActiveModifiersChanged({modifiers}) {
if (areSetsEqual(modifiers, this._activeModifiers)) { return; }
this._activeModifiers = modifiers;
- if (await this._popup.isVisible()) {
+ if (this._popup !== null && await this._popup.isVisible()) {
this._optionsUpdatePending = true;
return;
}
@@ -311,7 +314,9 @@ class Frontend {
const popup = await popupPromise;
const optionsContext = await this.getOptionsContext();
if (this._updatePopupToken !== token) { return; }
- await popup.setOptionsContext(optionsContext, this._id);
+ if (popup !== null) {
+ await popup.setOptionsContext(optionsContext, this._id);
+ }
if (this._updatePopupToken !== token) { return; }
if (this._isSearchPage) {
@@ -323,6 +328,11 @@ class Frontend {
}
async _getDefaultPopup() {
+ const isXmlDocument = (typeof XMLDocument !== 'undefined' && document instanceof XMLDocument);
+ if (isXmlDocument) {
+ return null;
+ }
+
return this._popupFactory.getOrCreatePopup({depth: this._depth, ownerFrameId: this._frameId});
}
@@ -335,7 +345,12 @@ class Frontend {
async _getIframeProxyPopup() {
const targetFrameId = 0; // Root frameId
await this._waitForFrontendReady(targetFrameId);
+
const {popupId} = await api.crossFrame.invoke(targetFrameId, 'getPopupInfo');
+ if (popupId === null) {
+ return null;
+ }
+
const popup = new PopupProxy(popupId, 0, null, targetFrameId, this._frameId, this._frameOffsetForwarder);
popup.on('offsetNotFound', () => {
this._allowRootFramePopupProxy = false;
@@ -368,6 +383,10 @@ class Frontend {
}
async _search(textSource, cause) {
+ if (this._popup === null) {
+ return null;
+ }
+
await this._updatePendingOptions();
let results = null;
@@ -466,14 +485,18 @@ class Frontend {
}
_showPopupContent(textSource, optionsContext, details=null) {
- this._lastShowPromise = this._popup.showContent(
- {
- source: this._id,
- optionsContext,
- elementRect: textSource.getRect(),
- writingMode: textSource.getWritingMode()
- },
- details
+ this._lastShowPromise = (
+ this._popup !== null ?
+ this._popup.showContent(
+ {
+ source: this._id,
+ optionsContext,
+ elementRect: textSource.getRect(),
+ writingMode: textSource.getWritingMode()
+ },
+ details
+ ) :
+ Promise.resolve()
);
this._lastShowPromise.catch((error) => {
if (yomichan.isExtensionUnloaded) { return; }