Source code
Revision control
Copy as Markdown
Other Tools
Test Info:
<!DOCTYPE HTML>
<html>
<head>
<title>Test for simple WebExtension</title>
<script type="text/javascript" src="head.js"></script>
</head>
<body>
<script type="text/javascript">
"use strict";
add_task(async function webnav_unresolved_uri_on_expected_URI_scheme() {
function background() {
let checkURLs;
browser.webNavigation.onCompleted.addListener(async msg => {
if (checkURLs.length) {
let expectedURL = checkURLs.shift();
browser.test.assertEq(expectedURL, msg.url, "Got the expected URL");
await browser.tabs.remove(msg.tabId);
browser.test.sendMessage("next");
}
});
browser.test.onMessage.addListener((name, urls) => {
if (name == "checkURLs") {
checkURLs = urls;
}
});
browser.test.sendMessage("ready", browser.runtime.getURL("/tab.html"));
}
let extensionData = {
manifest: {
permissions: [
"webNavigation",
],
},
background,
files: {
"tab.html": `<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
</head>
</html>
`,
},
};
let extension = ExtensionTestUtils.loadExtension(extensionData);
await extension.startup();
let checkURLs = [
"resource://gre/modules/XPCOMUtils.sys.mjs",
"about:mozilla",
];
let tabURL = await extension.awaitMessage("ready");
checkURLs.push(tabURL);
extension.sendMessage("checkURLs", checkURLs);
for (let url of checkURLs) {
window.open(url);
await extension.awaitMessage("next");
}
await extension.unload();
});
</script>
</body>
</html>