From b612bd8b8dc62a83e6800b052cc5f673a287dbe8 Mon Sep 17 00:00:00 2001 From: toasted-nutbread Date: Sun, 14 Jun 2020 14:06:52 -0400 Subject: PopupProxy refactor (#609) * Remove setDisabled member; replace with an event * Pass frameOffsetForwarder directly to PopupProxy * Replace .start with .prepare * Make onMessage private * Make message safer and handle unexpected inputs --- ext/fg/js/content-script-main.js | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) (limited to 'ext/fg/js/content-script-main.js') diff --git a/ext/fg/js/content-script-main.js b/ext/fg/js/content-script-main.js index cebda2d7..c31cde3f 100644 --- a/ext/fg/js/content-script-main.js +++ b/ext/fg/js/content-script-main.js @@ -49,9 +49,8 @@ async function createIframePopupProxy(frameOffsetForwarder, setDisabled) { api.broadcastTab('rootPopupRequestInformationBroadcast'); const {popupId, frameId: parentFrameId} = await rootPopupInformationPromise; - const getFrameOffset = frameOffsetForwarder.getOffset.bind(frameOffsetForwarder); - - const popup = new PopupProxy(popupId, 0, null, parentFrameId, getFrameOffset, setDisabled); + const popup = new PopupProxy(popupId, 0, null, parentFrameId, frameOffsetForwarder); + popup.on('offsetNotFound', setDisabled); await popup.prepare(); return popup; @@ -115,7 +114,7 @@ async function createPopupProxy(depth, id, parentFrameId) { if (!proxy && frameOffsetForwarder === null) { frameOffsetForwarder = new FrameOffsetForwarder(); - frameOffsetForwarder.start(); + frameOffsetForwarder.prepare(); } let popup; -- cgit v1.2.3