diff options
author | Richard Macklin <richard.github@nrm.com> | 2018-10-18 22:00:06 -0700 |
---|---|---|
committer | Richard Macklin <richard.github@nrm.com> | 2019-01-14 17:44:35 -0800 |
commit | ac8ffbe76a90d89a5655bea6af5abcac6c7320e0 (patch) | |
tree | 0b9a0d21d7e04c56d15d899f479740a3d6f444c5 /actioncable/test/javascript/src | |
parent | fcd38cf19fa6249d5b62bbe887fde6120408e9c3 (diff) | |
download | rails-ac8ffbe76a90d89a5655bea6af5abcac6c7320e0.tar.gz rails-ac8ffbe76a90d89a5655bea6af5abcac6c7320e0.tar.bz2 rails-ac8ffbe76a90d89a5655bea6af5abcac6c7320e0.zip |
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
Diffstat (limited to 'actioncable/test/javascript/src')
-rw-r--r-- | actioncable/test/javascript/src/unit/action_cable_test.js | 8 |
1 files changed, 4 insertions, 4 deletions
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) }) }) }) |