Source code
Revision control
Copy as Markdown
Other Tools
Test Info:
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
"use strict";
const { validateProfilerWebChannelUrl } = ChromeUtils.importESModule(
"resource:///modules/DevToolsStartup.sys.mjs"
);
add_task(function test() {
info(
"Since the WebChannel can communicate with a content page, test that only " +
"trusted URLs can be used with this mechanism."
);
const { checkUrlIsValid, checkUrlIsInvalid } = setup();
info("Check all of the valid URLs");
info("Check all of the invalid URLs");
});
function setup() {
function checkUrlIsValid(url) {
info(`Check that ${url} is valid`);
equal(
validateProfilerWebChannelUrl(url),
url,
`"${url}" is a valid WebChannel URL.`
);
}
function checkUrlIsInvalid(url) {
info(`Check that ${url} is invalid`);
equal(
validateProfilerWebChannelUrl(url),
`"${url}" was not valid, and was reset to the base URL.`
);
}
return {
checkUrlIsValid,
checkUrlIsInvalid,
};
}