mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-23 12:51:06 +00:00
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:
parent
196fd4c78c
commit
0b5dab40c6
@ -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"]
|
||||
|
39
docshell/test/mochitest/test_popup_unknown_protocol.html
Normal file
39
docshell/test/mochitest/test_popup_unknown_protocol.html
Normal 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>
|
Loading…
Reference in New Issue
Block a user