gecko-dev/dom/manifest/test/test_IconsProcessor_density...

58 строки
2.0 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 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>
/**
* icon member's 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);
ise(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);
ise(result.icons[0].density, parseFloat(testNumber), expected);
});
</script>
</head>