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

Add support for chromium-based browsers #218

Closed
AlexBeLi opened this issue Mar 19, 2017 · 10 comments · Fixed by #266
Closed

Add support for chromium-based browsers #218

AlexBeLi opened this issue Mar 19, 2017 · 10 comments · Fixed by #266
Assignees
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

Comments

@AlexBeLi
Copy link

Because ipfs-chrome-extension and ipfs-chrome-station don't support ipfs>=0.4.5.

@lidel lidel added kind/enhancement A net-new feature or improvement to an existing feature help wanted Seeking public contribution on this issue kind/maintenance Work required to avoid breaking changes or harm to project's status quo labels Mar 19, 2017
@lidel
Copy link
Member

lidel commented Mar 19, 2017

This may require some additional work due to incompatibilities between WebExtensions and Chrome APIs.
It may be easier/faster to just fix one of mentioned Chrome extensions, at least for now.

"Make it work in Chromium" TODO list 🚧 👷

🛑 Hard Errors

Things that make it impossible to load WebExtension under Chromium or connect to IPFS API.

  • Chromium does not have browser object and requires a polyfill for standardized APIs (which is a subset of APIs provided by Firefox): https://github.com/mozilla/webextension-polyfill (there is also https://github.com/MetaMask/extensionizer) (fixed in chromium-compat branch)
  • Only one of browser_action, page_action can be specified in Chromium (we use both) (fixed in chromium-compat branch)
  • Chromium has some additional restrictions regarding locale files which needs to be addressed (fixed by removing - from key names)
  • Chromium does not support async / await yet (Firefox does and I plan to use it extensively)
    In general, chrome target would probably need some kind of transpilling

    (supports since v55)
  • Chromium complains about some i18 placeholders present in local files (fixed in chromium-compat branch)
  • Chromium does not support "alpha/beta" suffix in version in manifest (fixed in chromium-compat branch)
  • Chromium does not accept SVG as browserAction icon, PNG needs to be provided instead (https://stackoverflow.com/q/38457208, https://bugs.chromium.org/p/chromium/issues/detail?id=647182, https://bugs.chromium.org/p/chromium/issues/detail?id=29683) (fixed in chromium-compat branch)
  • Chromium sends Origin: null with XHR requests for /api/v0/swarm/peers which causes 403 - Forbidden error (fixed in chromium-compat branch)

⚠️ Soft Errors

These produce feature regressions, warnings / ugly interface, but do not break main functionality.

  • Chromium does not support protocol_handlers in manifest, this needs to be detected and manual handler needs to be installed.
  • Chromium does not ship with native CSS classes that are shipped with Firefox (fixed in chromium-compat branch)
  • Chromium does not accept Alarm periods less than minimum of 1 minutes (fixed in Refactoring of Browser Action and API Polling #266)

    On Chrome, unless the add-on is loaded unpackaged, alarms it creates are not allowed to fire more than once per minute. If an add-on tries to set delayInMinutes to a value < 1, or when to a value < 1 minute in the future, then the alarm will fire after 1 minute. If an add-on tries to set periodInMinutes to a value < 1, then the alarm will fire every minute. – alarms.create()

  • Right-click "Upload to IPFS" does not work due to Origin mismatch

@mateon1
Copy link

mateon1 commented Mar 19, 2017

I just fixed ipfs-chrome-station, but it might take a while for fbaiodias/ipfs-chrome-station#15 to get merged, and the extension updated.
For now, you can use https://github.com/mateon1/ipfs-chrome-station/tree/fix/ipfs-0.4.5
To do so, clone the repo and switch to branch fix/ipfs-0.4.5. Run npm install and npm run build. You can then load the ./build folder in Chrome as an unpacked extension.

lidel added a commit that referenced this issue Apr 4, 2017
This fixes Chromium incompatibility mentioned in #218
@daviddias
Copy link
Member

Following up ipfs/in-web-browsers#54 (comment), we want to have this WebExtension serving both.

Is Only one of browser_action, page_action can be specified in chrome (we use both) the only thing missing?

@lidel
Copy link
Member

lidel commented May 9, 2017

I remember there were multiple errors about unsupported manifest keys, eg. recently introduced protocol_handlers. I've added them to first post. There is probably more.

This "write once, run everywhere" story provided by Mozilla does not pass reality check.
As soon as we use non-canonical API provided by Firefox, we are not Chrome-compatible.
And as you can see there are discrepancies even within APIs copied from Chrome.

I suspect we will end up with chunks of conditional code and dedicated manifest and build pipeline for each browser.

That being said, we can simplify stuff by merging "pageAction" back into "browserActions".
One thing less to worry about.

@lidel lidel self-assigned this May 11, 2017
@lidel lidel removed the help wanted Seeking public contribution on this issue label May 11, 2017
@lidel
Copy link
Member

lidel commented May 11, 2017

FYI I'll do my best in diagnosing / mitigating compatibility issues in chromium-compat branch this week.
Stay tuned. 👌

@victorb
Copy link
Member

victorb commented May 11, 2017

I came across extensionizer[0] from the same peeps that are developing MetaMask, maybe
incorporating it and help develop it further would be a good idea

lidel added a commit that referenced this issue May 11, 2017
Firefox supported simplified syntax, but Chromium does not.

Implements part of #218
lidel added a commit that referenced this issue May 11, 2017
lidel added a commit that referenced this issue May 11, 2017
Only one of browser_action, page_action can be specified in Chrome

Part of #218 effort
@lidel lidel closed this as completed May 11, 2017
@lidel lidel reopened this May 11, 2017
@lidel
Copy link
Member

lidel commented May 11, 2017

I am afraid extensionizer is not enough, as it is still callback-based.

Firefox introduced promise-based syntax and that functionality for Chrome is provided by webextension-polyfill, which is safe to be enabled all the time.

Update:

I've added the polyfill and it should be possible to build via npm run build and load it into Chromium based browser.

Browser button does not work yet, but that's a start.
Each error can be now fixed while using Chromium developer tools.

I also updated the list of known issues.

lidel added a commit that referenced this issue May 11, 2017
lidel added a commit that referenced this issue May 11, 2017
This solves load error under Chromium

Part of #218
lidel added a commit that referenced this issue May 13, 2017
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
lidel added a commit that referenced this issue May 13, 2017
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
lidel added a commit that referenced this issue May 13, 2017
@lidel
Copy link
Member

lidel commented May 13, 2017

Oh hey, look what the cat dragged in:

2017-05-13-211205_897x506_scrot

I made some changes and chromium-compat branch loads under Chromium without "Hard Errors".

So far I noticed 3 issues that need additional work (see "Soft Errors"), but basic functionality works (redirect, Quick Upload, copying public URL, pinning etc)

lidel added a commit that referenced this issue May 21, 2017
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 added a commit that referenced this issue May 21, 2017
lidel added a commit that referenced this issue May 24, 2017
Firefox supported simplified syntax, but Chromium does not.

Implements part of #218
lidel added a commit that referenced this issue May 24, 2017
lidel added a commit that referenced this issue May 24, 2017
Only one of browser_action, page_action can be specified in Chrome

Part of #218 effort
lidel added a commit that referenced this issue May 24, 2017
lidel added a commit that referenced this issue May 24, 2017
This solves load error under Chromium

Part of #218
lidel added a commit that referenced this issue May 24, 2017
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
lidel added a commit that referenced this issue May 24, 2017
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
lidel added a commit that referenced this issue May 24, 2017
lidel added a commit that referenced this issue May 24, 2017
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 added a commit that referenced this issue May 24, 2017
lidel added a commit that referenced this issue Jul 8, 2017
This replaces alarm-based updates with message-based signalling
based on `browser.runtime.connect` API

Chrome does not support Alarm intervals smaller than one minute,
so we will replace all of them with this new type of signalling.
This is yet another piece of #218 (and #259) efforts.

This commit also closes #243 by hiding broken actions in 'incognito' mode.
lidel added a commit that referenced this issue Jul 9, 2017
This fixes 1-minute-refresh lag in Chrome-based browsers (#218)
and enables us to skip updates when browser is idle for more than 5 minutes.

It should also close #259, as it no longer relies on Alerts for status
updates.
@lidel lidel closed this as completed in #266 Jul 9, 2017
@styfle
Copy link

styfle commented Jul 27, 2017

@lidel Is this published to the Chrome Web Store now?

@lidel lidel mentioned this issue Jul 27, 2017
7 tasks
@lidel
Copy link
Member

lidel commented Jul 27, 2017

Not yet, but thanks for asking! I created #268 to track that.

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 a pull request may close this issue.

6 participants