Backed out changeset 6573975cfe40 (bug 1743653) for causing mochitest failures on browser_protocol_ask_dialog_permission.js CLOSED TREE

This commit is contained in:
Cristian Tuns 2022-03-29 08:16:09 -04:00
Родитель cafc14e738
Коммит 6a5e277a4c
4 изменённых файлов: 7 добавлений и 212 удалений

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

@ -97,9 +97,6 @@ support-files =
support-files =
redirect_helper.sjs
[browser_protocol_ask_dialog_permission.js]
support-files =
redirect_helper.sjs
script_redirect.html
[browser_protocolhandler_loop.js]
[browser_remember_download_option.js]
[browser_txt_download_save_as.js]

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

@ -7,11 +7,6 @@ let gHandlerService = Cc["@mozilla.org/uriloader/handler-service;1"].getService(
Ci.nsIHandlerService
);
const ROOT_PATH = getRootDirectory(gTestPath).replace(
"chrome://mochitests/content/",
""
);
// Testing multiple protocol / origin combinations takes long on debug.
requestLongerTimeout(3);
@ -125,9 +120,6 @@ async function triggerOpenProto(
useNullPrincipal = false,
useExtensionPrincipal = false,
omitTriggeringPrincipal = false,
useJSRedirect = false,
serverRedirect = "",
linkToRedirect = false,
} = {}
) {
let uri = `${scheme}://test`;
@ -180,65 +172,6 @@ async function triggerOpenProto(
return;
}
if (useJSRedirect) {
let innerParams = new URLSearchParams();
innerParams.set("uri", uri);
let params = new URLSearchParams();
params.set(
"uri",
"https://example.com/" +
ROOT_PATH +
"script_redirect.html?" +
innerParams.toString()
);
uri =
"https://example.org/" +
ROOT_PATH +
"script_redirect.html?" +
params.toString();
BrowserTestUtils.loadURI(browser, uri);
return;
}
if (serverRedirect) {
let innerParams = new URLSearchParams();
innerParams.set("uri", uri);
innerParams.set("redirectType", serverRedirect);
let params = new URLSearchParams();
params.set(
"uri",
"https://example.com/" +
ROOT_PATH +
"redirect_helper.sjs?" +
innerParams.toString()
);
uri =
"https://example.org/" +
ROOT_PATH +
"redirect_helper.sjs?" +
params.toString();
BrowserTestUtils.loadURI(browser, uri);
return;
}
if (linkToRedirect) {
let params = new URLSearchParams();
params.set("uri", uri);
uri =
"https://example.com/" +
ROOT_PATH +
"redirect_helper.sjs?" +
params.toString();
await ContentTask.spawn(browser, { uri }, args => {
let textLink = content.document.createElement("a");
textLink.href = args.uri;
textLink.textContent = "click me";
content.document.body.appendChild(textLink);
textLink.click();
});
return;
}
info("Loading uri: " + uri);
browser.loadURI(uri, { triggeringPrincipal });
}
@ -296,7 +229,6 @@ async function testOpenProto(
let {
hasCheckbox,
checkboxOrigin,
hasChangeApp,
chooserIsNext,
actionCheckbox,
@ -322,7 +254,6 @@ async function testOpenProto(
await testCheckbox(dialogEl, dialogType, {
hasCheckbox,
actionCheckbox,
checkboxOrigin,
});
// Check the button label depending on whether we would show the chooser
@ -380,11 +311,7 @@ async function testOpenProto(
}
// Clean up test extension if needed.
if (testExtension) {
await testExtension.unload();
// Don't try to unload it again later!
testExtension = null;
}
await testExtension?.unload();
}
/**
@ -403,7 +330,7 @@ async function testOpenProto(
async function testCheckbox(
dialogEl,
dialogType,
{ hasCheckbox, hasCheckboxState = false, actionCheckbox, checkboxOrigin }
{ hasCheckbox, hasCheckboxState = false, actionCheckbox }
) {
let checkbox = dialogEl.ownerDocument.getElementById("remember");
if (typeof hasCheckbox == "boolean") {
@ -431,14 +358,6 @@ async function testCheckbox(
is(checkbox.checked, hasCheckboxState, "Dialog checkbox has correct state");
}
if (checkboxOrigin) {
let doc = dialogEl.ownerDocument;
let hostFromLabel = doc.l10n.getAttributes(
doc.getElementById("remember-label")
).args.host;
is(hostFromLabel, checkboxOrigin, "Checkbox should be for correct domain.");
}
if (typeof actionCheckbox == "boolean") {
checkbox.click();
}
@ -849,103 +768,3 @@ add_task(async function test_extension_principal() {
});
});
});
/**
* Test that we use the redirect principal for the dialog when applicable.
*/
add_task(async function test_redirect_principal() {
let scheme = TEST_PROTOS[0];
await BrowserTestUtils.withNewTab("about:blank", async browser => {
await testOpenProto(browser, scheme, {
loadOptions: {
serverRedirect: "location",
},
permDialogOptions: {
checkboxOrigin: ORIGIN1,
chooserIsNext: true,
hasCheckbox: true,
actionConfirm: false, // Cancel dialog
},
});
});
});
/**
* Test that we use the redirect principal for the dialog for refresh headers.
*/
add_task(async function test_redirect_principal() {
let scheme = TEST_PROTOS[0];
await BrowserTestUtils.withNewTab("about:blank", async browser => {
await testOpenProto(browser, scheme, {
loadOptions: {
serverRedirect: "refresh",
},
permDialogOptions: {
checkboxOrigin: ORIGIN1,
chooserIsNext: true,
hasCheckbox: true,
actionConfirm: false, // Cancel dialog
},
});
});
});
/**
* Test that we use the redirect principal for the dialog for meta refreshes.
*/
add_task(async function test_redirect_principal() {
let scheme = TEST_PROTOS[0];
await BrowserTestUtils.withNewTab("about:blank", async browser => {
await testOpenProto(browser, scheme, {
loadOptions: {
serverRedirect: "meta-refresh",
},
permDialogOptions: {
checkboxOrigin: ORIGIN1,
chooserIsNext: true,
hasCheckbox: true,
actionConfirm: false, // Cancel dialog
},
});
});
});
/**
* Test that we use the redirect principal for the dialog for JS redirects.
*/
add_task(async function test_redirect_principal_js() {
let scheme = TEST_PROTOS[0];
await BrowserTestUtils.withNewTab("about:blank", async browser => {
await testOpenProto(browser, scheme, {
loadOptions: {
useJSRedirect: true,
},
permDialogOptions: {
checkboxOrigin: ORIGIN1,
chooserIsNext: true,
hasCheckbox: true,
actionConfirm: false, // Cancel dialog
},
});
});
});
/**
* Test that we use the redirect principal for the dialog for link clicks.
*/
add_task(async function test_redirect_principal_links() {
let scheme = TEST_PROTOS[0];
await BrowserTestUtils.withNewTab("about:blank", async browser => {
await testOpenProto(browser, scheme, {
loadOptions: {
linkToRedirect: true,
},
permDialogOptions: {
checkboxOrigin: ORIGIN1,
chooserIsNext: true,
hasCheckbox: true,
actionConfirm: false, // Cancel dialog
},
});
});
});

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

@ -6,25 +6,9 @@
Cu.importGlobalProperties(["URLSearchParams"]);
function handleRequest(request, response) {
let params = new URLSearchParams(request.queryString);
let uri = params.get("uri");
let redirectType = params.get("redirectType") || "location";
switch (redirectType) {
case "refresh":
response.setStatusLine(request.httpVersion, 200, "OK");
response.setHeader("Refresh", "0; url=" + uri);
break;
case "meta-refresh":
response.setStatusLine(request.httpVersion, 200, "OK");
response.setHeader("Content-Type", "text/html");
response.write(`<meta http-equiv="refresh" content="0; url=${uri}">`);
break;
case "location":
// fall through
default:
response.setStatusLine(request.httpVersion, 302, "Moved Temporarily");
response.setHeader("Location", uri);
}
response.setStatusLine(request.httpVersion, 302, "Moved Temporarily");
response.setHeader(
"Location",
new URLSearchParams(request.queryString).get("uri")
);
}

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

@ -1,5 +0,0 @@
<script>
let params = new URL(document.location).searchParams;
let uri = params.get("uri");
document.location = uri;
</script>