Skip to content

Commit

Permalink
Restore browser-polyfill.js
Browse files Browse the repository at this point in the history
  • Loading branch information
fregante authored Nov 25, 2021
1 parent ab5d3ce commit 6147e88
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions src/browser-polyfill.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,7 @@
* 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) {
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 browser === "undefined" || Object.getPrototypeOf(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 Expand Up @@ -544,6 +540,10 @@ if (typeof window.browser === "undefined" || Object.getPrototypeOf(window.browse
return wrapObject(extensionAPIs, staticWrappers, apiMetadata);
};

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

// The build process adds a UMD wrapper around this file, which makes the
// `module` variable available.
module.exports = wrapAPIs(chrome);
Expand Down

0 comments on commit 6147e88

Please sign in to comment.