Bug 1918529 - fix some subpixel misalignment issues with gfx.webrender.svg-filter...
[gecko.git] / dom / manifest / test / browser_ManifestFinder_browserHasManifestLink.js
blob360c98220bb81490675c51ecc2a5b9f3658813df
1 "use strict";
2 const { ManifestFinder } = ChromeUtils.importESModule(
3 "resource://gre/modules/ManifestFinder.sys.mjs"
4 );
5 const defaultURL = new URL(
6 "http://example.org/browser/dom/manifest/test/resource.sjs"
7 );
8 defaultURL.searchParams.set("Content-Type", "text/html; charset=utf-8");
10 const tests = [
12 body: `
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"}'>
17 run(result) {
18 ok(result, "Document has a web manifest.");
22 body: `
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"}'>`,
26 run(result) {
27 ok(!result, "Document does not have a web manifest.");
31 body: `
32 <link rel="manifest" href="">
33 <link rel="manifest" href='${defaultURL}?body={"name":"fail"}'>`,
34 run(result) {
35 ok(!result, "Manifest link is has empty href.");
39 body: `
40 <link rel="manifest">
41 <link rel="manifest" href='${defaultURL}?body={"name":"fail"}'>`,
42 run(result) {
43 ok(!result, "Manifest link is missing.");
48 function makeTestURL({ body }) {
49 const url = new URL(defaultURL);
50 url.searchParams.set("body", encodeURIComponent(body));
51 return url.href;
54 /**
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"]) {
60 try {
61 await ManifestFinder.contentManifestLink(invalidValue);
62 ok(false, expected);
63 } catch (e) {
64 is(e.name, "TypeError", expected);
66 try {
67 await ManifestFinder.browserManifestLink(invalidValue);
68 ok(false, expected);
69 } catch (e) {
70 is(e.name, "TypeError", expected);
73 });
75 add_task(async function () {
76 const runningTests = tests
77 .map(test => ({
78 gBrowser,
79 test,
80 url: makeTestURL(test),
81 }))
82 .map(tabOptions =>
83 BrowserTestUtils.withNewTab(tabOptions, async function (browser) {
84 const result = await ManifestFinder.browserHasManifestLink(browser);
85 tabOptions.test.run(result);
88 await Promise.all(runningTests);
89 });