aboutsummaryrefslogtreecommitdiff
path: root/ext/fg/js/frame-offset-forwarder.js
diff options
context:
space:
mode:
Diffstat (limited to 'ext/fg/js/frame-offset-forwarder.js')
-rw-r--r--ext/fg/js/frame-offset-forwarder.js15
1 files changed, 11 insertions, 4 deletions
diff --git a/ext/fg/js/frame-offset-forwarder.js b/ext/fg/js/frame-offset-forwarder.js
index b3715c2a..09eb89a6 100644
--- a/ext/fg/js/frame-offset-forwarder.js
+++ b/ext/fg/js/frame-offset-forwarder.js
@@ -22,15 +22,23 @@
class FrameOffsetForwarder {
constructor() {
- this._forwardFrameOffset = window !== window.parent ?
+ this._started = false;
+
+ this._forwardFrameOffset = (
+ window !== window.parent ?
this._forwardFrameOffsetParent.bind(this) :
- this._forwardFrameOffsetOrigin.bind(this);
+ this._forwardFrameOffsetOrigin.bind(this)
+ );
this._windowMessageHandlers = new Map([
- ['getFrameOffset', ({offset, uniqueId}, e) => { return this._onGetFrameOffset(offset, uniqueId, e); }]
+ ['getFrameOffset', ({offset, uniqueId}, e) => this._onGetFrameOffset(offset, uniqueId, e)]
]);
+ }
+ start() {
+ if (this._started) { return; }
window.addEventListener('message', this.onMessage.bind(this), false);
+ this._started = true;
}
async applyOffset(x, y) {
@@ -44,7 +52,6 @@ class FrameOffsetForwarder {
chrome.runtime.onMessage.removeListener(runtimeMessageCallback);
callback();
frameOffsetResolve(params);
- return false;
}
};
chrome.runtime.onMessage.addListener(runtimeMessageCallback);