Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(5)

Side by Side Diff: third_party/WebKit/LayoutTests/svg/dom/transform-parser.html

Issue 2646503002: Split svg/dom/transform-parser.html (Closed)
Patch Set: Created 3 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 <html> 1 <!DOCTYPE html>
2 <head> 2 <title>Transform parser fuzzer (matrix, rotate, scale)</title>
3 <script src="../../resources/js-test.js"></script>
4 <script src="resources/scripted-random.js"></script> 3 <script src="resources/scripted-random.js"></script>
5 </head> 4 <script src="resources/transform-parser-fuzzer.js"></script>
6 <body>
7 <p id="description"></p>
8 <div id="console"></div>
9 <script> 5 <script>
10 description("This test fuzzes the transform parser with semi-random attribut e values and dumps the results of any values that parse successfully."); 6 fuzzTransforms({ matrix: 6, rotate: 1, scale: 1 });
11
12 var transforms = { // maps a transform name to its minimum argument count
13 matrix: 6,
14 rotate: 1,
15 scale: 1,
16 skewX: 1,
17 skewY: 1,
18 translate: 1
19 };
20
21 var characters = [
22 "0",
23 "1",
24 "2",
25 "3",
26 "4",
27 "5",
28 "6",
29 "7",
30 "8",
31 "9",
32 ".",
33 "e",
34 "+",
35 "-",
36 "e",
37 "(",
38 ")",
39 " ",
40 "\t",
41 ","
42 ];
43
44 var gElement = document.createElementNS("http://www.w3.org/2000/svg", "g");
45 function parseTransform(string)
46 {
47 gElement.setAttributeNS(null, "transform", string);
48
49 var transformList = gElement.transform.baseVal;
50 if (!transformList.numberOfItems)
51 return;
52
53 debug("Parsed as " + transformList.numberOfItems + " transform(s): " + s tring);
54 }
55
56 function fuzz()
57 {
58 for (var transform in transforms) {
59
60 // Too few / too many arguments
61 for (var i = 0; i < 50; i++) { //>
62 var transformString = transform + "(";
63 for (var j = 0; j < i; j++) { //>
64 transformString += "0";
65 if (j < i - 1) //>
66 transformString += ",";
67 }
68 transformString += ")";
69 parseTransform(transformString);
70 }
71
72 // Random assortments of valid characters
73 for (var i = 0; i < 100; i++) { //>
74 var transformString = transform + "(";
75 var count = Math.scriptedRandomInt(20);
76 for (var j = 0; j < count; j++) { //>
77 transformString += characters[Math.scriptedRandomInt(charact ers.length)];
78 }
79 parseTransform(transformString);
80 }
81
82 // Transform names that are "off by one"
83 var extraChar = transform.charAt(transform.length - 1);
84 parseTransform(transform + extraChar + "(0, 0)");
85 parseTransform(transform.substring(0, transform.length - 1) + "(0, 0 )");
86
87 // Empty-ish transforms
88 parseTransform(transform);
89 parseTransform(transform + String.fromCharCode(0));
90 parseTransform(transform + "(" + String.fromCharCode(0) + ")");
91 }
92 }
93
94 fuzz();
95
96 </script> 7 </script>
97 </html> 8 <p>DONE</p>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698