mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-11-09 21:00:42 +02:00
This patch includes the following changes:
- move into the API schema wrappers the additional checks needed (in the child process) to ensure that we throw a validation error when
a webRequest blocking listener is registered by an extension that doesn't have the required webRequestBlocking permission:
- define a new webRequestBlockingPermissionRequired postprocessor
- add to web_request.json API schema the `"postprocess": "webRequestBlockingPermissionRequired"` property
to all the webRequest options types that allows "blocking" as a valid string value (currently
OnBeforeRequestOptions, OnBeforeSendHeadersOptions, OnHeadersReceivedOptions and OnAuthRequiredOptions)
- add back an additional check for the webRequestBlocking permission in parent/ext-webRequest.js
(just in case a new webRequest event is added in the future and we forget to add the postprocess
property, so that we still ensure that an extension without the webRequestBlocking permission
is not able to register any blocking listener)
- tweak the test_no_webRequestBlocking_error test case to use browser.test.assertThrows to explicitly check
that the error is thrown and "catchable" by the extension code, and not just logged in the console
messages, and extend it to run on all the webRequest API events that can be blocking.
Differential Revision: https://phabricator.services.mozilla.com/D14994
--HG--
extra : moz-landing-system : lando
35 lines
813 B
JavaScript
35 lines
813 B
JavaScript
/* -*- Mode: indent-tabs-mode: nil; js-indent-level: 2 -*- */
|
|
/* vim: set sts=2 sw=2 et tw=80: */
|
|
"use strict";
|
|
|
|
this.webRequest = class extends ExtensionAPI {
|
|
getAPI(context) {
|
|
let filters = new WeakSet();
|
|
|
|
context.callOnClose({
|
|
close() {
|
|
for (let filter of ChromeUtils.nondeterministicGetWeakSetKeys(filters)) {
|
|
try {
|
|
filter.disconnect();
|
|
} catch (e) {
|
|
// Ignore.
|
|
}
|
|
}
|
|
},
|
|
});
|
|
|
|
return {
|
|
webRequest: {
|
|
filterResponseData(requestId) {
|
|
requestId = parseInt(requestId, 10);
|
|
|
|
let streamFilter = context.cloneScope.StreamFilter.create(
|
|
requestId, context.extension.id);
|
|
|
|
filters.add(streamFilter);
|
|
return streamFilter;
|
|
},
|
|
},
|
|
};
|
|
}
|
|
};
|