Bug 1881037 - Part 2: Add a basic test for loading unknown protocols in a popup window, r=smaug

The console notification is only created when an error page would not
otherwise load, so allows us to detect the situation where the error
page is not going to be loaded.

Differential Revision: https://phabricator.services.mozilla.com/D218984
This commit is contained in:
Nika Layzell 2024-08-15 10:19:49 +00:00
parent 196fd4c78c
commit 0b5dab40c6
2 changed files with 46 additions and 0 deletions

View File

@ -286,6 +286,13 @@ skip-if = [
"http2",
]
["test_popup_unknown_protocol.html"]
skip-if = [
# Android handles external protocols and error pages differently, so this test
# doesn't make sense to run on that platform.
"os == 'android'",
]
["test_pushState_after_document_open.html"]
["test_redirect_history.html"]

View File

@ -0,0 +1,39 @@
<!doctype html>
<html>
<head>
<title>Test for loading unknown protocols in a popup window</title>
<script src="/tests/SimpleTest/SimpleTest.js"></script>
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
</head>
<body>
<script>
"use strict";
add_task(async function() {
let consoleMessagePromise = new Promise(resolve => {
info("registering console listener");
SpecialPowers.registerConsoleListener(msg => {
info(`Got console message: ${msg.errorMessage}`);
if (msg.errorMessage && msg.errorMessage.includes("unknown-protocol")) {
SpecialPowers.executeSoon(() => {
SpecialPowers.postConsoleSentinel();
resolve();
});
}
});
});
info("opening pop-up");
let popup = window.open("unknown-protocol://example", "_blank");
info("waiting for console message error");
await consoleMessagePromise;
is(popup.location.href, "about:blank");
ok(!SpecialPowers.wrap(popup).docShell.failedChannel,
"no failed channel specified, as no error page is being loaded");
});
</script>
</body>
</html>