summaryrefslogtreecommitdiffstats
path: root/dom/manifest/test/test_ImageObjectProcessor_src.html
diff options
context:
space:
mode:
authorMatt A. Tobin <mattatobin@localhost.localdomain>2018-02-02 04:16:08 -0500
committerMatt A. Tobin <mattatobin@localhost.localdomain>2018-02-02 04:16:08 -0500
commit5f8de423f190bbb79a62f804151bc24824fa32d8 (patch)
tree10027f336435511475e392454359edea8e25895d /dom/manifest/test/test_ImageObjectProcessor_src.html
parent49ee0794b5d912db1f95dce6eb52d781dc210db5 (diff)
downloadUXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.gz
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.lz
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.xz
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.zip
Add m-esr52 at 52.6.0
Diffstat (limited to 'dom/manifest/test/test_ImageObjectProcessor_src.html')
-rw-r--r--dom/manifest/test/test_ImageObjectProcessor_src.html106
1 files changed, 106 insertions, 0 deletions
diff --git a/dom/manifest/test/test_ImageObjectProcessor_src.html b/dom/manifest/test/test_ImageObjectProcessor_src.html
new file mode 100644
index 000000000..cb77af0bd
--- /dev/null
+++ b/dom/manifest/test/test_ImageObjectProcessor_src.html
@@ -0,0 +1,106 @@
+<!DOCTYPE HTML>
+<html>
+<!--
+https://bugzilla.mozilla.org/show_bug.cgi?id=1079453
+-->
+<head>
+ <meta charset="utf-8">
+ <title>Test for Bug 1079453</title>
+ <script type="application/javascript" 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: ''
+ }]
+};
+
+var expected = `Expect icons with invalid src prop to be filtered out.`;
+data.jsonText = JSON.stringify(noSrc);
+var result = processor.process(data);
+is(result.icons.length, 0, expected);
+
+var expected = `Expect icon's src to be a string.`;
+var withSrc = {
+ icons: [{
+ src: 'pass'
+ }]
+};
+data.jsonText = JSON.stringify(withSrc);
+var result = processor.process(data);
+is(typeof result.icons[0].src, "string", expected);
+
+var expected = `Expect only icons with a src prop to be kept.`;
+var withSrc = {
+ icons: [{
+ src: 'pass'
+ }, {
+ src: 'pass',
+ }, {}, {
+ foo: 'foo'
+ }]
+};
+data.jsonText = JSON.stringify(withSrc);
+var result = processor.process(data);
+is(result.icons.length, 2, expected);
+
+var expectedURL = new URL('pass', manifestURL);
+for (var icon of result.icons) {
+ var 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) => {
+ var expected = `Resolve icon src URLs relative to manifest.`;
+ data.jsonText = JSON.stringify({
+ icons: [{
+ src: url
+ }]
+ });
+ var absURL = new URL(url, manifestURL).toString();
+ var result = processor.process(data);
+ is(result.icons[0].src.toString(), absURL, expected);
+});
+ </script>
+</head>