Skip to content

Conversation

Lusito
Copy link
Contributor

@Lusito Lusito commented Jun 29, 2020

So, as request, I've made a cleaned up version of #1791. It fixes #1901 and resolves #1791.
I've kept the history so that the work of @andyrichardson can still be credited.

Flow and chromium tests don't seem to run on windows, so I'll wait for travis to check these. lint and unit-tests are green.

What I've done:

  • Undone the formatting changes
  • Replaced the reducer + try/catch version with a simple for of loop. Call me crazy, but I don't like try/catch for things that can be checked easily.
  • Made the tests DRY.
  • Fixed flow errors

assert.equal(install.asProxy, true);
assert.equal(install.manifestData.applications.gecko.id,
manifestData.applications &&
manifestData.applications.gecko &&
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This seems to be the pattern to silence flow here, but it feels wrong. Should we maybe just test for the exact string here rather than optional chaining these properties? (same for the test.sign.js version)

Copy link
Member

Choose a reason for hiding this comment

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

I see this more as "making flow happy / respect flow type checking in tests", the other option is actually silence it using a $FLOW_IGNORE suppress comment (e.g. like used in some other tests here)

As long as the assertion is going to fail when it is supposed to, I'm fine with this.

@Lusito
Copy link
Contributor Author

Lusito commented Jun 29, 2020

@rpl Should be green now (it hangs on npm ci for the windows machine).
I only have one remark about the flow fix, since I've never actually used flow before.

@Lusito Lusito changed the title Cleanup for: Add support for browser_specific_settings fix: Add support for browser_specific_settings Jun 29, 2020
@Lusito Lusito changed the title fix: Add support for browser_specific_settings feat: Add support for browser_specific_settings Jun 29, 2020
@coveralls
Copy link

Coverage Status

Coverage remained the same at 100.0% when pulling b13cb9d on Lusito:fix-browser-specific-support into e480d86 on mozilla:master.

Copy link
Member

@rpl rpl left a comment

Choose a reason for hiding this comment

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

Thanks for reviving that PR @Lusito!
This version looks pretty clean, I like it.

Follows just a couple of review comments (one related to make the code to retrieve the addon id to match a bit more closely what is being done on the Firefox side, the other is just related to an additional test case it may be nice to add).

assert.equal(install.asProxy, true);
assert.equal(install.manifestData.applications.gecko.id,
manifestData.applications &&
manifestData.applications.gecko &&
Copy link
Member

Choose a reason for hiding this comment

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

I see this more as "making flow happy / respect flow type checking in tests", the other option is actually silence it using a $FLOW_IGNORE suppress comment (e.g. like used in some other tests here)

As long as the assertion is going to fail when it is supposed to, I'm fine with this.

Comment on lines +241 to +246
describe('without applications and browser_specific_settings', () => {

it('returns undefined when ID is not specified', () => {
assert.strictEqual(getManifestId(manifestWithoutApps), undefined);
});

Copy link
Member

Choose a reason for hiding this comment

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

On the Firefox side "browser_specific_settings" has an higher priority than "applications" and in this patch it looks that web-ext is going to do the same, it would be nice to add an explicit test case, would you mind add one small test case to cover this in the automated tests?

Comment on lines +89 to +99
const manifestApps = [
manifestData.browser_specific_settings,
manifestData.applications,
];
for (const apps of manifestApps) {
if (apps && apps.gecko && apps.gecko.id) {
return apps.gecko.id;
}
}

return undefined;
Copy link
Member

Choose a reason for hiding this comment

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

Thanks! I actually like this version.

I took another look to what is being done on the Firefox side and it looks that we are doing a slightly different check here:
https://searchfox.org/mozilla-central/rev/5a4aaccb28665807a6fd49cf48367d47fbb5a19a/toolkit/mozapps/extensions/internal/XPIInstall.jsm#472-479

in particular, on the Firefox side, it looks that if browser_specific_settings.gecko is defined we only try to retrieve the id from that object and we don't look to applications.gecko.id anymore.

It may be reasonable to match that here in web-ext too, how that sounds to you?

@rpl
Copy link
Member

rpl commented Jul 24, 2020

Closing in favor of #1974 (which include this changes, plus some small tweaks as described in #1974 description)

@rpl rpl closed this Jul 24, 2020
@Lusito
Copy link
Contributor Author

Lusito commented Jul 24, 2020

Weird, I did not get notified about your code review comments, but I got notified by the mention. Thanks for the merge!

@Lusito Lusito deleted the fix-browser-specific-support branch July 24, 2020 22:35
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.

web-ext ignores manifest browser_specific_settings.gecko.id field
4 participants