Bug 1580811 - Add xpcshell test to check that moz-extension: redirect by webRequest is loaded in the correct process, r=zombie

This was originally authored by :willdurand for bug 1573456, but was broken at
the time due to DocumentChannel not knowing how handle parent-initiated document
loads. The behaviour was fixed in bug 1673869, so this test now works.

Differential Revision: https://phabricator.services.mozilla.com/D80987
This commit is contained in:
Kashav Madan 2020-07-09 21:34:51 +00:00
Родитель 6290dc16f9
Коммит 069254b63a
2 изменённых файлов: 49 добавлений и 1 удалений

Просмотреть файл

@ -0,0 +1,47 @@
"use strict";
// See: https://bugzilla.mozilla.org/show_bug.cgi?id=1573456
add_task(async function test_mozextension_page_loaded_in_extension_process() {
let extension = ExtensionTestUtils.loadExtension({
manifest: {
permissions: [
"webRequest",
"webRequestBlocking",
"https://example.com/*",
],
web_accessible_resources: ["test.html"],
},
files: {
"test.html": '<!DOCTYPE html><script src="test.js"></script>',
"test.js": () => {
browser.test.assertTrue(
browser.webRequest,
"webRequest API should be available"
);
browser.test.sendMessage("test_done");
},
},
background: () => {
browser.webRequest.onBeforeRequest.addListener(
() => {
return {
redirectUrl: browser.runtime.getURL("test.html"),
};
},
{ urls: ["*://*/redir"] },
["blocking"]
);
},
});
await extension.startup();
let contentPage = await ExtensionTestUtils.loadContentPage(
"https://example.com/redir"
);
await extension.awaitMessage("test_done");
await extension.unload();
await contentPage.close();
});

Просмотреть файл

@ -201,6 +201,7 @@ skip-if = os == "android" && debug
[test_ext_webRequest_mergecsp.js] [test_ext_webRequest_mergecsp.js]
[test_ext_webRequest_permission.js] [test_ext_webRequest_permission.js]
skip-if = os == "android" && debug skip-if = os == "android" && debug
[test_ext_webRequest_redirect_mozextension.js]
[test_ext_webRequest_requestSize.js] [test_ext_webRequest_requestSize.js]
skip-if = socketprocess_networking skip-if = socketprocess_networking
[test_ext_webRequest_responseBody.js] [test_ext_webRequest_responseBody.js]