Skip to content

Commit

Permalink
Use globalThis
Browse files Browse the repository at this point in the history
  • Loading branch information
fregante committed Nov 26, 2021
1 parent ab5d3ce commit d61a168
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
1 change: 1 addition & 0 deletions .eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
},

"globals": {
"globalThis": true,
},

"rules": {
Expand Down
4 changes: 2 additions & 2 deletions src/browser-polyfill.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
"use strict";

if (typeof window != "object" || typeof chrome != "object" || !chrome || !chrome.runtime || !chrome.runtime.id) {
if (typeof globalThis != "object" || typeof chrome != "object" || !chrome || !chrome.runtime || !chrome.runtime.id) {
throw new Error("This script should only be loaded in a browser extension.");
}

if (typeof window.browser === "undefined" || Object.getPrototypeOf(window.browser) !== Object.prototype) {
if (typeof globalThis.browser === "undefined" || Object.getPrototypeOf(globalThis.browser) !== Object.prototype) {
const CHROME_SEND_MESSAGE_CALLBACK_NO_RESPONSE_MESSAGE = "The message port closed before a response was received.";
const SEND_RESPONSE_DEPRECATION_WARNING = "Returning a Promise is the preferred way to send a reply from an onMessage/onMessageExternal listener, as the sendResponse will be removed from the specs (See https://developer.mozilla.org/docs/Mozilla/Add-ons/WebExtensions/API/runtime/onMessage)";

Expand Down

0 comments on commit d61a168

Please sign in to comment.