gecko-dev/dom/manifest/test/test_ImageObjectProcessor_src.html
Brian Grinstead 0d460e3432 Bug 1544322 - Part 2.2 - Remove the [type] attribute for one-liner <script> tags loading files in /tests/SimpleTest/ in dom/ r=bzbarsky
This is split from the previous changeset since if we include dom/ the file size is too
large for phabricator to handle.

This is an autogenerated commit to handle scripts loading mochitest harness files, in
the simple case where the script src is on the same line as the tag.

This was generated with https://bug1544322.bmoattachments.org/attachment.cgi?id=9058170
using the `--part 2` argument.

Differential Revision: https://phabricator.services.mozilla.com/D27457

--HG--
extra : moz-landing-system : lando
2019-04-16 03:53:28 +00:00

111 lines
2.2 KiB
HTML

<!DOCTYPE HTML>
<html>
<!--
https://bugzilla.mozilla.org/show_bug.cgi?id=1079453
-->
<head>
<meta charset="utf-8">
<title>Test for Bug 1079453</title>
<script src="/tests/SimpleTest/SimpleTest.js"></script>
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
<script src="common.js"></script>
<script>
/**
* Image object's src member
* https://w3c.github.io/manifest/#src-member
**/
"use strict";
var noSrc = {
icons: [{}, {
src: [],
}, {
src: {},
}, {
src: null,
}, {
type: "image/jpg",
}, {
sizes: "1x1,2x2",
}, {
sizes: "any",
type: "image/jpg",
}],
};
var expected = `Expect icons without a src prop to be filtered out.`;
data.jsonText = JSON.stringify(noSrc);
var result = processor.process(data);
is(result.icons.length, 0, expected);
var invalidSrc = {
icons: [{
src: null,
}, {
src: 1,
}, {
src: [],
}, {
src: {},
}, {
src: true,
}, {
src: "",
}],
};
expected = `Expect icons with invalid src prop to be filtered out.`;
data.jsonText = JSON.stringify(invalidSrc);
result = processor.process(data);
is(result.icons.length, 0, expected);
expected = `Expect icon's src to be a string.`;
var withSrc = {
icons: [{
src: "pass",
}],
};
data.jsonText = JSON.stringify(withSrc);
result = processor.process(data);
is(typeof result.icons[0].src, "string", expected);
expected = `Expect only icons with a src prop to be kept.`;
withSrc = {
icons: [{
src: "pass",
}, {
src: "pass",
}, {}, {
foo: "foo",
}],
};
data.jsonText = JSON.stringify(withSrc);
result = processor.process(data);
is(result.icons.length, 2, expected);
var expectedURL = new URL("pass", manifestURL);
for (var icon of result.icons) {
expected = `Expect src prop to be ${expectedURL.toString()}`;
is(icon.src.toString(), expectedURL.toString(), expected);
}
// Resolve URLs relative to manfiest
var URLs = ["path", "/path", "../../path"];
URLs.forEach((url) => {
expected = `Resolve icon src URLs relative to manifest.`;
data.jsonText = JSON.stringify({
icons: [{
src: url,
}],
});
var absURL = new URL(url, manifestURL).toString();
result = processor.process(data);
is(result.icons[0].src.toString(), absURL, expected);
});
</script>
</head>