Sat, 03 Jan 2015 20:18:00 +0100
Conditionally enable double key logic according to:
private browsing mode or privacy.thirdparty.isolate preference and
implement in GetCookieStringCommon and FindCookie where it counts...
With some reservations of how to convince FindCookie users to test
condition and pass a nullptr when disabling double key logic.
1 <html xmlns="http://www.w3.org/1999/xhtml">
2 <!--
3 https://bugzilla.mozilla.org/show_bug.cgi?id=436418
4 -->
5 <head>
6 <title>Test for animateMotion acceptance of invalid values</title>
7 <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
8 <script type="text/javascript" src="smilTestUtils.js" />
9 <script type="text/javascript" src="smilAnimateMotionValueLists.js" />
10 <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
11 </head>
12 <body>
13 <a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=436418">Mozilla Bug 436418</a>
14 <p id="display"></p>
15 <div id="content" style="visibility: hidden">
16 <svg xmlns="http://www.w3.org/2000/svg" id="svg"
17 width="200px" height="200px"
18 onload="this.pauseAnimations()">
19 <rect id="rect" x="20" y="20" width="200" height="200"/>
20 </svg>
21 </div>
22 <pre id="test">
23 <script class="testbody" type="text/javascript">
24 <![CDATA[
26 // Constant strings (& string-arrays)
27 const SVGNS = "http://www.w3.org/2000/svg";
28 const XLINKNS = "http://www.w3.org/1999/xlink";
30 // Constant objects
31 const gSvg = document.getElementById("svg");
32 const gRect = document.getElementById("rect");
33 const gUnAnimatedCTM = gRect.getCTM();
35 SimpleTest.waitForExplicitFinish();
37 function createAnim()
38 {
39 var anim = document.createElementNS(SVGNS, "animateMotion");
40 anim.setAttribute("dur", "2s");
41 return gRect.appendChild(anim);
42 }
44 function removeElem(aElem)
45 {
46 aElem.parentNode.removeChild(aElem);
47 }
49 function testAttr(aAttrName, aAttrValueArray, aIsValid)
50 {
51 var componentsToCheck;
53 for (var i in aAttrValueArray) {
54 var curVal = aAttrValueArray[i];
55 var anim = createAnim();
56 anim.setAttribute(aAttrName, curVal);
57 if (aAttrName == "rotate") {
58 // Apply a diagonal translation (so rotate='auto' will have an effect)
59 // and just test the rotation matrix components
60 anim.setAttribute("values", "0 0; 50 50");
61 componentsToCheck = CTMUtil.CTM_COMPONENTS_ROTATE;
62 } else {
63 // Apply a supplementary rotation to make sure that we don't apply it if
64 // our value is rejected.
65 anim.setAttribute("rotate", Math.PI/4);
66 componentsToCheck = CTMUtil.CTM_COMPONENTS_ALL;
67 if (aAttrName == "keyPoints") {
68 // Add three times so we can test a greater range of values for
69 // keyPoints
70 anim.setAttribute("values", "0 0; 25 25; 50 50");
71 anim.setAttribute("keyTimes", "0; 0.5; 1");
72 anim.setAttribute("calcMode", "discrete");
73 }
74 }
76 var curCTM = gRect.getCTM();
77 if (aIsValid) {
78 var errMsg = "CTM should have changed when applying animateMotion " +
79 "with '" + aAttrName + "' set to valid value '" + curVal + "'";
80 CTMUtil.assertCTMNotEqual(curCTM, gUnAnimatedCTM, componentsToCheck,
81 errMsg, false);
82 } else {
83 var errMsg = "CTM should not have changed when applying animateMotion " +
84 "with '" + aAttrName + "' set to invalid value '" + curVal + "'";
85 CTMUtil.assertCTMEqual(curCTM, gUnAnimatedCTM, componentsToCheck,
86 errMsg, false);
87 }
88 removeElem(anim);
89 }
90 }
92 function createPath(aPathDescription)
93 {
94 var path = document.createElementNS(SVGNS, "path");
95 path.setAttribute("d", aPathDescription);
96 path.setAttribute("id", "thePath");
97 return gSvg.appendChild(path);
98 }
100 function createMpath(aAnimElement)
101 {
102 var mpath = document.createElementNS(SVGNS, "mpath");
103 mpath.setAttributeNS(XLINKNS, "href", "#thePath");
104 return aAnimElement.appendChild(mpath);
105 }
107 function testMpathElem(aPathValueArray, aIsValid)
108 {
109 for (var i in aPathValueArray) {
110 var curVal = aPathValueArray[i];
111 var anim = createAnim();
112 var mpath = createMpath(anim);
113 var path = createPath(curVal);
115 // Apply a supplementary rotation to make sure that we don't apply it if
116 // our value is rejected.
117 anim.setAttribute("rotate", Math.PI/4);
118 componentsToCheck = CTMUtil.CTM_COMPONENTS_ALL;
120 if (aIsValid) {
121 var errMsg = "CTM should have changed when applying animateMotion " +
122 "with mpath linking to a path with valid value '" + curVal + "'";
124 CTMUtil.assertCTMNotEqual(gRect.getCTM(), gUnAnimatedCTM,
125 componentsToCheck, errMsg, false);
126 } else {
127 var errMsg = "CTM should not have changed when applying animateMotion " +
128 "with mpath linking to a path with invalid value '" + curVal + "'";
129 CTMUtil.assertCTMEqual(gRect.getCTM(), gUnAnimatedCTM,
130 componentsToCheck, errMsg, false);
131 }
132 removeElem(anim);
133 removeElem(path);
134 removeElem(mpath);
135 }
136 }
138 // Main Function
139 function main()
140 {
141 // Start out with document paused
142 var svg = SMILUtil.getSVGRoot();
143 ok(svg.animationsPaused(), "should be paused by <svg> load handler");
144 is(svg.getCurrentTime(), 0, "should be paused at 0 in <svg> load handler");
146 testAttr("values", gValidValues, true);
147 testAttr("values", gInvalidValues, false);
149 testAttr("rotate", gValidRotate, true);
150 testAttr("rotate", gInvalidRotate, false);
152 testAttr("to", gValidToBy, true);
153 testAttr("to", gInvalidToBy, false);
155 testAttr("by", gValidToBy, true);
156 testAttr("by", gInvalidToBy, false);
158 testAttr("path", gValidPath, true);
159 testAttr("path", gInvalidPath, false);
160 testAttr("path", gValidPathWithErrors, true);
162 testAttr("keyPoints", gValidKeyPoints, true);
163 testAttr("keyPoints", gInvalidKeyPoints, false);
165 testMpathElem(gValidPath, true);
166 testMpathElem(gInvalidPath, false);
168 SimpleTest.finish();
169 }
171 window.addEventListener("load", main, false);
172 ]]>
173 </script>
174 </pre>
175 </body>
176 </html>