blob: 71a432871f54b0fd88903d9f63c3de05ff1049a8 [file] [log] [blame]
<html>
<head>
<script src="../../resources/js-test-pre.js"></script>
</head>
<body>
<p id="description"></p>
<div id="console"></div>
<script>
description("This tests the parser for preserve aspect ratio attribute values.");
var imageElement = document.createElementNS("http://www.w3.org/2000/svg", "image");
function parsePreserveAspectRatio(string, alignValue, meetOrSliceValue)
{
imageElement.setAttributeNS(null, "preserveAspectRatio", string);
debug("Test string: '" + string + "'");
shouldBe("imageElement.preserveAspectRatio.baseVal.align", alignValue);
shouldBe("imageElement.preserveAspectRatio.baseVal.meetOrSlice", meetOrSliceValue);
debug("");
}
parsePreserveAspectRatio("none", "SVGPreserveAspectRatio.SVG_PRESERVEASPECTRATIO_NONE", "SVGPreserveAspectRatio.SVG_MEETORSLICE_MEET");
parsePreserveAspectRatio("xMinYMin", "SVGPreserveAspectRatio.SVG_PRESERVEASPECTRATIO_XMINYMIN", "SVGPreserveAspectRatio.SVG_MEETORSLICE_MEET");
parsePreserveAspectRatio("xMidYMin", "SVGPreserveAspectRatio.SVG_PRESERVEASPECTRATIO_XMIDYMIN", "SVGPreserveAspectRatio.SVG_MEETORSLICE_MEET");
parsePreserveAspectRatio("xMaxYMin", "SVGPreserveAspectRatio.SVG_PRESERVEASPECTRATIO_XMAXYMIN", "SVGPreserveAspectRatio.SVG_MEETORSLICE_MEET");
parsePreserveAspectRatio("xMinYMid", "SVGPreserveAspectRatio.SVG_PRESERVEASPECTRATIO_XMINYMID", "SVGPreserveAspectRatio.SVG_MEETORSLICE_MEET");
parsePreserveAspectRatio("xMidYMid", "SVGPreserveAspectRatio.SVG_PRESERVEASPECTRATIO_XMIDYMID", "SVGPreserveAspectRatio.SVG_MEETORSLICE_MEET");
parsePreserveAspectRatio("xMaxYMid", "SVGPreserveAspectRatio.SVG_PRESERVEASPECTRATIO_XMAXYMID", "SVGPreserveAspectRatio.SVG_MEETORSLICE_MEET");
parsePreserveAspectRatio("xMinYMax", "SVGPreserveAspectRatio.SVG_PRESERVEASPECTRATIO_XMINYMAX", "SVGPreserveAspectRatio.SVG_MEETORSLICE_MEET");
parsePreserveAspectRatio("xMidYMax", "SVGPreserveAspectRatio.SVG_PRESERVEASPECTRATIO_XMIDYMAX", "SVGPreserveAspectRatio.SVG_MEETORSLICE_MEET");
parsePreserveAspectRatio("xMaxYMax", "SVGPreserveAspectRatio.SVG_PRESERVEASPECTRATIO_XMAXYMAX", "SVGPreserveAspectRatio.SVG_MEETORSLICE_MEET");
parsePreserveAspectRatio("xMinYMin meet", "SVGPreserveAspectRatio.SVG_PRESERVEASPECTRATIO_XMINYMIN", "SVGPreserveAspectRatio.SVG_MEETORSLICE_MEET");
parsePreserveAspectRatio("xMidYMin meet", "SVGPreserveAspectRatio.SVG_PRESERVEASPECTRATIO_XMIDYMIN", "SVGPreserveAspectRatio.SVG_MEETORSLICE_MEET");
parsePreserveAspectRatio("xMaxYMin meet", "SVGPreserveAspectRatio.SVG_PRESERVEASPECTRATIO_XMAXYMIN", "SVGPreserveAspectRatio.SVG_MEETORSLICE_MEET");
parsePreserveAspectRatio("xMinYMid meet", "SVGPreserveAspectRatio.SVG_PRESERVEASPECTRATIO_XMINYMID", "SVGPreserveAspectRatio.SVG_MEETORSLICE_MEET");
parsePreserveAspectRatio("xMidYMid meet", "SVGPreserveAspectRatio.SVG_PRESERVEASPECTRATIO_XMIDYMID", "SVGPreserveAspectRatio.SVG_MEETORSLICE_MEET");
parsePreserveAspectRatio("xMaxYMid meet", "SVGPreserveAspectRatio.SVG_PRESERVEASPECTRATIO_XMAXYMID", "SVGPreserveAspectRatio.SVG_MEETORSLICE_MEET");
parsePreserveAspectRatio("xMinYMax meet", "SVGPreserveAspectRatio.SVG_PRESERVEASPECTRATIO_XMINYMAX", "SVGPreserveAspectRatio.SVG_MEETORSLICE_MEET");
parsePreserveAspectRatio("xMidYMax meet", "SVGPreserveAspectRatio.SVG_PRESERVEASPECTRATIO_XMIDYMAX", "SVGPreserveAspectRatio.SVG_MEETORSLICE_MEET");
parsePreserveAspectRatio("xMaxYMax meet", "SVGPreserveAspectRatio.SVG_PRESERVEASPECTRATIO_XMAXYMAX", "SVGPreserveAspectRatio.SVG_MEETORSLICE_MEET");
parsePreserveAspectRatio("xMinYMin slice", "SVGPreserveAspectRatio.SVG_PRESERVEASPECTRATIO_XMINYMIN", "SVGPreserveAspectRatio.SVG_MEETORSLICE_SLICE");
parsePreserveAspectRatio("xMidYMin slice", "SVGPreserveAspectRatio.SVG_PRESERVEASPECTRATIO_XMIDYMIN", "SVGPreserveAspectRatio.SVG_MEETORSLICE_SLICE");
parsePreserveAspectRatio("xMaxYMin slice", "SVGPreserveAspectRatio.SVG_PRESERVEASPECTRATIO_XMAXYMIN", "SVGPreserveAspectRatio.SVG_MEETORSLICE_SLICE");
parsePreserveAspectRatio("xMinYMid slice", "SVGPreserveAspectRatio.SVG_PRESERVEASPECTRATIO_XMINYMID", "SVGPreserveAspectRatio.SVG_MEETORSLICE_SLICE");
parsePreserveAspectRatio("xMidYMid slice", "SVGPreserveAspectRatio.SVG_PRESERVEASPECTRATIO_XMIDYMID", "SVGPreserveAspectRatio.SVG_MEETORSLICE_SLICE");
parsePreserveAspectRatio("xMaxYMid slice", "SVGPreserveAspectRatio.SVG_PRESERVEASPECTRATIO_XMAXYMID", "SVGPreserveAspectRatio.SVG_MEETORSLICE_SLICE");
parsePreserveAspectRatio("xMinYMax slice", "SVGPreserveAspectRatio.SVG_PRESERVEASPECTRATIO_XMINYMAX", "SVGPreserveAspectRatio.SVG_MEETORSLICE_SLICE");
parsePreserveAspectRatio("xMidYMax slice", "SVGPreserveAspectRatio.SVG_PRESERVEASPECTRATIO_XMIDYMAX", "SVGPreserveAspectRatio.SVG_MEETORSLICE_SLICE");
parsePreserveAspectRatio("xMaxYMax slice", "SVGPreserveAspectRatio.SVG_PRESERVEASPECTRATIO_XMAXYMAX", "SVGPreserveAspectRatio.SVG_MEETORSLICE_SLICE");
parsePreserveAspectRatio("defer xMinYMin", "SVGPreserveAspectRatio.SVG_PRESERVEASPECTRATIO_XMINYMIN", "SVGPreserveAspectRatio.SVG_MEETORSLICE_MEET");
parsePreserveAspectRatio("defer xMidYMin", "SVGPreserveAspectRatio.SVG_PRESERVEASPECTRATIO_XMIDYMIN", "SVGPreserveAspectRatio.SVG_MEETORSLICE_MEET");
parsePreserveAspectRatio("defer xMaxYMin", "SVGPreserveAspectRatio.SVG_PRESERVEASPECTRATIO_XMAXYMIN", "SVGPreserveAspectRatio.SVG_MEETORSLICE_MEET");
parsePreserveAspectRatio("defer xMinYMid", "SVGPreserveAspectRatio.SVG_PRESERVEASPECTRATIO_XMINYMID", "SVGPreserveAspectRatio.SVG_MEETORSLICE_MEET");
parsePreserveAspectRatio("defer xMidYMid", "SVGPreserveAspectRatio.SVG_PRESERVEASPECTRATIO_XMIDYMID", "SVGPreserveAspectRatio.SVG_MEETORSLICE_MEET");
parsePreserveAspectRatio("defer xMaxYMid", "SVGPreserveAspectRatio.SVG_PRESERVEASPECTRATIO_XMAXYMID", "SVGPreserveAspectRatio.SVG_MEETORSLICE_MEET");
parsePreserveAspectRatio("defer xMinYMax", "SVGPreserveAspectRatio.SVG_PRESERVEASPECTRATIO_XMINYMAX", "SVGPreserveAspectRatio.SVG_MEETORSLICE_MEET");
parsePreserveAspectRatio("defer xMidYMax", "SVGPreserveAspectRatio.SVG_PRESERVEASPECTRATIO_XMIDYMAX", "SVGPreserveAspectRatio.SVG_MEETORSLICE_MEET");
parsePreserveAspectRatio("defer xMaxYMax", "SVGPreserveAspectRatio.SVG_PRESERVEASPECTRATIO_XMAXYMAX", "SVGPreserveAspectRatio.SVG_MEETORSLICE_MEET");
parsePreserveAspectRatio("defer xMinYMin meet", "SVGPreserveAspectRatio.SVG_PRESERVEASPECTRATIO_XMINYMIN", "SVGPreserveAspectRatio.SVG_MEETORSLICE_MEET");
parsePreserveAspectRatio("defer xMidYMin meet", "SVGPreserveAspectRatio.SVG_PRESERVEASPECTRATIO_XMIDYMIN", "SVGPreserveAspectRatio.SVG_MEETORSLICE_MEET");
parsePreserveAspectRatio("defer xMaxYMin meet", "SVGPreserveAspectRatio.SVG_PRESERVEASPECTRATIO_XMAXYMIN", "SVGPreserveAspectRatio.SVG_MEETORSLICE_MEET");
parsePreserveAspectRatio("defer xMinYMid meet", "SVGPreserveAspectRatio.SVG_PRESERVEASPECTRATIO_XMINYMID", "SVGPreserveAspectRatio.SVG_MEETORSLICE_MEET");
parsePreserveAspectRatio("defer xMidYMid meet", "SVGPreserveAspectRatio.SVG_PRESERVEASPECTRATIO_XMIDYMID", "SVGPreserveAspectRatio.SVG_MEETORSLICE_MEET");
parsePreserveAspectRatio("defer xMaxYMid meet", "SVGPreserveAspectRatio.SVG_PRESERVEASPECTRATIO_XMAXYMID", "SVGPreserveAspectRatio.SVG_MEETORSLICE_MEET");
parsePreserveAspectRatio("defer xMinYMax meet", "SVGPreserveAspectRatio.SVG_PRESERVEASPECTRATIO_XMINYMAX", "SVGPreserveAspectRatio.SVG_MEETORSLICE_MEET");
parsePreserveAspectRatio("defer xMidYMax meet", "SVGPreserveAspectRatio.SVG_PRESERVEASPECTRATIO_XMIDYMAX", "SVGPreserveAspectRatio.SVG_MEETORSLICE_MEET");
parsePreserveAspectRatio("defer xMaxYMax meet", "SVGPreserveAspectRatio.SVG_PRESERVEASPECTRATIO_XMAXYMAX", "SVGPreserveAspectRatio.SVG_MEETORSLICE_MEET");
parsePreserveAspectRatio("defer xMinYMin slice", "SVGPreserveAspectRatio.SVG_PRESERVEASPECTRATIO_XMINYMIN", "SVGPreserveAspectRatio.SVG_MEETORSLICE_SLICE");
parsePreserveAspectRatio("defer xMidYMin slice", "SVGPreserveAspectRatio.SVG_PRESERVEASPECTRATIO_XMIDYMIN", "SVGPreserveAspectRatio.SVG_MEETORSLICE_SLICE");
parsePreserveAspectRatio("defer xMaxYMin slice", "SVGPreserveAspectRatio.SVG_PRESERVEASPECTRATIO_XMAXYMIN", "SVGPreserveAspectRatio.SVG_MEETORSLICE_SLICE");
parsePreserveAspectRatio("defer xMinYMid slice", "SVGPreserveAspectRatio.SVG_PRESERVEASPECTRATIO_XMINYMID", "SVGPreserveAspectRatio.SVG_MEETORSLICE_SLICE");
parsePreserveAspectRatio("defer xMidYMid slice", "SVGPreserveAspectRatio.SVG_PRESERVEASPECTRATIO_XMIDYMID", "SVGPreserveAspectRatio.SVG_MEETORSLICE_SLICE");
parsePreserveAspectRatio("defer xMaxYMid slice", "SVGPreserveAspectRatio.SVG_PRESERVEASPECTRATIO_XMAXYMID", "SVGPreserveAspectRatio.SVG_MEETORSLICE_SLICE");
parsePreserveAspectRatio("defer xMinYMax slice", "SVGPreserveAspectRatio.SVG_PRESERVEASPECTRATIO_XMINYMAX", "SVGPreserveAspectRatio.SVG_MEETORSLICE_SLICE");
parsePreserveAspectRatio("defer xMidYMax slice", "SVGPreserveAspectRatio.SVG_PRESERVEASPECTRATIO_XMIDYMAX", "SVGPreserveAspectRatio.SVG_MEETORSLICE_SLICE");
parsePreserveAspectRatio("defer xMaxYMax slice", "SVGPreserveAspectRatio.SVG_PRESERVEASPECTRATIO_XMAXYMAX", "SVGPreserveAspectRatio.SVG_MEETORSLICE_SLICE");
debug('Tests for some whitespace cases.');
debug('');
parsePreserveAspectRatio(" xMinYMin", "SVGPreserveAspectRatio.SVG_PRESERVEASPECTRATIO_XMINYMIN", "SVGPreserveAspectRatio.SVG_MEETORSLICE_MEET");
parsePreserveAspectRatio("xMinYMin ", "SVGPreserveAspectRatio.SVG_PRESERVEASPECTRATIO_XMINYMIN", "SVGPreserveAspectRatio.SVG_MEETORSLICE_MEET");
parsePreserveAspectRatio(" xMinYMin ", "SVGPreserveAspectRatio.SVG_PRESERVEASPECTRATIO_XMINYMIN", "SVGPreserveAspectRatio.SVG_MEETORSLICE_MEET");
parsePreserveAspectRatio(" xMinYMin ", "SVGPreserveAspectRatio.SVG_PRESERVEASPECTRATIO_XMINYMIN", "SVGPreserveAspectRatio.SVG_MEETORSLICE_MEET");
parsePreserveAspectRatio("xMinYMin" + String.fromCharCode(9), "SVGPreserveAspectRatio.SVG_PRESERVEASPECTRATIO_XMINYMIN", "SVGPreserveAspectRatio.SVG_MEETORSLICE_MEET");
parsePreserveAspectRatio("xMinYMin" + String.fromCharCode(10), "SVGPreserveAspectRatio.SVG_PRESERVEASPECTRATIO_XMINYMIN", "SVGPreserveAspectRatio.SVG_MEETORSLICE_MEET");
parsePreserveAspectRatio("xMinYMin" + String.fromCharCode(13), "SVGPreserveAspectRatio.SVG_PRESERVEASPECTRATIO_XMINYMIN", "SVGPreserveAspectRatio.SVG_MEETORSLICE_MEET");
parsePreserveAspectRatio("xMinYMinslice", "SVGPreserveAspectRatio.SVG_PRESERVEASPECTRATIO_XMINYMIN", "SVGPreserveAspectRatio.SVG_MEETORSLICE_SLICE");
parsePreserveAspectRatio("xMinYMin slice", "SVGPreserveAspectRatio.SVG_PRESERVEASPECTRATIO_XMINYMIN", "SVGPreserveAspectRatio.SVG_MEETORSLICE_SLICE");
parsePreserveAspectRatio("xMinYMinslice ", "SVGPreserveAspectRatio.SVG_PRESERVEASPECTRATIO_XMINYMIN", "SVGPreserveAspectRatio.SVG_MEETORSLICE_SLICE");
parsePreserveAspectRatio("xMinYMin slice ", "SVGPreserveAspectRatio.SVG_PRESERVEASPECTRATIO_XMINYMIN", "SVGPreserveAspectRatio.SVG_MEETORSLICE_SLICE");
parsePreserveAspectRatio(" xMinYMinslice", "SVGPreserveAspectRatio.SVG_PRESERVEASPECTRATIO_XMINYMIN", "SVGPreserveAspectRatio.SVG_MEETORSLICE_SLICE");
parsePreserveAspectRatio(" xMinYMin slice", "SVGPreserveAspectRatio.SVG_PRESERVEASPECTRATIO_XMINYMIN", "SVGPreserveAspectRatio.SVG_MEETORSLICE_SLICE");
parsePreserveAspectRatio(" xMinYMinslice ", "SVGPreserveAspectRatio.SVG_PRESERVEASPECTRATIO_XMINYMIN", "SVGPreserveAspectRatio.SVG_MEETORSLICE_SLICE");
parsePreserveAspectRatio(" xMinYMin slice ", "SVGPreserveAspectRatio.SVG_PRESERVEASPECTRATIO_XMINYMIN", "SVGPreserveAspectRatio.SVG_MEETORSLICE_SLICE");
debug('Tests for bug where "slice" parsing was based on the old value rather than the parsed value.');
debug('');
parsePreserveAspectRatio("none", "SVGPreserveAspectRatio.SVG_PRESERVEASPECTRATIO_NONE", "SVGPreserveAspectRatio.SVG_MEETORSLICE_MEET");
parsePreserveAspectRatio("xMinYMin slice", "SVGPreserveAspectRatio.SVG_PRESERVEASPECTRATIO_XMINYMIN", "SVGPreserveAspectRatio.SVG_MEETORSLICE_SLICE");
parsePreserveAspectRatio("xMinYMin", "SVGPreserveAspectRatio.SVG_PRESERVEASPECTRATIO_XMINYMIN", "SVGPreserveAspectRatio.SVG_MEETORSLICE_MEET");
parsePreserveAspectRatio("none slice", "SVGPreserveAspectRatio.SVG_PRESERVEASPECTRATIO_NONE", "SVGPreserveAspectRatio.SVG_MEETORSLICE_MEET");
parsePreserveAspectRatio("xMinYMin", "SVGPreserveAspectRatio.SVG_PRESERVEASPECTRATIO_XMINYMIN", "SVGPreserveAspectRatio.SVG_MEETORSLICE_MEET");
parsePreserveAspectRatio("slice", "SVGPreserveAspectRatio.SVG_PRESERVEASPECTRATIO_XMIDYMID", "SVGPreserveAspectRatio.SVG_MEETORSLICE_MEET");
debug('Strings that fail to parse, and hence parse as default');
debug('');
parsePreserveAspectRatio("", "SVGPreserveAspectRatio.SVG_PRESERVEASPECTRATIO_XMIDYMID", "SVGPreserveAspectRatio.SVG_MEETORSLICE_MEET");
parsePreserveAspectRatio("defer", "SVGPreserveAspectRatio.SVG_PRESERVEASPECTRATIO_XMIDYMID", "SVGPreserveAspectRatio.SVG_MEETORSLICE_MEET");
parsePreserveAspectRatio("meet", "SVGPreserveAspectRatio.SVG_PRESERVEASPECTRATIO_XMIDYMID", "SVGPreserveAspectRatio.SVG_MEETORSLICE_MEET");
parsePreserveAspectRatio("slice", "SVGPreserveAspectRatio.SVG_PRESERVEASPECTRATIO_XMIDYMID", "SVGPreserveAspectRatio.SVG_MEETORSLICE_MEET");
parsePreserveAspectRatio("xminymin", "SVGPreserveAspectRatio.SVG_PRESERVEASPECTRATIO_XMIDYMID", "SVGPreserveAspectRatio.SVG_MEETORSLICE_MEET");
parsePreserveAspectRatio("refer xMinYMin slice", "SVGPreserveAspectRatio.SVG_PRESERVEASPECTRATIO_XMIDYMID", "SVGPreserveAspectRatio.SVG_MEETORSLICE_MEET");
parsePreserveAspectRatio("xMinYMin defer", "SVGPreserveAspectRatio.SVG_PRESERVEASPECTRATIO_XMIDYMID", "SVGPreserveAspectRatio.SVG_MEETORSLICE_MEET");
parsePreserveAspectRatio("slice xMinYMin", "SVGPreserveAspectRatio.SVG_PRESERVEASPECTRATIO_XMIDYMID", "SVGPreserveAspectRatio.SVG_MEETORSLICE_MEET");
parsePreserveAspectRatio("xMinYMin" + String.fromCharCode(0xa0), "SVGPreserveAspectRatio.SVG_PRESERVEASPECTRATIO_XMIDYMID", "SVGPreserveAspectRatio.SVG_MEETORSLICE_MEET");
</script>
<script src="../../resources/js-test-post.js"></script>
</body>
</html>