<!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 type property
 * https://w3c.github.io/manifest/#type-member
 **/

"use strict";
var testIcon = {
  icons: [{
    src: "test",
    type: undefined,
  }],
};

var invalidMimeTypes = [
  "application / text",
  "test;test",
  ";test?test",
  "application\\text",
  "image/jpeg, image/gif",
];
invalidMimeTypes.forEach((invalidMime) => {
  var expected = `Expect invalid mime to be treated like undefined.`;
  testIcon.icons[0].type = invalidMime;
  data.jsonText = JSON.stringify(testIcon);
  var result = processor.process(data);
  is(result.icons[0].type, undefined, expected);
});

var validTypes = [
  "image/jpeg",
  "IMAGE/jPeG",
  `${whiteSpace}image/jpeg${whiteSpace}`,
  "image/JPEG; whatever=something",
  "image/JPEG;whatever",
];

validTypes.forEach((validMime) => {
  var expected = `Expect valid mime to be parsed to : image/jpeg.`;
  testIcon.icons[0].type = validMime;
  data.jsonText = JSON.stringify(testIcon);
  var result = processor.process(data);
  is(result.icons[0].type, "image/jpeg", expected);
});
  </script>
</head>
