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

Side by Side Diff: LayoutTests/svg/dom/resources/viewspec-parser.js

Issue 17143003: Rewrite SVG viewspec tests to not be fuzzer tests. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Update for landing Created 7 years, 6 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 | Annotate | Revision Log
OLDNEW
(Empty)
1 description("This test fuzzes the transform parser with semi-random attribute va lues and dumps the results of any values that parse successfully.");
2
3 var testsToRun;
4
5 var preserveAspectRatioValues = [ "Min", "Max", "Mid" ];
6
7 var characters = [
8 "0",
9 "1",
10 "2",
11 "3",
12 "4",
13 "5",
14 "6",
15 "7",
16 "8",
17 "9",
18 ".",
19 "e",
20 "+",
21 "-",
22 "e",
23 "(",
24 ")",
25 " ", // not a valid fragment char
26 "\t", // not a valid fragment char
27 ","
28 ];
29
30 function zoomAndPanToString(zoomAndPan)
31 {
32 if (zoomAndPan == SVGZoomAndPan.SVG_ZOOMANDPAN_MAGNIFY)
33 return "magnify";
34 if (zoomAndPan == SVGZoomAndPan.SVG_ZOOMANDPAN_DISABLE)
35 return "disable";
36 return "unknown";
37 }
38
39 function viewSpecToString(viewSpec)
40 {
41 if (!viewSpec)
42 return undefined;
43
44 var attributes = [];
45 if (viewSpec.transformString)
46 attributes.push("transform(" + viewSpec.transformString + ")");
47 if (viewSpec.viewBoxString && viewSpec.viewBoxString != "0 0 0 0")
48 attributes.push("viewBox(" + viewSpec.viewBoxString + ")");
49 if (viewSpec.preserveAspectRatioString && viewSpec.preserveAspectRatioString != "xMidYMid meet")
50 attributes.push("preserveAspectRatio(" + viewSpec.preserveAspectRatioStr ing + ")");
51 if (viewSpec.zoomAndPan && viewSpec.zoomAndPan != SVGZoomAndPan.SVG_ZOOMANDP AN_MAGNIFY)
52 attributes.push("zoomAndPan(" + zoomAndPanToString(viewSpec.zoomAndPan) + ")");
53 if (viewSpec.viewTargetString)
54 attributes.push("viewTarget(" + viewSpec.viewTargetString + ")");
55 if (!attributes.length)
56 return "[initial view]";
57 return "svgView(" + attributes.join(";") + ")";
58 }
59
60 var testNumber = 0;
61 var testString = "[initial view]"
62
63 function makeURLRelative(url)
64 {
65 return url.slice(url.indexOf("resources"));
66 }
67
68 function testFragment(string)
69 {
70 var oldEmbed = document.getElementById("object");
71 if (oldEmbed)
72 oldEmbed.parentNode.removeChild(oldEmbed);
73 var embedElement = document.createElement("iframe");
74 embedElement.setAttribute("id", "object");
75 embedElement.setAttribute("width", "100");
76 embedElement.setAttribute("height", "100");
77 embedElement.setAttribute("onload", "setTimeout('continueFuzzing(event)', 0) ");
78 var newURL = "resources/viewspec-target.svg#" + string;
79 embedElement.src = newURL;
80 document.body.appendChild(embedElement);
81 }
82
83 function startNextTest()
84 {
85 testFragment(testString);
86 }
87
88 function continueFuzzing(event)
89 {
90 var embedElement = document.getElementById("object");
91 if (embedElement.contentDocument) {
92 debug("Loaded: " + makeURLRelative(embedElement.contentDocument.URL));
93 debug("Parsed: " + viewSpecToString(embedElement.contentDocument.documen tElement.currentView) + " from: " + testString + "\n");
94 } else
95 debug("no svgdocument");
96
97 if (testNumber < testsToRun.length)
98 testString = testsToRun[testNumber];
99 else {
100 var script = document.createElement("script");
101
102 script.onload = function() {
103 if (window.testRunner)
104 testRunner.notifyDone();
105 };
106
107 script.src = "../../fast/js/resources/js-test-post.js";
108 document.body.appendChild(script);
109 return;
110 }
111 testNumber++;
112
113 // this lets us out of the onload handler so we don't overrun the stack
114 window.setTimeout(startNextTest, 0);
115 }
116
117 function startViewspecTests(tests)
118 {
119 testsToRun = tests;
120 testFragment("");
121 }
OLDNEW
« no previous file with comments | « LayoutTests/svg/dom/resources/viewspec-aspectparams.svg ('k') | LayoutTests/svg/dom/resources/viewspec-transformparams.svg » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698