From ac8ffbe76a90d89a5655bea6af5abcac6c7320e0 Mon Sep 17 00:00:00 2001 From: Richard Macklin Date: Thu, 18 Oct 2018 22:00:06 -0700 Subject: Replace `window` references in ActionCable with `self` Before this change, attempting to use ActionCable inside a web worker would result in an exception being thrown: ``` ReferenceError: window is not defined ``` By replacing the `window` reference with `self`, which is available in both a window context and a worker context, we can avoid this error. Ref: https://developer.mozilla.org/en-US/docs/Web/API/Window/self --- actioncable/test/javascript/src/unit/action_cable_test.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'actioncable/test') 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) }) }) }) -- cgit v1.2.3