commit 3455cd5da831ad77bd6e77544dba21134a294514 Author: Arlo Breault arlolra@gmail.com Date: Wed Jul 10 10:52:51 2019 +0200
Ensure `snnowflake` was initialized in unload handlers --- proxy/init-badge.js | 8 ++++++-- proxy/init-webext.js | 8 ++++++-- 2 files changed, 12 insertions(+), 4 deletions(-)
diff --git a/proxy/init-badge.js b/proxy/init-badge.js index 30c0218..09579e6 100644 --- a/proxy/init-badge.js +++ b/proxy/init-badge.js @@ -63,14 +63,18 @@ var snowflake, query, debug, silenceNotifications, log, dbg, init;
// Notification of closing tab with active proxy. window.onbeforeunload = function() { - if (!silenceNotifications && Snowflake.MODE.WEBRTC_READY === snowflake.state) { + if ( + !silenceNotifications && + snowflake !== null && + Snowflake.MODE.WEBRTC_READY === snowflake.state + ) { return Snowflake.MESSAGE.CONFIRMATION; } return null; };
window.onunload = function() { - snowflake.disable(); + if (snowflake !== null) { snowflake.disable(); } return null; };
diff --git a/proxy/init-webext.js b/proxy/init-webext.js index 3a2b120..ee755c6 100644 --- a/proxy/init-webext.js +++ b/proxy/init-webext.js @@ -61,14 +61,18 @@ var debug, snowflake, config, broker, ui, log, dbg, init, update, silenceNotific
// Notification of closing tab with active proxy. window.onbeforeunload = function() { - if (!silenceNotifications && Snowflake.MODE.WEBRTC_READY === snowflake.state) { + if ( + !silenceNotifications && + snowflake !== null && + Snowflake.MODE.WEBRTC_READY === snowflake.state + ) { return Snowflake.MESSAGE.CONFIRMATION; } return null; };
window.onunload = function() { - snowflake.disable(); + if (snowflake !== null) { snowflake.disable(); } return null; };
tor-commits@lists.torproject.org