Bug 1264813 - Remove image object's density member from Web Manifest processor. r=mconley
authorMarcos Caceres <marcos@marcosc.com>
Thu, 14 Apr 2016 17:26:00 +0200
changeset 331399 3243da9095ef3fd8458966625c73ba6a03a51f8e
parent 331398 a9e12099d7f695c943dae615d2978687e709b9d6
child 331400 668fa79490ed60a861f48cbfd0f717197b8165c1
push id6048
push userkmoir@mozilla.com
push dateMon, 06 Jun 2016 19:02:08 +0000
treeherdermozilla-beta@46d72a56c57d [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmconley
bugs1264813
milestone48.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1264813 - Remove image object's density member from Web Manifest processor. r=mconley
dom/manifest/ImageObjectProcessor.jsm
dom/manifest/test/mochitest.ini
dom/manifest/test/test_ImageObjectProcessor_density.html
dom/manifest/test/test_ImageObjectProcessor_src.html
--- a/dom/manifest/ImageObjectProcessor.jsm
+++ b/dom/manifest/ImageObjectProcessor.jsm
@@ -70,17 +70,16 @@ ImageObjectProcessor.prototype.process =
   }
   return images;
 
   function toImageObject(aImageSpec) {
     return {
       'src': processSrcMember(aImageSpec, aBaseURL),
       'type': processTypeMember(aImageSpec),
       'sizes': processSizesMember(aImageSpec),
-      'density': processDensityMember(aImageSpec),
       'background_color': processBackgroundColorMember(aImageSpec)
     };
   }
 
   function processTypeMember(aImage) {
     const charset = {};
     const hadCharset = {};
     const spec = {
@@ -92,23 +91,16 @@ ImageObjectProcessor.prototype.process =
     };
     let value = extractor.extractValue(spec);
     if (value) {
       value = netutil.parseRequestContentType(value, charset, hadCharset);
     }
     return value || undefined;
   }
 
-  function processDensityMember(aImage) {
-    const value = parseFloat(aImage.density);
-    const validNum = Number.isNaN(value) || value === +Infinity || value <=
-      0;
-    return (validNum) ? 1.0 : value;
-  }
-
   function processSrcMember(aImage, aBaseURL) {
     const spec = {
       objectName: 'image',
       object: aImage,
       property: 'src',
       expectedType: 'string',
       trim: false
     };
--- a/dom/manifest/test/mochitest.ini
+++ b/dom/manifest/test/mochitest.ini
@@ -1,15 +1,14 @@
 [DEFAULT]
 support-files =
 	common.js
 	resource.sjs
 	manifestLoader.html
 [test_ImageObjectProcessor_background_color.html]
-[test_ImageObjectProcessor_density.html]
 [test_ImageObjectProcessor_sizes.html]
 [test_ImageObjectProcessor_src.html]
 [test_ImageObjectProcessor_type.html]
 [test_ManifestProcessor_background_color.html]
 [test_ManifestProcessor_dir.html]
 [test_ManifestProcessor_display.html]
 [test_ManifestProcessor_icons.html]
 [test_ManifestProcessor_JSON.html]
deleted file mode 100644
--- a/dom/manifest/test/test_ImageObjectProcessor_density.html
+++ /dev/null
@@ -1,57 +0,0 @@
-<!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 density member
- * https://w3c.github.io/manifest/#density-member
- **/
-'use strict';
-
-var testIcon = {
-  icons: [{
-    src: 'test',
-    density: undefined
-  }]
-};
-
-var iconDensityValueTests = [null, {},
-  [], false, '', -0, '-0', -1.0000, -123131132, -1.2e+200,
-  'Infinity', '-Infinity',
-  '-1000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000',
-  '1000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000'
-];
-
-iconDensityValueTests.forEach((density) => {
-  var expected = `Expect density to default to 1.0.`;
-  testIcon.icons[0].density = density;
-  data.jsonText = JSON.stringify(testIcon);
-  var result = processor.process(data);
-  is(result.icons[0].density, 1.0, expected);
-});
-
-testIcon = {
-  icons: [{
-    src: 'test',
-    density: undefined
-  }]
-};
-
-var parseFloatTests = [3.14, '3.14', `${whiteSpace}3.14${whiteSpace}`, 12e300];
-parseFloatTests.forEach((testNumber) => {
-  var expected = `Expect density to be ${parseFloat(testNumber)}.`;
-  testIcon.icons[0].density = testNumber;
-  data.jsonText = JSON.stringify(testIcon);
-  var result = processor.process(data);
-  is(result.icons[0].density, parseFloat(testNumber), expected);
-});
-  </script>
-</head>
--- a/dom/manifest/test/test_ImageObjectProcessor_src.html
+++ b/dom/manifest/test/test_ImageObjectProcessor_src.html
@@ -18,23 +18,20 @@ https://bugzilla.mozilla.org/show_bug.cg
 var noSrc = {
   icons: [{}, {
     src: []
   }, {
     src: {}
   }, {
     src: null
   }, {
-    density: '1'
-  }, {
     type: 'image/jpg'
   }, {
     sizes: '1x1,2x2'
   }, {
-    density: '1',
     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);
@@ -72,17 +69,16 @@ 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',
-    density: 1
   }, {}, {
     foo: 'foo'
   }]
 };
 data.jsonText = JSON.stringify(withSrc);
 var result = processor.process(data);
 is(result.icons.length, 2, expected);