aboutsummaryrefslogtreecommitdiff
path: root/ext/js/comm/frame-ancestry-handler.js
diff options
context:
space:
mode:
authortoasted-nutbread <toasted-nutbread@users.noreply.github.com>2024-02-18 07:58:59 -0500
committerGitHub <noreply@github.com>2024-02-18 12:58:59 +0000
commit7e9f7e2616973418cc50f7706bd8f644cb9d5559 (patch)
tree8f8bec7a777a2df33a0a26ef53022c50d2327ef8 /ext/js/comm/frame-ancestry-handler.js
parent4aaa9f15d97668203741c1731f15e710ae8b8294 (diff)
Application data refactor (#699)
* Pass tabId and frameId to Application * Remove casts * Remove redundant frameInformationGet calls * Expose tabId and frameId * Remove unsed * Simplify * Update FrameAncestryHandler to not need a direct frameId * Remove frameId from FrameOffsetForwarder * Remove frameId from PopupFactory * Remove frameId from Frontend * Remove frameId from PopupPreviewFrame * Fix PopupFactory and Frontend constructor * Remove frameId from Display * Remove frameId from SearchDisplayController * Restore if check
Diffstat (limited to 'ext/js/comm/frame-ancestry-handler.js')
-rw-r--r--ext/js/comm/frame-ancestry-handler.js26
1 files changed, 8 insertions, 18 deletions
diff --git a/ext/js/comm/frame-ancestry-handler.js b/ext/js/comm/frame-ancestry-handler.js
index 3e58d57b..92ed3b8c 100644
--- a/ext/js/comm/frame-ancestry-handler.js
+++ b/ext/js/comm/frame-ancestry-handler.js
@@ -28,13 +28,10 @@ export class FrameAncestryHandler {
/**
* Creates a new instance.
* @param {import('../comm/cross-frame-api.js').CrossFrameAPI} crossFrameApi
- * @param {number} frameId The frame ID of the current frame the instance is instantiated in.
*/
- constructor(crossFrameApi, frameId) {
+ constructor(crossFrameApi) {
/** @type {import('../comm/cross-frame-api.js').CrossFrameAPI} */
this._crossFrameApi = crossFrameApi;
- /** @type {number} */
- this._frameId = frameId;
/** @type {boolean} */
this._isPrepared = false;
/** @type {string} */
@@ -48,14 +45,6 @@ export class FrameAncestryHandler {
}
/**
- * Gets the frame ID that the instance is instantiated in.
- * @type {number}
- */
- get frameId() {
- return this._frameId;
- }
-
- /**
* Initializes event event listening.
*/
prepare() {
@@ -116,8 +105,9 @@ export class FrameAncestryHandler {
*/
_getFrameAncestryInfo(timeout = 5000) {
return new Promise((resolve, reject) => {
+ const {frameId} = this._crossFrameApi;
const targetWindow = window.parent;
- if (window === targetWindow) {
+ if (frameId === null || window === targetWindow) {
resolve([]);
return;
}
@@ -141,11 +131,10 @@ export class FrameAncestryHandler {
if (params.nonce !== nonce) { return null; }
// Add result
- const {frameId, more} = params;
- results.push(frameId);
+ results.push(params.frameId);
nonce = generateId(16);
- if (!more) {
+ if (!params.more) {
// Cleanup
cleanup();
@@ -167,7 +156,6 @@ export class FrameAncestryHandler {
// Start
this._addResponseHandler(uniqueId, onMessage);
resetTimeout();
- const frameId = this._frameId;
this._requestFrameInfo(targetWindow, frameId, frameId, uniqueId, nonce);
});
}
@@ -208,7 +196,9 @@ export class FrameAncestryHandler {
return;
}
- const frameId = this._frameId;
+ const {frameId} = this._crossFrameApi;
+ if (frameId === null) { return; }
+
const {parent} = window;
const more = (window !== parent);