1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258
|
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<!--
https://bugzilla.mozilla.org/show_bug.cgi?id=629200
-->
<head>
<title>Test for Bug 629200</title>
<script src="/tests/SimpleTest/SimpleTest.js"></script>
<script type="application/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"></div>
<iframe id="svg" src="dataTypes-helper.svg"></iframe>
<pre id="test">
<script class="testbody" type="application/javascript">
SimpleTest.waitForExplicitFinish();
function runTests() {
var doc = $("svg").contentWindow.document;
var filter = doc.getElementById("filter");
var convolve = doc.getElementById("convolve");
var blur = doc.getElementById("blur");
var marker = doc.getElementById("marker");
var eventChecker = new MutationEventChecker;
// class attribute
eventChecker.watchAttr(filter, "class");
eventChecker.expect("add modify remove add");
filter.setAttribute("class", "foo");
filter.className.baseVal = "bar";
filter.removeAttribute("class");
filter.removeAttributeNS(null, "class");
filter.className.baseVal = "foo";
eventChecker.expect("");
filter.className.baseVal = "foo";
filter.setAttribute("class", "foo");
// length attribute
eventChecker.watchAttr(marker, "markerWidth");
eventChecker.expect("add modify modify modify modify modify remove add");
marker.setAttribute("markerWidth", "12.5");
marker.markerWidth.baseVal.value = 8;
marker.markerWidth.baseVal.valueInSpecifiedUnits = 9;
marker.markerWidth.baseVal.valueAsString = "10";
marker.markerWidth.baseVal.convertToSpecifiedUnits(
SVGLength.SVG_LENGTHTYPE_CM);
marker.markerWidth.baseVal.newValueSpecifiedUnits(
SVGLength.SVG_LENGTHTYPE_MM, 11);
marker.removeAttribute("markerWidth");
marker.removeAttributeNS(null, "markerWidth");
marker.markerWidth.baseVal.value = 8;
eventChecker.expect("remove add modify");
marker.removeAttribute("markerWidth");
console.log(marker.getAttribute("markerWidth"));
marker.markerWidth.baseVal.convertToSpecifiedUnits(
SVGLength.SVG_LENGTHTYPE_NUMBER);
console.log(marker.getAttribute("markerWidth"));
marker.markerWidth.baseVal.value = 8;
eventChecker.expect("");
marker.markerWidth.baseVal.value = 8;
marker.setAttribute("markerWidth", "8");
marker.markerWidth.baseVal.value = 8;
marker.markerWidth.baseVal.valueAsString = "8";
marker.markerWidth.baseVal.convertToSpecifiedUnits(
SVGLength.SVG_LENGTHTYPE_NUMBER);
marker.markerWidth.baseVal.newValueSpecifiedUnits(
SVGLength.SVG_LENGTHTYPE_NUMBER, 8);
// number attribute
eventChecker.watchAttr(convolve, "divisor");
eventChecker.expect("add modify remove add");
convolve.setAttribute("divisor", "12.5");
convolve.divisor.baseVal = 6;
convolve.removeAttribute("divisor");
convolve.removeAttributeNS(null, "divisor");
convolve.divisor.baseVal = 8;
eventChecker.expect("");
convolve.divisor.baseVal = 8;
convolve.setAttribute("divisor", "8");
// number-optional-number attribute
eventChecker.watchAttr(blur, "stdDeviation");
eventChecker.expect("add modify remove add");
blur.setAttribute("stdDeviation", "5, 6");
blur.stdDeviationX.baseVal = 8;
blur.removeAttribute("stdDeviation");
blur.removeAttributeNS(null, "stdDeviation");
blur.setAttribute("stdDeviation", "2, 3");
eventChecker.expect("");
blur.stdDeviationX.baseVal = 2;
blur.stdDeviationY.baseVal = 3;
blur.setAttribute("stdDeviation", "2, 3");
// integer attribute
eventChecker.watchAttr(convolve, "targetX");
eventChecker.expect("add modify remove add");
convolve.setAttribute("targetX", "12");
convolve.targetX.baseVal = 6;
convolve.removeAttribute("targetX");
convolve.removeAttributeNS(null, "targetX");
convolve.targetX.baseVal = 8;
// Check redundant change when comparing typed value to attribute value
eventChecker.expect("");
convolve.setAttribute("targetX", "8");
// Check redundant change when comparing attribute value to typed value
eventChecker.expect("remove add");
convolve.removeAttribute("targetX");
convolve.setAttribute("targetX", "8");
convolve.targetX.baseVal = 8;
// integer-optional-integer attribute
eventChecker.watchAttr(convolve, "order");
eventChecker.expect("add modify remove add");
convolve.setAttribute("order", "5, 7");
convolve.orderX.baseVal = 9;
convolve.removeAttribute("order");
convolve.removeAttributeNS(null, "order");
convolve.setAttribute("order", "9, 5");
eventChecker.expect("");
convolve.orderX.baseVal = 9;
convolve.setAttribute("order", "9, 5");
convolve.orderY.baseVal = 5;
// angle attribute
eventChecker.watchAttr(marker, "orient");
eventChecker.expect("add modify modify modify modify modify remove add");
marker.setAttribute("orient", "90deg");
marker.orientAngle.baseVal.value = 12;
marker.orientAngle.baseVal.valueInSpecifiedUnits = 23;
marker.orientAngle.baseVal.valueAsString = "34";
marker.orientAngle.baseVal.newValueSpecifiedUnits(
SVGAngle.SVG_ANGLETYPE_GRAD, 34);
marker.orientAngle.baseVal.newValueSpecifiedUnits(
SVGAngle.SVG_ANGLETYPE_GRAD, 45);
marker.removeAttribute("orient");
marker.removeAttributeNS(null, "orient");
marker.orientAngle.baseVal.value = 40;
eventChecker.expect("");
marker.orientAngle.baseVal.value = 40;
marker.orientAngle.baseVal.valueInSpecifiedUnits = 40;
marker.orientAngle.baseVal.valueAsString = "40";
marker.orientAngle.baseVal.convertToSpecifiedUnits(
SVGAngle.SVG_ANGLETYPE_UNSPECIFIED);
marker.orientAngle.baseVal.newValueSpecifiedUnits(
SVGAngle.SVG_ANGLETYPE_UNSPECIFIED, 40);
// boolean attribute
eventChecker.watchAttr(convolve, "preserveAlpha");
eventChecker.expect("add modify remove add");
convolve.setAttribute("preserveAlpha", "true");
convolve.preserveAlpha.baseVal = false;
convolve.removeAttribute("preserveAlpha");
convolve.removeAttributeNS(null, "preserveAlpha");
convolve.preserveAlpha.baseVal = true;
eventChecker.expect("");
convolve.preserveAlpha.baseVal = true;
convolve.setAttribute("preserveAlpha", "true");
// enum attribute
eventChecker.watchAttr(convolve, "edgeMode");
eventChecker.expect("add modify remove add");
convolve.setAttribute("edgeMode", "none");
convolve.edgeMode.baseVal = SVGFEConvolveMatrixElement.SVG_EDGEMODE_WRAP;
convolve.removeAttribute("edgeMode");
convolve.removeAttributeNS(null, "edgeMode");
convolve.edgeMode.baseVal = SVGFEConvolveMatrixElement.SVG_EDGEMODE_NONE;
eventChecker.expect("");
convolve.edgeMode.baseVal = SVGFEConvolveMatrixElement.SVG_EDGEMODE_NONE;
convolve.setAttribute("edgeMode", "none");
convolve.edgeMode.baseVal = SVGFEConvolveMatrixElement.SVG_EDGEMODE_NONE;
// string attribute
eventChecker.watchAttr(convolve, "result");
eventChecker.expect("add modify remove add");
convolve.setAttribute("result", "bar");
convolve.result.baseVal = "foo";
convolve.removeAttribute("result");
convolve.removeAttributeNS(null, "result");
convolve.result.baseVal = "bar";
eventChecker.expect("");
convolve.result.baseVal = "bar";
convolve.setAttribute("result", "bar");
convolve.result.baseVal = "bar";
// preserveAspectRatio attribute
eventChecker.watchAttr(marker, "preserveAspectRatio");
eventChecker.expect("add modify remove add");
marker.setAttribute("preserveAspectRatio", "xMaxYMid slice");
marker.preserveAspectRatio.baseVal.align =
SVGPreserveAspectRatio.SVG_PRESERVEASPECTRATIO_XMAXYMAX;
marker.removeAttribute("preserveAspectRatio");
marker.removeAttributeNS(null, "preserveAspectRatio");
marker.preserveAspectRatio.baseVal.align =
SVGPreserveAspectRatio.SVG_PRESERVEASPECTRATIO_XMIDYMIN;
eventChecker.expect("");
marker.preserveAspectRatio.baseVal.meetOrSlice =
SVGPreserveAspectRatio.SVG_MEETORSLICE_MEET;
marker.setAttribute("preserveAspectRatio", "xMidYMin meet");
// viewBox attribute
eventChecker.watchAttr(marker, "viewBox");
eventChecker.expect("add modify remove add");
marker.setAttribute("viewBox", "1 2 3 4");
marker.viewBox.baseVal.height = 5;
marker.removeAttribute("viewBox");
marker.removeAttributeNS(null, "viewBox");
marker.setAttribute("viewBox", "none");
marker.setAttribute("viewBox", "none");
eventChecker.ignoreEvents();
marker.setAttribute("viewBox", "1 2 3 4");
eventChecker.expect("");
marker.viewBox.baseVal.height = 4;
marker.viewBox.baseVal.x = 1;
marker.setAttribute("viewBox", "1 2 3 4");
eventChecker.finish();
SimpleTest.finish();
}
window.addEventListener("load", () =>
SpecialPowers.pushPrefEnv({"set": [["dom.mutation_events.enabled", true]]}, runTests));
</script>
</pre>
</body>
</html>
|