2012-02-15 23:40:46 +00:00
|
|
|
<html xmlns="http://www.w3.org/1999/xhtml">
|
|
|
|
<!--
|
|
|
|
https://bugzilla.mozilla.org/show_bug.cgi?id=629200
|
|
|
|
-->
|
|
|
|
<head>
|
|
|
|
<title>Tests specific to SVGPointList</title>
|
|
|
|
<script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
|
|
|
|
<script type="text/javascript" src="MutationEventChecker.js"></script>
|
|
|
|
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
|
|
|
|
</head>
|
|
|
|
<body>
|
|
|
|
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=629200">Mozilla Bug 629200</a>
|
|
|
|
<p id="display"></p>
|
|
|
|
<div id="content" style="display:none;">
|
|
|
|
<svg id="svg" xmlns="http://www.w3.org/2000/svg" width="100" height="100">
|
|
|
|
<polyline id="polyline" points="50,375 150,380"/>
|
2014-08-06 13:58:57 +00:00
|
|
|
<polyline id="polyline2" points="10,20"/>
|
2012-02-15 23:40:46 +00:00
|
|
|
</svg>
|
|
|
|
</div>
|
|
|
|
<pre id="test">
|
|
|
|
<script class="testbody" type="text/javascript">
|
|
|
|
<![CDATA[
|
|
|
|
|
|
|
|
SimpleTest.waitForExplicitFinish();
|
|
|
|
|
|
|
|
/*
|
|
|
|
This file runs a series of SVGPointList specific tests. Generic SVGXxxList
|
|
|
|
tests can be found in test_SVGxxxList.xhtml. Anything that can be generalized
|
|
|
|
to other list types belongs there.
|
|
|
|
*/
|
|
|
|
|
|
|
|
function run_tests()
|
|
|
|
{
|
|
|
|
document.getElementById('svg').pauseAnimations();
|
|
|
|
|
|
|
|
var polyline = document.getElementById("polyline");
|
|
|
|
var points = polyline.points;
|
|
|
|
|
|
|
|
is(points.numberOfItems, 2, 'Checking numberOfItems');
|
|
|
|
|
|
|
|
// Test mutation events
|
|
|
|
// --- Initialization
|
|
|
|
eventChecker = new MutationEventChecker;
|
|
|
|
eventChecker.watchAttr(polyline, "points");
|
|
|
|
// -- Actual changes
|
|
|
|
eventChecker.expect("modify modify");
|
|
|
|
points[0].x = 40;
|
|
|
|
polyline.setAttribute("points", "30,375 150,380");
|
|
|
|
// -- Redundant changes
|
|
|
|
eventChecker.expect("");
|
|
|
|
points[0].x = 30;
|
|
|
|
points[1].y = 380;
|
|
|
|
polyline.setAttribute("points", "30,375 150,380");
|
2012-07-30 09:02:50 +00:00
|
|
|
// -- Invalid attribute
|
|
|
|
eventChecker.expect("modify");
|
|
|
|
polyline.setAttribute("points", ",30,375");
|
|
|
|
is(points.numberOfItems, 0, 'Checking that parsing stops at invalid token');
|
2012-03-04 23:38:03 +00:00
|
|
|
// -- Attribute removal
|
|
|
|
eventChecker.expect("remove");
|
|
|
|
polyline.removeAttribute("points");
|
|
|
|
// -- Non-existent attribute removal
|
|
|
|
eventChecker.expect("");
|
|
|
|
polyline.removeAttribute("points");
|
|
|
|
polyline.removeAttributeNS(null, "points");
|
2012-02-15 23:40:46 +00:00
|
|
|
eventChecker.finish();
|
|
|
|
|
2014-08-06 13:58:57 +00:00
|
|
|
// Test that the addition of an owned SVGPoint to an SVGPointList creates a
|
|
|
|
// copy of the SVGPoint
|
|
|
|
var polyline2 = document.getElementById("polyline2");
|
|
|
|
var subtests = [
|
|
|
|
function initialize(aItem) {
|
|
|
|
polyline.removeAttribute("points");
|
|
|
|
return points.initialize(aItem);
|
|
|
|
},
|
|
|
|
function insertItemBefore(aItem) {
|
|
|
|
polyline.removeAttribute("points");
|
|
|
|
return points.insertItemBefore(aItem, 0);
|
|
|
|
},
|
|
|
|
function replaceItem(aItem) {
|
|
|
|
polyline.setAttribute("points", "10,20");
|
|
|
|
return points.replaceItem(aItem, 0);
|
|
|
|
},
|
|
|
|
function appendItem(aItem) {
|
|
|
|
polyline.removeAttribute("points");
|
|
|
|
return points.appendItem(aItem);
|
|
|
|
}
|
|
|
|
];
|
|
|
|
subtests.forEach(function(aFunction) {
|
|
|
|
// -- Adding SVGSVGElement.currentTranslate, which is the only instance
|
|
|
|
// of an owned, single SVGPoint
|
|
|
|
var svg = document.getElementById("svg");
|
|
|
|
var name = aFunction.name;
|
|
|
|
var existingItem = svg.currentTranslate;
|
|
|
|
var newItem = aFunction(existingItem);
|
|
|
|
is(newItem, points.getItem(0), name + " return value is correct when passed currentTranslate");
|
|
|
|
isnot(newItem, existingItem, name + " made a copy when passed currentTranslate");
|
|
|
|
is(newItem.value, existingItem.value, name + " made a copy with the right values when passed currentTranslate");
|
|
|
|
todo(svg.currentTranslate == existingItem, name + " left the original object alone when passed currentTranslate");
|
|
|
|
});
|
|
|
|
subtests.forEach(function(aFunction) {
|
|
|
|
// -- Adding an SVGPoint that is in a baseVal list
|
|
|
|
var name = aFunction.name;
|
|
|
|
var existingItem = polyline2.points.getItem(0);
|
|
|
|
var newItem = aFunction(existingItem);
|
|
|
|
is(newItem, points.getItem(0), name + " return value is correct when passed a baseVal list item");
|
|
|
|
isnot(newItem, existingItem, name + " made a copy when passed a baseVal list item");
|
|
|
|
is(newItem.value, existingItem.value, name + " made a copy with the right values when passed a baseVal list item");
|
|
|
|
is(polyline2.points.getItem(0), existingItem, name + " left the original object alone when passed a baseVal list item");
|
|
|
|
});
|
|
|
|
subtests.forEach(function(aFunction) {
|
|
|
|
// -- Adding an SVGPoint that is in a animVal list
|
|
|
|
var name = aFunction.name;
|
|
|
|
var existingItem = polyline2.animatedPoints.getItem(0);
|
|
|
|
var newItem = aFunction(existingItem);
|
|
|
|
is(newItem, points.getItem(0), name + " return value is correct when passed a animVal list item");
|
|
|
|
isnot(newItem, existingItem, name + " made a copy when passed a animVal list item");
|
|
|
|
is(newItem.value, existingItem.value, name + " made a copy with the right values when passed a animVal list item");
|
|
|
|
is(polyline2.animatedPoints.getItem(0), existingItem, name + " left the original object alone when passed a animVal list item");
|
|
|
|
});
|
|
|
|
|
2012-02-15 23:40:46 +00:00
|
|
|
SimpleTest.finish();
|
|
|
|
}
|
|
|
|
|
|
|
|
window.addEventListener("load", run_tests, false);
|
|
|
|
|
|
|
|
]]>
|
|
|
|
</script>
|
|
|
|
</pre>
|
|
|
|
</body>
|
|
|
|
</html>
|