summaryrefslogtreecommitdiff
path: root/ext/bg/js/backend.js
diff options
context:
space:
mode:
authortoasted-nutbread <toasted-nutbread@users.noreply.github.com>2021-02-09 22:56:04 -0500
committerGitHub <noreply@github.com>2021-02-09 22:56:04 -0500
commit166451b8f76224542b49c13cb27a258eb291f05e (patch)
tree071438b28a04b0478586272038ea343ad4cad319 /ext/bg/js/backend.js
parent0f5fb804d03041b58813516721d897c4315dca8b (diff)
Improve popup window ownership (#1364)
* Update frameInformationGet to also return the tab ID * Add tabId to Frontend * Pass tabId/frameId to Display * Pass ownership information using setContent * Remove ownerFrameId for Popup classes * Use frameId instead of ownerFrameId for screenshotting * Use contentOrigin instead of owner * Update _invokeContentOrigin implementation
Diffstat (limited to 'ext/bg/js/backend.js')
-rw-r--r--ext/bg/js/backend.js16
1 files changed, 9 insertions, 7 deletions
diff --git a/ext/bg/js/backend.js b/ext/bg/js/backend.js
index f1983cb3..fd90a220 100644
--- a/ext/bg/js/backend.js
+++ b/ext/bg/js/backend.js
@@ -525,8 +525,10 @@ class Backend {
}
_onApiFrameInformationGet(params, sender) {
+ const tab = sender.tab;
+ const tabId = tab ? tab.id : void 0;
const frameId = sender.frameId;
- return Promise.resolve({frameId});
+ return Promise.resolve({tabId, frameId});
}
_onApiInjectStylesheet({type, value}, sender) {
@@ -1505,17 +1507,17 @@ class Backend {
return isValidTab ? tab : null;
}
- async _getScreenshot(windowId, tabId, ownerFrameId, format, quality) {
+ async _getScreenshot(windowId, tabId, frameId, format, quality) {
if (typeof windowId !== 'number') {
throw new Error('Invalid window ID');
}
let token = null;
try {
- if (typeof tabId === 'number' && typeof ownerFrameId === 'number') {
+ if (typeof tabId === 'number' && typeof frameId === 'number') {
const action = 'setAllVisibleOverride';
const params = {value: false, priority: 0, awaitFrame: true};
- token = await this._sendMessageTabPromise(tabId, {action, params}, {frameId: ownerFrameId});
+ token = await this._sendMessageTabPromise(tabId, {action, params}, {frameId});
}
return await new Promise((resolve, reject) => {
@@ -1533,7 +1535,7 @@ class Backend {
const action = 'clearAllVisibleOverride';
const params = {token};
try {
- await this._sendMessageTabPromise(tabId, {action, params}, {frameId: ownerFrameId});
+ await this._sendMessageTabPromise(tabId, {action, params}, {frameId});
} catch (e) {
// NOP
}
@@ -1634,8 +1636,8 @@ class Backend {
}
async _injectAnkNoteScreenshot(ankiConnect, timestamp, definitionDetails, details) {
- const {windowId, tabId, ownerFrameId, format, quality} = details;
- const dataUrl = await this._getScreenshot(windowId, tabId, ownerFrameId, format, quality);
+ const {windowId, tabId, frameId, format, quality} = details;
+ const dataUrl = await this._getScreenshot(windowId, tabId, frameId, format, quality);
const {mediaType, data} = this._getDataUrlInfo(dataUrl);
const extension = this._mediaUtility.getFileExtensionFromImageMediaType(mediaType);