Skip to content
This repository has been archived by the owner on Nov 27, 2019. It is now read-only.

Allow relative path for icon url #498

Merged
merged 4 commits into from
Apr 10, 2016
Merged

Allow relative path for icon url #498

merged 4 commits into from
Apr 10, 2016

Conversation

yan12125
Copy link
Contributor

Fixes #197 and fixes #341.

It's a workaround before https://bugzilla.mozilla.org/show_bug.cgi?id=1141839 is resolved. Tested with https://github.com/whuhacker/Unblock-Youku-Firefox on Linux. If this patch is OK I'll try to add some tests.

@johannhof
Copy link

For previous discussions around this, see earlier PRs #212 and #267.

@kumar303
Copy link
Contributor

@johannhof since you are more familiar, could you review this patch? I think it should be fine since it's not moving files around, right?

@johannhof
Copy link

@kumar303 sure, I'll take a look! The main issue is that this patch (and the earlier patch) are using resource: urls while that protocol might not forever be supported in Firefox add-ons and people would have to repackage with an updated version of jpm. I'm not sure it's a valid argument because

  1. it's completely broken right now which is arguably worse than will at some point maybe stop to work
  2. To fix it in m-c would be equally messy
  3. jpm will be obsolete at some point as well

So I would recommend going for this approach, however I'm a bit biased since I wrote the initial patch. Do you know what's up with resource:?

@kumar303
Copy link
Contributor

Thanks for the detailed info. The fact that it's completely broken as is sounds like a good enough reason to go ahead with this patch.

@yan12125 yes, please continue the patch with tests.

@kumar303
Copy link
Contributor

@johannhof also, thanks for your continued help on jpm. I added you as a project member so that you can also help merge patches if you'd like to in the future.

@@ -64,6 +75,15 @@ function createRDF(manifest) {
delete jetpackMeta["em:icon64URL"];
}

if (needsBootstrapJS) {

Choose a reason for hiding this comment

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

Why would you only do this if no bootstrap.js is present? Is there a reason for that if clause?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

When bootstrap.js is not provided by the addon developer, the default bootstrap.js is used. With this bootstrap.js, the addon's resource:// URI registration occurs in resource://gre/modules/commonjs/sdk/addon/bootstrap.js. If a custom bootstrap.js is provided, the program flow mentioned above may not occur, so the real icon URLs are unknow.

Choose a reason for hiding this comment

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

Huh, I didn't know this was done in bootstrap.js. In any case I suppose we can trust developers using custom bootstrap.js with this. Can you please add a very short comment above that line so that people like me understand what's going on? 😅

@johannhof
Copy link

@yan12125 in https://github.com/mozilla-jetpack/jpm/pull/267/files#diff-dc54654b4741edd9be2ea246c9563573R61 it logs a warning that using the manifest icon key is not recommended. It would be cool if could include a warning like that.

@yan12125
Copy link
Contributor Author

yan12125 commented Mar 2, 2016

It would be cool if could include a warning like that.

https://developer.mozilla.org/en-US/Add-ons/Install_Manifests says:

Starting in Gecko 1.9.2 (Firefox 3.6), you can also simply include your icon, named icon.png, in the base directory of the add-on. This allows your add-on's icon to be displayed even when the add-on is disabled, or if the manifest is missing an iconURL entry.

For me the wording you can also indicates both ways are acceptable, and neither is more preferred than another. Are there texts explicit recommending not using <em:iconURL> or <em:iconURL64> keys?

For the following statement:

This allows your add-on's icon to be displayed even when the add-on is disabled

Things may have been changed since this sentence is written. On Firefox 44.0.2, at least EPUBReader, GreaseMonkey, Advanced Cookie Manager and Anonymox uses <em:iconURL> in install.rdf and their icons display correctly when the corresponding addon is disabled.

As stated in https://bugzilla.mozilla.org/show_bug.cgi?id=1141839, relative paths should be supported, and with some hacks in jpm it really works. I don't think warnings here are necessary.

Finally, concerning another statement in https://developer.mozilla.org/en-US/Add-ons/Install_Manifests#iconURL:

A chrome:// URL to an icon to display in the add-ons list.

There should be a note in this section. Something like "relative paths are supported if you're using jpm >= x.y.z" if this PR is finally merged.

@yan12125
Copy link
Contributor Author

yan12125 commented Mar 2, 2016

@johannhof Can I adapt your test cases from #267 in this PR?

@johannhof
Copy link

@yan12125:

Things may have been changed since this sentence is written. On Firefox 44.0.2, at least EPUBReader, GreaseMonkey, Advanced Cookie Manager and Anonymox uses em:iconURL in install.rdf and their icons display correctly when the corresponding addon is disabled.

I can still reproduce it on my nightly build using a dummy add-on. Did you reload the page after disabling them? Also, they might still have an icon.png in their root.

Apart from that, I would like a warning because falling back to resource URLs is still a hack and should be last resort, not the default.

Can I adapt your test cases from #267 in this PR?

Sure!

@johannhof
Copy link

@yan12125 do you need any help finalizing this patch? :)

@kumar303
Copy link
Contributor

kumar303 commented Apr 8, 2016

This needs to be rebased on master to resolve the conflicts.

@yan12125
Copy link
Contributor Author

yan12125 commented Apr 9, 2016

Rebased and tests added.

@johannhof
Copy link

Ok, thanks! I see you didn't add a warning, which is not a breaker for me. We can make a small follow-up bug for this.

Thank you for contributing. 👍

@johannhof johannhof merged commit e4d58a1 into mozilla-jetpack:master Apr 10, 2016
@johannhof
Copy link

See #522

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Please open issue #197 again. It is not closed! Relative icon paths do not work
3 participants