From 290d668ceb6d459a82bbbd36136f46da33f726d9 Mon Sep 17 00:00:00 2001 From: yflory Date: Fri, 8 Sep 2017 15:53:53 +0200 Subject: [PATCH] Fix race condition preventing slide to work on Edge --- www/common/sframe-channel.js | 15 +++++++++++++++ www/common/sframe-common-outer.js | 2 ++ www/common/sframe-common.js | 1 + 3 files changed, 18 insertions(+) diff --git a/www/common/sframe-channel.js b/www/common/sframe-channel.js index c4aed597b..7277a1bfe 100644 --- a/www/common/sframe-channel.js +++ b/www/common/sframe-channel.js @@ -105,6 +105,21 @@ define([ insideHandlers.push(content); }, true); + // Make sure both iframes are ready + var readyHandlers = []; + chan.onReady = function (h) { + if (typeof(h) !== "function") { return; } + readyHandlers.push(h); + }; + chan.ready = function () { + chan.whenReg('EV_RPC_READY', function () { + chan.event('EV_RPC_READY'); + }); + chan.on('EV_RPC_READY', function () { + readyHandlers.forEach(function (h) { h(); }); + }); + }; + var txid; window.addEventListener('message', function (msg) { var data = JSON.parse(msg.data); diff --git a/www/common/sframe-common-outer.js b/www/common/sframe-common-outer.js index 7ac04fe55..04561bd77 100644 --- a/www/common/sframe-common-outer.js +++ b/www/common/sframe-common-outer.js @@ -313,6 +313,8 @@ define([ Cryptpad.useTemplate(href, Cryptget, cb); }); + + sframeChan.ready(); CpNfOuter.start({ sframeChan: sframeChan, channel: secret.channel, diff --git a/www/common/sframe-common.js b/www/common/sframe-common.js index ff6e63387..e42f32236 100644 --- a/www/common/sframe-common.js +++ b/www/common/sframe-common.js @@ -228,6 +228,7 @@ define([ Cryptpad.log(data.logText); }); + ctx.sframeChan.ready(); cb(funcs); }); } };