зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1654833 - Improve error message when webRequest listener is passed an invalid urls filter r=robwu
Differential Revision: https://phabricator.services.mozilla.com/D89944
This commit is contained in:
Родитель
b343cb50cf
Коммит
8ca0706c76
|
@ -10,6 +10,8 @@ ChromeUtils.defineModuleGetter(
|
|||
"resource://gre/modules/WebRequest.jsm"
|
||||
);
|
||||
|
||||
var { parseMatchPatterns } = ExtensionUtils;
|
||||
|
||||
// The guts of a WebRequest event handler. Takes care of converting
|
||||
// |details| parameter when invoking listeners.
|
||||
function registerEvent(
|
||||
|
@ -43,7 +45,7 @@ function registerEvent(
|
|||
...extension.optionalOrigins.patterns,
|
||||
]);
|
||||
|
||||
filter2.urls = new MatchPatternSet(filter.urls);
|
||||
filter2.urls = parseMatchPatterns(filter.urls);
|
||||
|
||||
if (!perms.overlapsAll(filter2.urls)) {
|
||||
Cu.reportError(
|
||||
|
|
|
@ -0,0 +1,35 @@
|
|||
/* Any copyright is dedicated to the Public Domain.
|
||||
http://creativecommons.org/publicdomain/zero/1.0/ */
|
||||
|
||||
"use strict";
|
||||
|
||||
AddonTestUtils.init(this);
|
||||
|
||||
add_task(async function test_invalid_urls_in_webRequest_filter() {
|
||||
let extension = ExtensionTestUtils.loadExtension({
|
||||
manifest: {
|
||||
permissions: ["webRequest", "https://example.com/*"],
|
||||
},
|
||||
background() {
|
||||
browser.webRequest.onBeforeRequest.addListener(() => {}, {
|
||||
urls: ["htt:/example.com/*"],
|
||||
types: ["main_frame"],
|
||||
});
|
||||
},
|
||||
});
|
||||
let { messages } = await promiseConsoleOutput(async () => {
|
||||
await extension.startup();
|
||||
await extension.unload();
|
||||
});
|
||||
AddonTestUtils.checkMessages(
|
||||
messages,
|
||||
{
|
||||
expected: [
|
||||
{
|
||||
message: /ExtensionError: Invalid url pattern: htt:\/example.com\/*/,
|
||||
},
|
||||
],
|
||||
},
|
||||
true
|
||||
);
|
||||
});
|
|
@ -200,6 +200,7 @@ skip-if = os == "android" && processor != "x86_64" # Bug 1573511
|
|||
[test_ext_webRequest_from_extension_page.js]
|
||||
[test_ext_webRequest_incognito.js]
|
||||
skip-if = os == "android" && debug
|
||||
[test_ext_webRequest_filter_urls.js]
|
||||
[test_ext_webRequest_host.js]
|
||||
skip-if = os == "android" && debug
|
||||
[test_ext_webRequest_mergecsp.js]
|
||||
|
|
Загрузка…
Ссылка в новой задаче