Add ability to implement programmable custom protocol handler
Categories
(WebExtensions :: Experiments, enhancement, P5)
Tracking
(firefox70 affected)
Tracking | Status | |
---|---|---|
firefox70 | --- | affected |
People
(Reporter: yuki, Unassigned)
References
(Depends on 12 open bugs, Blocks 1 open bug)
Details
(Whiteboard: [design-decision-approved]triaged)
Attachments
(4 files, 7 obsolete files)
Reporter | ||
Updated•9 years ago
|
Updated•9 years ago
|
Comment 1•9 years ago
|
||
Reporter | ||
Comment 2•9 years ago
|
||
Reporter | ||
Comment 3•9 years ago
|
||
Reporter | ||
Comment 4•9 years ago
|
||
Comment 5•9 years ago
|
||
Comment 6•9 years ago
|
||
Comment 7•9 years ago
|
||
Reporter | ||
Comment 8•9 years ago
|
||
Reporter | ||
Comment 9•9 years ago
|
||
Reporter | ||
Comment 10•9 years ago
|
||
Updated•9 years ago
|
Comment 12•8 years ago
|
||
Updated•8 years ago
|
Comment 13•8 years ago
|
||
Updated•8 years ago
|
Comment 14•8 years ago
|
||
Comment 15•8 years ago
|
||
Comment 16•8 years ago
|
||
Comment 17•8 years ago
|
||
Comment 18•8 years ago
|
||
Comment 19•8 years ago
|
||
Comment 20•8 years ago
|
||
Comment 22•8 years ago
|
||
Comment 23•8 years ago
|
||
Comment 24•8 years ago
|
||
Comment 25•8 years ago
|
||
Comment 26•8 years ago
|
||
Comment 27•8 years ago
|
||
Comment 28•8 years ago
|
||
Updated•8 years ago
|
Comment 29•8 years ago
|
||
Comment hidden (mozreview-request) |
Comment 31•8 years ago
|
||
Comment 32•8 years ago
|
||
Comment 33•8 years ago
|
||
Comment 34•8 years ago
|
||
Comment 35•8 years ago
|
||
Comment 36•8 years ago
|
||
Comment 37•8 years ago
|
||
Comment 38•8 years ago
|
||
Comment 39•8 years ago
|
||
Updated•8 years ago
|
Comment 40•8 years ago
|
||
Comment 41•8 years ago
|
||
Comment 42•8 years ago
|
||
Comment 43•8 years ago
|
||
Comment 44•8 years ago
|
||
Comment 45•8 years ago
|
||
Updated•8 years ago
|
Updated•8 years ago
|
Updated•8 years ago
|
Comment 46•8 years ago
|
||
Comment 47•8 years ago
|
||
Comment 48•8 years ago
|
||
Comment 50•8 years ago
|
||
Comment 51•7 years ago
|
||
Comment 52•7 years ago
|
||
Comment 53•7 years ago
|
||
Comment 54•7 years ago
|
||
Comment hidden (metoo) |
Updated•7 years ago
|
Updated•7 years ago
|
Comment 56•7 years ago
|
||
Comment 57•7 years ago
|
||
Comment 58•7 years ago
|
||
Comment 59•7 years ago
|
||
Comment 60•7 years ago
|
||
Comment 61•7 years ago
|
||
Updated•7 years ago
|
Comment 62•7 years ago
|
||
Comment 63•7 years ago
|
||
Updated•6 years ago
|
Comment 64•6 years ago
|
||
Updated•6 years ago
|
Comment 65•6 years ago
|
||
bz I know we've talked about this in the past, but I'm afraid I need to re-query you on this once again as it appears things have changed since causing different behaviors.
So we're looking to expose an API for custom protocol definitions that mimic service workers except per-protocol bases and for web-extensions only. We would like protocols to have following properties, but are failing short with selection of protocol flags to achieve that:
- We would like CORS with-in the protocol boundaries so that fetch across origins e.g.
dweb://foo
anddweb://bar
is controllable via CORS headers but generally restricted if not explicitly enabled. - We would like to restrict embedding & fetching across standard and custom protocols.
- We would like to enable navigation cross-protocol links as link to https resources with-in
dweb://foo
should be treated as a link and vice versa. At the same time we don't want to allow location change across protocols to prevent tracking by redirecting to some central server and back. - We would like add-ons to be able to open tabs with custom protocols (which currently fails even with
NS_ERROR_DOM_BAD_URI
when web-extensions code runsscriptSecurityManager.checkLoadURIWithPrincipal
) - We want to enable some none standard cross-protocol embedding / fetching. e.g.
ipns://foo
to embedipfs://${hash}/icon.png
At the moment used protocolFlags
are:
Ci.nsIProtocolHandler.URI_STD |
Ci.nsIProtocolHandler.URI_IS_UI_RESOURCE |
Ci.nsIProtocolHandler.URI_IS_POTENTIALLY_TRUSTWORTHY |
Ci.nsIProtocolHandler.URI_LOADABLE_BY_EXTENSIONS
However CORS don't seem to apply across different origins under same protocol (they used to at couple of month ago, not sure what's changed). It also appears that URI_LOADABLE_BY_EXTENSIONS
has no effect when URI_IS_UI_RESOURCE
is used which if I recall correctly we've introduced to restrict embedding between custom protocols and HTTP(S).
Could you please advise what would be a way to achieve desired goals or whether those goals make sense.
Thank you!
Comment 66•6 years ago
|
||
We would like CORS with-in the protocol boundaries
I am not aware of a protocol flag for that.
We would like to restrict embedding & fetching across standard and custom protocols.
I don't think you can restrict embedding https:// (say) via protocol flags. Fetching via the fetch
API would be restricted by the usual same-origin policy bits...
That said, maybe you can do this with a CSP you force on these protocols.
We would like to enable navigation cross-protocol links
There isn't really a difference between "embedding" and "linking" for protocol flag purposes. Again, maybe you can do this with forced CSP.
At the same time we don't want to allow location change across protocols
I'm not sure what differentiates "location change" from "navigation" here.
We would like add-ons to be able to open tabs with custom protocols
What principal is the relevant part of the add-on running with? I'd expect URI_LOADABLE_BY_EXTENSIONS to work here.
currently fails even with NS_ERROR_DOM_BAD_URI when web-extensions code runs scriptSecurityManager.checkLoadURIWithPrincipal
Have you stepped through to see why?
We want to enable some none standard cross-protocol embedding / fetching.
I don't think protocol flags let you control that.
However CORS don't seem to apply across different origins under same protocol
It should apply for the cases that are designed to apply CORS (fetch, XHR, HTML elements with "crossorigin" attributes set), but not for all cases. I'm not aware, offhand, of something changing here, which doesn't mean nothing changed...
It also appears that URI_LOADABLE_BY_EXTENSIONS has no effect when URI_IS_UI_RESOURCE is used
Odd. Code inspection suggests it's checked before we ever go looking at URI_IS_UI_RESOURCE. Again, I would suggest stepping through CheckLoadURIWithPrincipal and seeing what's going on.
In general, it sounds like you want to define a loading policy for this stuff which is quite different from anything we have right now; our current protocol flags are designed to express the use cases we have right now and can't express this use case. My suggestion would be to talk to the content security team about what exactly your use case is and how they recommend approaching this. There's a good chance you will need to introduce either new protocol flags or new custom code in the content security manager or both to achieve the goals as listed above.
Comment 67•6 years ago
|
||
Implements programmable custom protocol API based on the libdweb exploration.
Implementation adds manifest protocol
key to make list of protocols provided
by extension static. API is only made available no nightly and dev edition and
for users that opt-in through libdweb.protocol.$extension_id: true
pref. API
restrictions are intentionally enforced at runtime to allow our partners ship
extensions that optionally can use this API on instances that opt-in.
Current implementation will be improved in followup changes e.g content
type detection, cross protocol interaction boundries, use of workers.
Comment 68•6 years ago
|
||
Implements programmable custom protocol API based on the libdweb exploration.
Implementation adds manifest protocol key to make list of protocols provided
by extension static. API is only made available no nightly and dev edition and
for users that opt-in through libdweb.protocol.$extension_id: true pref. API
restrictions are intentionally enforced at runtime to allow our partners ship
extensions that optionally can use this API on instances that opt-in.
Current implementation will be improved in followup changes e.g content
type detection, cross protocol interaction boundries, use of workers.
Updated•5 years ago
|
Comment 69•5 years ago
|
||
Fix for the Bug 1536744 removed abiliti for nsIProtocolHandler to parse URLs of the
custom protocols & broke libdweb. In order to fix followup change for Bug 1559356 introduced a
whitelist for dweb: and dat: protocols to parse those as nsIStandardURLs. This change extends
whitelist with ipfs: ipns: ssb: schemes and ext+ prefix scheme.
This would allow Bug 1271553 to progress until better more general solution can be implemnted.
Updated•5 years ago
|
Comment 70•5 years ago
|
||
:bz I started work on creating a dynamic registry for custom protocols, but then I also would like to make progress on this sooner. So I've created a patch to just extend whitelist for now. Who would be a right person to request a review from on this ?
Comment 71•5 years ago
|
||
Implements programmable custom protocol API based on the libdweb exploration.
Implementation adds manifest protocol key to make list of protocols provided
by extension static. API is only made available no nightly and dev edition and
for users that opt-in through libdweb.protocol.$extension_id: true pref. API
restrictions are intentionally enforced at runtime to allow our partners ship
extensions that optionally can use this API on instances that opt-in.
Comment 72•5 years ago
|
||
Valentin is out, right? Looking at the blame for this code, probably Kershaw?
Updated•5 years ago
|
Updated•5 years ago
|
Comment 73•5 years ago
|
||
Adding checkin-needed for D39463 as I'm blocked on getting my L3 restored https://bugzilla.mozilla.org/show_bug.cgi?id=1569822
Comment 75•5 years ago
|
||
Comment 76•5 years ago
|
||
Backed out changeset 8d6593460b06 for mochitest failures.
Backout link: https://hg.mozilla.org/integration/autoland/rev/8d6593460b06df740e232130420c8daf81c0428d
Failure log: https://treeherder.mozilla.org/logviewer.html#/jobs?job_id=258937839&repo=autoland&lineNumber=25355
[task 2019-07-30T04:30:34.720Z] 04:30:34 INFO - TEST-PASS | toolkit/components/extensions/test/mochitest/test_ext_protocolHandlers.html | correct url template
[task 2019-07-30T04:30:34.723Z] 04:30:34 INFO - Buffered messages finished
[task 2019-07-30T04:30:34.723Z] 04:30:34 INFO - TEST-UNEXPECTED-FAIL | toolkit/components/extensions/test/mochitest/test_ext_protocolHandlers.html | test query ok - got "?val=ext%2Bfoo%3A%2F%2Ftest%2F", expected "?val=ext%2Bfoo%3Atest"
[task 2019-07-30T04:30:34.723Z] 04:30:34 INFO - SimpleTest.is@SimpleTest/SimpleTest.js:320:16
[task 2019-07-30T04:30:34.723Z] 04:30:34 INFO - test_protocolHandler@toolkit/components/extensions/test/mochitest/test_ext_protocolHandlers.html:126:3
[task 2019-07-30T04:30:34.723Z] 04:30:34 INFO - asyncnextTick/<@SimpleTest/SimpleTest.js:1793:34
[task 2019-07-30T04:30:34.723Z] 04:30:34 INFO - nextTick@SimpleTest/SimpleTest.js:1809:11
[task 2019-07-30T04:30:34.723Z] 04:30:34 INFO - setTimeout handlerSimpleTest_setTimeoutShim@SimpleTest/SimpleTest.js:684:43
[task 2019-07-30T04:30:34.723Z] 04:30:34 INFO - add_task@SimpleTest/SimpleTest.js:1753:7
[task 2019-07-30T04:30:34.723Z] 04:30:34 INFO - @toolkit/components/extensions/test/mochitest/test_ext_protocolHandlers.html:45:1
[task 2019-07-30T04:30:34.724Z] 04:30:34 INFO - GECKO(1914) | [Parent 1914, Main Thread] WARNING: Constructing RangeBoundary with invalid value: 'mRef || aOffset == 0', file /builds/worker/workspace/build/src/obj-firefox/dist/include/mozilla/RangeBoundary.h, line 79
[task 2019-07-30T04:30:34.725Z] 04:30:34 INFO - GECKO(1914) | [Parent 1914, Main Thread] WARNING: Constructing RangeBoundary with invalid value: 'mRef || aOffset == 0', file /builds/worker/workspace/build/src/obj-firefox/dist/include/mozilla/RangeBoundary.h, line 79
[task 2019-07-30T04:30:34.725Z] 04:30:34 INFO - GECKO(1914) | [Child 1916, Main Thread] WARNING: No active window: file /builds/worker/workspace/build/src/js/xpconnect/src/XPCJSContext.cpp, line 664
Comment 77•5 years ago
|
||
:mixedpuppy :kmag my working assumption was that we would allow extensions to implement handful of known protocols and ones that start with ext+
(matching the choices in extension_protocol_handlers.json
) however as it turns out (from the test failures above) it is assumed that ext+
corresponds to URI
s rather that standard URL
s.
For now I would remove ext+
prefix from set of schemes that need to be parsed as standard URL
s, but I would love to get your input on what do you think would make most sense here. Once Bug 1569733 is addressed it would be possible to to opt-in individual schemes (into standard URL parsing) like ext+foo
but not ext+bar
, still not sure if that seems reasonable or something entirely different should be done here.
Thanks
Comment 78•5 years ago
|
||
This is what is allowed in protocol handlers:
The failure seems to be that the protocol url is being changed from "something:foo" to "something://foo", which shouldn't happen. This should continue to work:
Services.io.newURI("abcd://test").spec;
"abcd://test"
Services.io.newURI("abcd:test").spec;
"abcd:test"
Whether any of the protocols in the above schema should be transformed to look more like uris is one question, but I'm not aware of why we should do that. If your protocols specifically always should be transformed, then I'd focus on those.
Comment 79•5 years ago
|
||
(In reply to Shane Caraveo (:mixedpuppy) from comment #78)
This is what is allowed in protocol handlers:
The failure seems to be that the protocol url is being changed from "something:foo" to "something://foo", which shouldn't happen. This should continue to work:
Services.io.newURI("abcd://test").spec;
"abcd://test"
Services.io.newURI("abcd:test").spec;
"abcd:test"Whether any of the protocols in the above schema should be transformed to look more like uris is one question, but I'm not aware of why we should do that. If your protocols specifically always should be transformed, then I'd focus on those.
I think you're missing some context here, let me try to elaborate:
- When extension registers protocol implementation for specific scheme e.g.
ipfs
orext+foo
Firefox will start recognizing them as standard URLs not URIs which have notion of relative URLs and authority. We could offer an option to register protocol handler for URIs in a future, but so far that had being no interest as all the protocols need relativeness and authority. nsIProtocolHandler
could opt-in specific scheme to standard URL serving protocol (which is what implementation is doing) meaning thatServices.io.newURI("ext+foo:bar").spec === "ext+foo:bar"
that is unless add-on would register implementation ofext+foo
protocol after whichServices.io.newURI("ext+foo:bar").spec === "ext+foo://bar"
.- Bug 1536744 removed ability from
nsIProtocolHandler
to declare whether underlying protocol is fornsIStandardURL
ornsIURI
effectively ignoringprotocolFlags
. I think we should restore that ability (see Bug 1569733), but in the meantime I'm adding protocol schemes to the whitelist as a temporary solution.
However all this made me realize that allowing extension to opt-in specific protocol scheme e.g. ext+ipfs
into URI_STD
may not necessarily be reasonable, hence my question above.
Comment 80•5 years ago
|
||
Well, the only comment I have on this is that allowing Services.io.newURI("ext+foo:bar").spec === "ext+foo://bar" will break protocol_handler in any existing extensions, thus the failed test.
Can you address this in your api layer instead? convert any uri use to the :// form? Or add a new prefix such as dweb+ ?
Comment 81•5 years ago
|
||
Comment 82•5 years ago
|
||
Comment 83•5 years ago
|
||
bugherder |
Comment 84•5 years ago
|
||
There seems to be something wrong with the bugs you set in the "Regressed By" field. In particular, one of them is still open and the patch attached to that was never landed, so it definitely can't have caused a regression.
Are you sure you wanted to set those bugs in "Regressed By"? Or did you want to add them to the "Depends On" field? Is this even a regression? (it doesn't seem like a regression to me)
Comment 85•5 years ago
|
||
(In reply to Marco Castelluccio [:marco] from comment #84)
There seems to be something wrong with the bugs you set in the "Regressed By" field. In particular, one of them is still open and the patch attached to that was never landed, so it definitely can't have caused a regression.
Are you sure you wanted to set those bugs in "Regressed By"? Or did you want to add them to the "Depends On" field? Is this even a regression? (it doesn't seem like a regression to me)
Hi :marco, you're right regressed by may not be an ideal field, so let me elaborate what's going on here. Bug 1553105 removed ability from nsIProtocolHandler
to specify how URLs for it's protocol behave e.g things like URI_STD
, URI_NORELATIVE
, URI_NOAUTH
, ... (in the past those were flags on protocolFlags
). These changes broke pending patch here because URLs our protocols API exposes end up loosing notion of relativeness or authority.
My understanding that it was done because according to spec only http / https have those properties & Bug 1553105 takes it step further and would make origin be property of those two protocol schemes. Now regression by 1553105 had being mitigated by temporary workaround, however pending patch will regress once again once Bug 1553105 is landed because content from our protocols won't have origin & there for access to the many web APIs. So I marked this as regressed by it pro-actively.
So perfect flag would say "Bug 1553105 Breaks Bug 1271553" but as we don't have one, I thought "regressed by" was most adequate option.
Comment 86•5 years ago
|
||
I see, a pretty confusing situation :P
In this case, if bug 1553105 breaks bug 1271553, a new bug should be filed to track the regression. The newly filed bug can have "Regressed By" set to bug 1553105, and bug 1271553 either in "See Also" or in "Blocks".
Bug 1271553 can have bug 1553105 in "See Also" or "Depends On".
"Regressed By" should only be used for actual regressions (something that used to work at some point in some Firefox build and stopped working because something else landed breaking it), so we can track what caused what.
When you don't know what field to use to link two bugs, I guess "See Also" is the best option to avoid mistakes.
Updated•5 years ago
|
Updated•5 years ago
|
Updated•5 years ago
|
Updated•5 years ago
|
Updated•5 years ago
|
Updated•5 years ago
|
Updated•5 years ago
|
Updated•5 years ago
|
Updated•5 years ago
|
Updated•5 years ago
|
Updated•5 years ago
|
Comment 87•5 years ago
|
||
Any update on this? I'm currently using the implementation from github for an experimental extension for the dat protocol. This implementation has just stopped working on Nightly. Discussing on IRC, it would be useful to at least have the implementation and tests in mozilla-central to track regressions like this, and know which change-sets caused them.
Comment 88•5 years ago
|
||
(In reply to sam from comment #87)
Any update on this? I'm currently using the implementation from github for an experimental extension for the dat protocol. This implementation has just stopped working on Nightly. Discussing on IRC, it would be useful to at least have the implementation and tests in mozilla-central to track regressions like this, and know which change-sets caused them.
Any clue on how it's broken in Nightly?
Comment 89•5 years ago
|
||
(In reply to Valentin Gosu [:valentin] (he/him) from comment #88)
(In reply to sam from comment #87)
Any update on this? I'm currently using the implementation from github for an experimental extension for the dat protocol. This implementation has just stopped working on Nightly. Discussing on IRC, it would be useful to at least have the implementation and tests in mozilla-central to track regressions like this, and know which change-sets caused them.
Any clue on how it's broken in Nightly?
This line throws this.loadGroup is undefined
when handling a request: https://github.com/mozilla/libdweb/blob/master/src/toolkit/components/extensions/ExtensionProtocol.js#L383
I believe this refers to the loadGroup
attribute on the nsIRequest
interface: https://searchfox.org/mozilla-central/source/netwerk/base/nsIRequest.idl
Comment 90•5 years ago
|
||
This line throws this.loadGroup is undefined when handling a request:
Nothing in that file ever sets this.loadGroup
, right?
Comment 91•5 years ago
|
||
(In reply to Boris Zbarsky [:bzbarsky, bz on IRC] from comment #90)
This line throws this.loadGroup is undefined when handling a request:
Nothing in that file ever sets
this.loadGroup
, right?
True. I just had another look and it seems that this method was not properly implemented yet. Before current nightly it did not get called, so this didn't cause any problems. Just commenting out the mentioned line is enough to fix it.
Updated•4 years ago
|
Updated•4 years ago
|
Comment 92•2 years ago
|
||
The bug assignee is inactive on Bugzilla, so the assignee is being reset.
Updated•2 years ago
|
Updated•2 years ago
|
Description
•