2 const { ManifestFinder
} = ChromeUtils
.importESModule(
3 "resource://gre/modules/ManifestFinder.sys.mjs"
5 const defaultURL
= new URL(
6 "http://example.org/browser/dom/manifest/test/resource.sjs"
8 defaultURL
.searchParams
.set("Content-Type", "text/html; charset=utf-8");
13 <link rel="manifesto" href='${defaultURL}?body={"name":"fail"}'>
14 <link rel="foo bar manifest bar test" href='${defaultURL}?body={"name":"value"}'>
15 <link rel="manifest" href='${defaultURL}?body={"name":"fail"}'>
18 ok(result
, "Document has a web manifest.");
23 <link rel="amanifista" href='${defaultURL}?body={"name":"fail"}'>
24 <link rel="foo bar manifesto bar test" href='${defaultURL}?body={"name":"pass-1"}'>
25 <link rel="manifesto" href='${defaultURL}?body={"name":"fail"}'>`,
27 ok(!result
, "Document does not have a web manifest.");
32 <link rel="manifest" href="">
33 <link rel="manifest" href='${defaultURL}?body={"name":"fail"}'>`,
35 ok(!result
, "Manifest link is has empty href.");
41 <link rel="manifest" href='${defaultURL}?body={"name":"fail"}'>`,
43 ok(!result
, "Manifest link is missing.");
48 function makeTestURL({ body
}) {
49 const url
= new URL(defaultURL
);
50 url
.searchParams
.set("body", encodeURIComponent(body
));
55 * Test basic API error conditions
57 add_task(async
function () {
58 const expected
= "Invalid types should throw a TypeError.";
59 for (let invalidValue
of [undefined, null, 1, {}, "test"]) {
61 await ManifestFinder
.contentManifestLink(invalidValue
);
64 is(e
.name
, "TypeError", expected
);
67 await ManifestFinder
.browserManifestLink(invalidValue
);
70 is(e
.name
, "TypeError", expected
);
75 add_task(async
function () {
76 const runningTests
= tests
80 url
: makeTestURL(test
),
83 BrowserTestUtils
.withNewTab(tabOptions
, async
function (browser
) {
84 const result
= await ManifestFinder
.browserHasManifestLink(browser
);
85 tabOptions
.test
.run(result
);
88 await Promise
.all(runningTests
);