diff options
| -rw-r--r-- | addons/bus/static/src/js/crosstab_bus.js | 8 | ||||
| -rw-r--r-- | addons/mail/static/tests/helpers/test_utils.js | 1 |
2 files changed, 8 insertions, 1 deletions
diff --git a/addons/bus/static/src/js/crosstab_bus.js b/addons/bus/static/src/js/crosstab_bus.js index b939ecab3a5..8f66a64b286 100644 --- a/addons/bus/static/src/js/crosstab_bus.js +++ b/addons/bus/static/src/js/crosstab_bus.js @@ -109,7 +109,7 @@ var CrossTabBus = Longpolling.extend({ peers[this._id] = new Date().getTime(); this._callLocalStorage('setItem', 'peers', peers); - $(window).on('unload.' + this._id, this._onUnload.bind(this)); + this._registerWindowUnload(); if (!this._callLocalStorage('getItem', 'master')) { this._startElection(); @@ -231,6 +231,12 @@ var CrossTabBus = Longpolling.extend({ this._heartbeatTimeout = setTimeout(this._heartbeat.bind(this), hbPeriod); }, /** + * @private + */ + _registerWindowUnload: function () { + $(window).on('unload.' + this._id, this._onUnload.bind(this)); + }, + /** * Check with the local storage if the current tab is the master tab. * If this tab became the master, trigger 'become_master' event * diff --git a/addons/mail/static/tests/helpers/test_utils.js b/addons/mail/static/tests/helpers/test_utils.js index af86d3c2e45..d3f7081eef6 100644 --- a/addons/mail/static/tests/helpers/test_utils.js +++ b/addons/mail/static/tests/helpers/test_utils.js @@ -59,6 +59,7 @@ var MockMailService = Class.extend({ bus_service: function () { return BusService.extend({ _poll: function () {}, // Do nothing + _registerWindowUnload: function () {}, // Do nothing isOdooFocused: function () { return true; }, updateOption: function () {}, }); |
