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();
});

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

@ -106,7 +106,7 @@ skip-if = true # This test no longer tests what it is meant to test.
[test_ext_permission_xhr.js]
[test_ext_persistent_events.js]
[test_ext_privacy.js]
skip-if = appname == "thunderbird" || (os == "android" && debug) || (os == "linux" && !debug) #Bug 1625455
skip-if = appname == "thunderbird" || (os == "android" && debug) || (os == "linux" && !debug) #Bug 1625455
[test_ext_privacy_disable.js]
skip-if = appname == "thunderbird"
[test_ext_privacy_update.js]
@ -201,6 +201,7 @@ skip-if = os == "android" && debug
[test_ext_webRequest_mergecsp.js]
[test_ext_webRequest_permission.js]
skip-if = os == "android" && debug
[test_ext_webRequest_redirect_mozextension.js]
[test_ext_webRequest_requestSize.js]
skip-if = socketprocess_networking
[test_ext_webRequest_responseBody.js]