Skip to content

Commit

Permalink
Fix no-op check to work with Safari (mozilla#364)
Browse files Browse the repository at this point in the history
Verify the object that might be at `globalThis.browser` is not already
implementing the basic Web Extension APIs. This is symmetric with the
check to verify the poly fill is only included in extension contexts.
  • Loading branch information
xeenon committed Mar 9, 2024
1 parent 0cf8915 commit 78b868a
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/browser-polyfill.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ if (!globalThis.chrome?.runtime?.id) {
throw new Error("This script should only be loaded in a browser extension.");
}

if (typeof globalThis.browser === "undefined" || Object.getPrototypeOf(globalThis.browser) !== Object.prototype) {
if (!globalThis.browser?.runtime?.id) {
const CHROME_SEND_MESSAGE_CALLBACK_NO_RESPONSE_MESSAGE = "The message port closed before a response was received.";

// Wrapping the bulk of this polyfill in a one-time-use function is a minor
Expand Down

0 comments on commit 78b868a

Please sign in to comment.