Source code
Revision control
Copy as Markdown
Other Tools
Test Info:
- Manifest: dom/manifest/test/mochitest.toml
<!DOCTYPE HTML>
<html>
<!--
-->
<head>
<meta charset="utf-8">
<script src="/tests/SimpleTest/SimpleTest.js"></script>
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
<script src="common.js"></script>
<script>
"use strict";
const options = {...data, checkConformance: true } ;
[
{
func: () => options.jsonText = JSON.stringify(1),
warn: "Manifest should be an object.",
},
{
func: () => options.jsonText = JSON.stringify("a string"),
warn: "Manifest should be an object.",
},
{
func: () => options.jsonText = JSON.stringify({
}),
warn: "The scope URL must be same origin as document.",
},
{
func: () => options.jsonText = JSON.stringify({
scope: "foo",
start_url: "bar",
}),
warn: "The start URL is outside the scope, so the scope is invalid.",
},
{
func: () => options.jsonText = JSON.stringify({
}),
warn: "The start URL must be same origin as document.",
},
{
func: () => options.jsonText = JSON.stringify({
start_url: 42,
}),
warn: "Expected the manifest\u2019s start_url member to be a string.",
},
{
func: () => options.jsonText = JSON.stringify({
theme_color: "42",
}),
warn: "theme_color: 42 is not a valid CSS color.",
},
{
func: () => options.jsonText = JSON.stringify({
background_color: "42",
}),
warn: "background_color: 42 is not a valid CSS color.",
},
{
func: () => options.jsonText = JSON.stringify({
icons: [
],
}),
},
// testing dom.properties: ManifestImageUnusable
{
func() {
return (options.jsonText = JSON.stringify({
icons: [
],
}));
},
get warn() {
// Returns 2 warnings... array here is just to keep them organized
return [
"icons item at index 1 includes unsupported purpose(s): banana.",
"icons item at index 1 lacks a usable purpose. It will be ignored.",
].join(" ");
},
},
// testing dom.properties: ManifestImageUnsupportedPurposes
{
func() {
return (options.jsonText = JSON.stringify({
icons: [
],
}));
},
warn: "icons item at index 1 includes unsupported purpose(s): foo bar baz.",
},
// testing dom.properties: ManifestImageRepeatedPurposes
{
func() {
return (options.jsonText = JSON.stringify({
icons: [
{
purpose: "any maskable any maskable maskable", // generates error
},
],
}));
},
warn: "icons item at index 1 includes repeated purpose(s): any maskable.",
},
// testing dom.properties: ManifestIdIsInvalid
{
},
warn: "The id member did not resolve to a valid URL.",
},
// testing dom.properties ManifestIdNotSameOrigin
{
func() {
}));
},
warn: "The id member must have the same origin as the start_url member.",
}
].forEach((test) => {
test.func();
const result = processor.process(options);
let messages = [];
// Poking directly at "warn" triggers xray security wrapper.
for (const validationError of result.moz_validation) {
const { warn } = validationError;
messages.push(warn);
}
is(messages.join(" "), test.warn, "Check warning.");
options.manifestURL = manifestURL;
options.docURL = docURL;
});
</script>
</head>