Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Check when message sender is about:blank/"null" #3040

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

ghostwords
Copy link
Member

For clarity/explicitness, and to avoid URL parsing errors.

Follows up on #3039.

if (utils.hasOwn(sender, "origin") ?
sender.origin + '/' !== chrome.runtime.getURL('') :
!sender.url.startsWith(chrome.runtime.getURL(''))) {
sender.origin == "null" || sender.origin + '/' !== chrome.runtime.getURL('') :
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"null" feels like a bug that browsers will hopefully fix. should we also check for sender.origin being null?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think "null" is intentional, the initiator property of webRequest callback details objects can be "null" too.

The origin where the request was initiated. This does not change through redirects. If this is an opaque origin, the string 'null' will be used.

-- https://developer.chrome.com/docs/extensions/reference/api/webRequest

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not aware of any cases where MessageSender.origin is falsy.

For clarity/explicitness, and to avoid URL parsing errors.
@ghostwords ghostwords force-pushed the use-sender-origin-pt2 branch from 5e3827a to b0441c5 Compare December 21, 2024 19:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants