The content script runs on every frame, including all iframes on the page. The gesture recognizer runs on each frame so that gestures can be performed in frames.
Because we want to display the HUD in the top frame, instead of a small iframe, we forward the events through background.js.
Ideally, such forwarding events should only be delivered to the top frame, but it seems that Safari does not respect the third argument of tabs.sendMessage and flood events.
The simplest workaround is to check window.self !== window.top on receiving messages from the background page not to process forwarded events on iframes. While it works as expected, this might affect performance especially if there are many iframes.
The content script runs on every frame, including all iframes on the page. The gesture recognizer runs on each frame so that gestures can be performed in frames.
Because we want to display the HUD in the top frame, instead of a small iframe, we forward the events through
background.js
.Ideally, such forwarding events should only be delivered to the top frame, but it seems that Safari does not respect the third argument of
tabs.sendMessage
and flood events.https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/API/tabs/sendMessage
The simplest workaround is to check
window.self !== window.top
on receiving messages from the background page not to process forwarded events on iframes. While it works as expected, this might affect performance especially if there are many iframes.