FrameOffsetForwarder fixes (#2017)

* Fix handling of null iframe rect

* Handle errors inside of getOffset
This commit is contained in:
toasted-nutbread 2021-11-21 15:08:39 -05:00 committed by GitHub
parent 36967b1839
commit 06e70c1cd8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 22 additions and 22 deletions

View File

@ -316,12 +316,7 @@ class PopupProxy extends EventDispatcher {
async _updateFrameOffsetInner(now) {
this._frameOffsetPromise = this._frameOffsetForwarder.getOffset();
try {
let offset = null;
try {
offset = await this._frameOffsetPromise;
} catch (e) {
// NOP
}
const offset = await this._frameOffsetPromise;
this._frameOffset = offset !== null ? offset : [0, 0];
if (offset === null) {
this.trigger('offsetNotFound');

View File

@ -37,6 +37,7 @@ class FrameOffsetForwarder {
return [0, 0];
}
try {
const ancestorFrameIds = await this._frameAncestryHandler.getFrameAncestryInfo();
let childFrameId = this._frameId;
@ -48,13 +49,17 @@ class FrameOffsetForwarder {
const results = await Promise.all(promises);
let xOffset = 0;
let yOffset = 0;
for (const {x, y} of results) {
xOffset += x;
yOffset += y;
let x = 0;
let y = 0;
for (const result of results) {
if (result === null) { return null; }
x += result.x;
y += result.y;
}
return [x, y];
} catch (e) {
return null;
}
return [xOffset, yOffset];
}
// Private