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

Initial stab at Chromium compatibility #250

Merged
merged 11 commits into from
May 24, 2017
Merged

Initial stab at Chromium compatibility #250

merged 11 commits into from
May 24, 2017

Conversation

lidel
Copy link
Member

@lidel lidel commented May 21, 2017

This PR provides initial support for Chromium 58+ browsers (ipfs/in-web-browsers#54, #218).

Running in Chromium

First, build it manually:

npm install
npm run build

Then open up chrome://extensions in Chromium-based browser, enable "Developer mode", click "Load unpacked extension..." and point it at add-on/manifest.json.

It should load just fine, with some minor warnings (see known issues below):

2017-05-13-211205_897x506_scrot

Brief list of issues fixed in this PR

Known Issues

Remaining Issues that are not covered by this PR:

  • Chromium does not accept Alarm periods less than minimum of 1 minutes. This means "ipfs-api-status-update" will fire approximately every 1 minutes (instead of every 3 seconds). We can leave it that way, or rewrite API polling logic to use something else than Alarms API.
  • No support for web+foo protocols. Chromium does not support protocol_handlers in manifest, this needs to be detected and manual handler needs to be installed somehow.

lidel added 10 commits May 11, 2017 14:53
Firefox supported simplified syntax, but Chromium does not.

Implements part of #218
Only one of browser_action, page_action can be specified in Chrome

Part of #218 effort
This solves load error under Chromium

Part of #218
Chromium does not support SVG
[ticket below is 8 years old, I can't even..]
https://bugs.chromium.org/p/chromium/issues/detail?id=29683

We use precomputed PNG versions instead.

This fixes part of #218 effort
For some reason `js-ipfs-api` sends requests with "Origin: null"
under Chrom which produces '403 - Forbidden' error.
This workaround removes bogus header from API requests

Part of #218 effort
Turns out workaround introduced for Firefox in #227
broke right-click "Upload to IPFS" function under Chromium ;-)

This commit adds userAgent check and enables workaround only
under Firefox, making Chromium (#218) happy.
@lidel lidel added kind/enhancement A net-new feature or improvement to an existing feature kind/maintenance Work required to avoid breaking changes or harm to project's status quo labels May 21, 2017
@lidel lidel added this to the v2.0.0 milestone May 21, 2017
@lidel lidel requested a review from daviddias May 21, 2017 19:49
@lidel
Copy link
Member Author

lidel commented May 23, 2017

Are we good to merge this? If so, hit me up with review approval.
I'd like to release it into Firefox's Development Channel as v2.0.0alpha5

@whyrusleeping
Copy link
Member

loading it into chrome i get:

Failed to load extension from: ~/gopkg/src/github.com/ipfs/ipfs-companion/add-on
Invalid placeholder errorMsg for key notify_inlineErrorMsg

Followed by the entire manifest.json in a little scrollybox

@whyrusleeping
Copy link
Member

chromium version: 58.0.3029.110

@lidel
Copy link
Member Author

lidel commented May 23, 2017

@whyrusleeping Are you sure you loaded code from chromium-compat branch?
Mentioned bug was fixed in 6f00741

@whyrusleeping
Copy link
Member

@lidel youre right, i missed the checkout a branch bit. Works! 👍 👍

@lidel lidel merged commit d4e5d1e into master May 24, 2017
@lidel lidel deleted the chromium-compat branch May 24, 2017 06:21
Copy link
Member

@daviddias daviddias left a comment

Choose a reason for hiding this comment

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

This LGTM, exciting!

return context.getImageData(0, 0, size, size)
}
*/

// OPTIONS
// ===================================================================
Copy link
Member

Choose a reason for hiding this comment

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

Wouldn't it make more sense to modularize these sections?

Copy link
Member Author

@lidel lidel May 24, 2017

Choose a reason for hiding this comment

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

Yes, at some point.
I've added those "section" comments, as common.js grew organically.

I was not sure what is the best course of action for "webextension modularization", as Firefox WX ecosystem was still brand new when I started the rewrite from legacy SDK.

In Chrome world people use ES6 modules, but feature is not implemented in any browsers natively at this time and requires you to transpile everything to a single .js file (example).

I avoided it and right now add-on code runs "as-is" (no transpilling), but I am not sure if this approach can be maintained in the long run, especially now that we support multiple browser vendors.

If you feel it is the time, create a new Issue and copy/link this comment there.
Alternatively, we leave it be a monolith until ES6 modules are natively supported by both Firefox and Chrome:

@daviddias
Copy link
Member

Ah, only see that purple merged label after. awesome!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/enhancement A net-new feature or improvement to an existing feature kind/maintenance Work required to avoid breaking changes or harm to project's status quo
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants