Skip to content

Conversation

@erayd
Copy link
Collaborator

@erayd erayd commented Oct 31, 2019

What

  • Work around parsing issue with URLs in Firefox
  • Adjust code to expect nulls in the origin field

Fixes #191.

Why

Because Firefox is annoyingly broken, again, and somehow thinks providing "null" instead of null is reasonable.

@erayd erayd added the bugfix Fixes something that doesn't work correctly. label Oct 31, 2019
@erayd erayd requested a review from max-baz October 31, 2019 02:46
@erayd erayd self-assigned this Oct 31, 2019
try {
const tab = await chrome.tabs.get(tabId);
badgeCache.settings.origin = new URL(tab.url).origin;
badgeCache.settings.origin = tab.url && new BrowserpassURL(tab.url).origin;
Copy link
Member

Choose a reason for hiding this comment

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

I don't like that we have to repeat this tab.url && XXX logic in many places, easy to miss... Maybe we should think of another approach? e.g. always initialize BrowserpassURL object, but make the origin field inside of it be null, or some special value, so that we don't have to check for null everywhere?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Are you suggesting that BrowserpassURL should accept null as a valid argument? Because that's what your suggestion implies.

Copy link
Member

@max-baz max-baz Oct 31, 2019

Choose a reason for hiding this comment

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

Is it ever null? When I tested this, tab.url was "about:newtab" in Firefox (and "chrome://newtab" in chromium).

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yes, because that's not the only place we obtain a URL from. In some places we parse the origin property of a previously-parsed URL, which may be null.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Also, this specific invocation sometimes has null coming from tab.url. This showed up in Firefox debugging.

Copy link
Member

@max-baz max-baz Oct 31, 2019

Choose a reason for hiding this comment

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

let's rethink it, how about we make settings.origin be not a nullable string, but non-nullable BrowserpassURL object that we don't have to ever reparse? If that requires allowing BrowserpassURL to accept null, we should consider that too :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bugfix Fixes something that doesn't work correctly.

Development

Successfully merging this pull request may close these issues.

Regression: error on New Tab in Firefox

2 participants