-
Notifications
You must be signed in to change notification settings - Fork 219
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
browser.devtools.network.onRequestFinished
does not promisify getContent()
#249
browser.devtools.network.onRequestFinished
does not promisify getContent()
#249
Comments
Regardless of the expected format, there are certainly two parameters. It's currently also the only API common to Firefox and Chrome where an API method resolves to an object that has an method with a callback. So it sounds reasonable to hard-code this API in the polyfill, without bothering to introduce support for a generic way of declaring the API in api-metadata.json. A wrapper can be added to webextension-polyfill/src/browser-polyfill.js Line 482 in 93203c6
Patches are very welcome :) |
Made #250 to fix the implementation of the polyfill. I'm trying to make a patch for MDN as well, although that is a bit trickier for me as I've never worked with mozilla-central before, so I need to make an account and set up my workspace and everything. I'll try to update that separately. |
I updated the MDN page for Since MDN is editable directly through the site, I'm a little unclear on what devtools_network.json represents in mozilla-central. I left that alone for now as I don't understand what I would be updating or what the end result of the change should be. |
I have filed https://bugzilla.mozilla.org/show_bug.cgi?id=1681085 for the Firefox side. |
Fixes #249. This updates `browser.devtools.network.onRequestFinished` to emit an object with a promisified `getContent()` property. This brings the polyfill implementation in line with Firefox's implementation, although MDN documentation is still inaccurate at the moment. Also updates some out of date documentation with `makeCallback()` and `wrapAsyncFunction()`.
On Chrome,
chrome.devtools.network.onRequestFinished.addListener
emits achrome.devtools.network.Request
object, which includes agetContent()
method that invokes a callback with string content and its encoding. Correct usage looks like:With Web Extensions,
getContent()
should return aPromise
rather than being callback based. For example:Currently however, the Web Extensions polyfill simply passes through what it receives from Chrome, so
getContent()
is still callback based.I wasn't able to find
browser.devtools
in the spec, however MDN does say that this method exists and does in fact return aPromise
.firefox-webext-browser
also says this returnsPromise<object>
. I'm not totally clear if this is an official part of the spec, or a Firefox-specific API.My questions here are:
browser.devtools.network.onRequestFinished
actually defined in the Web Extensions spec somewhere?Promise<object>
is pretty vague and MDN doesn't provide specifics.[string, string]
, where the former is the content as a string or a base64 encoded string (if binary), and the latter is an empty string or'base64'
(if binary). I'm not sure what the expected behavior of Web Extensions would be for binary data?I'm happy to write up a PR to implement this if it is appropriate to add to this polyfill. I'm not totally clear on where this API stands with respect to the spec, but if you're willing to merge it, I'm happy to write it.
The text was updated successfully, but these errors were encountered: