commit 39be8403a430abab13c77cded2b13bf06324e25c Author: Serene Han keroserene+git@gmail.com Date: Mon Mar 7 22:58:23 2016 -0800
provide 'silent' param on snowflake proxy to disable confirmation dialog --- proxy/snowflake.coffee | 4 +++- proxy/spec/snowflake.spec.coffee | 8 ++++++++ 2 files changed, 11 insertions(+), 1 deletion(-)
diff --git a/proxy/snowflake.coffee b/proxy/snowflake.coffee index 90150ad..4a98472 100644 --- a/proxy/snowflake.coffee +++ b/proxy/snowflake.coffee @@ -14,6 +14,7 @@ DEFAULT_RELAY = COPY_PASTE_ENABLED = false
DEBUG = false +silenceNotifications = false query = null if 'undefined' != typeof window && window.location query = Query.parse(window.location.search.substr(1)) @@ -190,6 +191,7 @@ dbg = (msg) -> log msg if true == snowflake.ui.debug
init = -> ui = new UI() + silenceNotifications = Params.getBool(query, 'silent', false) brokerUrl = Params.getString(query, 'broker', DEFAULT_BROKER) broker = new Broker brokerUrl snowflake = new Snowflake broker, ui @@ -205,7 +207,7 @@ init = -> # Notification of closing tab with active proxy. # TODO: Opt-in/out parameter or cookie window.onbeforeunload = -> - if MODE.WEBRTC_READY == snowflake.state + if !silenceNotifications && MODE.WEBRTC_READY == snowflake.state return CONFIRMATION_MESSAGE null
diff --git a/proxy/spec/snowflake.spec.coffee b/proxy/spec/snowflake.spec.coffee index f3fbae8..9b63419 100644 --- a/proxy/spec/snowflake.spec.coffee +++ b/proxy/spec/snowflake.spec.coffee @@ -61,6 +61,7 @@ describe 'Snowflake', -> expect(s.proxyPairs.length).toBe 2
it 'gives a dialog when closing, only while active', -> + silenceNotifications = false snowflake.state = MODE.WEBRTC_READY msg = window.onbeforeunload() expect(snowflake.state).toBe MODE.WEBRTC_READY @@ -70,3 +71,10 @@ describe 'Snowflake', -> msg = window.onbeforeunload() expect(snowflake.state).toBe MODE.INIT expect(msg).toBe null + + it 'does not give a dialog when silent flag is on', -> + silenceNotifications = true + snowflake.state = MODE.WEBRTC_READY + msg = window.onbeforeunload() + expect(snowflake.state).toBe MODE.WEBRTC_READY + expect(msg).toBe null
tor-commits@lists.torproject.org