diff options
4 files changed, 12 insertions, 12 deletions
diff --git a/actioncable/app/assets/javascripts/action_cable.js b/actioncable/app/assets/javascripts/action_cable.js index a68c76f299..280adbfa83 100644 --- a/actioncable/app/assets/javascripts/action_cable.js +++ b/actioncable/app/assets/javascripts/action_cable.js @@ -3,8 +3,8 @@ })(this, function(exports) { "use strict"; var adapters = { - logger: window.console, - WebSocket: window.WebSocket + logger: self.console, + WebSocket: self.WebSocket }; var logger = { log: function log() { @@ -49,7 +49,7 @@ this.startedAt = now(); delete this.stoppedAt; this.startPolling(); - document.addEventListener("visibilitychange", this.visibilityDidChange); + addEventListener("visibilitychange", this.visibilityDidChange); logger.log("ConnectionMonitor started. pollInterval = " + this.getPollInterval() + " ms"); } }; @@ -57,7 +57,7 @@ if (this.isRunning()) { this.stoppedAt = now(); this.stopPolling(); - document.removeEventListener("visibilitychange", this.visibilityDidChange); + removeEventListener("visibilitychange", this.visibilityDidChange); logger.log("ConnectionMonitor stopped"); } }; diff --git a/actioncable/app/javascript/action_cable/adapters.js b/actioncable/app/javascript/action_cable/adapters.js index 9ba6d338ee..4de8131438 100644 --- a/actioncable/app/javascript/action_cable/adapters.js +++ b/actioncable/app/javascript/action_cable/adapters.js @@ -1,4 +1,4 @@ export default { - logger: window.console, - WebSocket: window.WebSocket + logger: self.console, + WebSocket: self.WebSocket } diff --git a/actioncable/app/javascript/action_cable/connection_monitor.js b/actioncable/app/javascript/action_cable/connection_monitor.js index f0e75ae137..312a71d154 100644 --- a/actioncable/app/javascript/action_cable/connection_monitor.js +++ b/actioncable/app/javascript/action_cable/connection_monitor.js @@ -21,7 +21,7 @@ class ConnectionMonitor { this.startedAt = now() delete this.stoppedAt this.startPolling() - document.addEventListener("visibilitychange", this.visibilityDidChange) + addEventListener("visibilitychange", this.visibilityDidChange) logger.log(`ConnectionMonitor started. pollInterval = ${this.getPollInterval()} ms`) } } @@ -30,7 +30,7 @@ class ConnectionMonitor { if (this.isRunning()) { this.stoppedAt = now() this.stopPolling() - document.removeEventListener("visibilitychange", this.visibilityDidChange) + removeEventListener("visibilitychange", this.visibilityDidChange) logger.log("ConnectionMonitor stopped") } } diff --git a/actioncable/test/javascript/src/unit/action_cable_test.js b/actioncable/test/javascript/src/unit/action_cable_test.js index daad900aca..83426fa32e 100644 --- a/actioncable/test/javascript/src/unit/action_cable_test.js +++ b/actioncable/test/javascript/src/unit/action_cable_test.js @@ -6,14 +6,14 @@ const {module, test} = QUnit module("ActionCable", () => { module("Adapters", () => { module("WebSocket", () => { - test("default is window.WebSocket", assert => { - assert.equal(ActionCable.adapters.WebSocket, window.WebSocket) + test("default is self.WebSocket", assert => { + assert.equal(ActionCable.adapters.WebSocket, self.WebSocket) }) }) module("logger", () => { - test("default is window.console", assert => { - assert.equal(ActionCable.adapters.logger, window.console) + test("default is self.console", assert => { + assert.equal(ActionCable.adapters.logger, self.console) }) }) }) |