|
1 <!DOCTYPE HTML> |
|
2 <html> |
|
3 <head> |
|
4 <title>Reftests with caret drawing</title> |
|
5 <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script> |
|
6 <script type="text/javascript" src="/tests/SimpleTest/EventUtils.js"></script> |
|
7 <script type="text/javascript" src="/tests/SimpleTest/WindowSnapshot.js"></script> |
|
8 <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" /> |
|
9 <style> |
|
10 iframe { |
|
11 width: 600px; |
|
12 height: 600px; |
|
13 } |
|
14 </style> |
|
15 <script type="text/javascript"> |
|
16 |
|
17 SimpleTest.waitForExplicitFinish(); |
|
18 |
|
19 var canvases = []; |
|
20 function callbackTestCanvas(canvas) |
|
21 { |
|
22 canvases.push(canvas); |
|
23 |
|
24 if (canvases.length != 2) |
|
25 return; |
|
26 |
|
27 var result = canvases[0]; |
|
28 var reference = canvases[1]; |
|
29 |
|
30 var ret = compareSnapshots(result.snapshot, reference.snapshot, true); |
|
31 ok(ret[0], "Reftest " + result.src + |
|
32 (ret[0] ? "" : (" FAILED\n" + |
|
33 "RESULT=" + ret[1] + "\n" + |
|
34 "REFERENCE=" + ret[2] + "\n"))); |
|
35 |
|
36 // Remove the iframes if the test was successful |
|
37 if (ret[0]) { |
|
38 result.parentNode.removeChild(result); |
|
39 reference.parentNode.removeChild(reference); |
|
40 } |
|
41 canvases = []; |
|
42 SimpleTest.waitForFocus(nextTest); |
|
43 } |
|
44 |
|
45 function doSnapShot(iframe) { |
|
46 iframe.snapshot = snapshotWindow(iframe.contentWindow, true); |
|
47 callbackTestCanvas(iframe); |
|
48 }; |
|
49 |
|
50 function remotePageLoaded(callback) { |
|
51 var iframe = this; |
|
52 setTimeout(function(){ |
|
53 doSnapShot(iframe); |
|
54 callback(); |
|
55 }, 0); |
|
56 }; |
|
57 |
|
58 const MAX_ITERATIONS = 1000; |
|
59 |
|
60 function createIframe(url,next) { |
|
61 var iframe = document.createElement("iframe"); |
|
62 iframe.src = url; |
|
63 iframe.remotePageLoaded = remotePageLoaded; |
|
64 var me = this; |
|
65 var currentIteration = 0; |
|
66 function iframeLoadCompleted() { |
|
67 var docEl = iframe.contentDocument.documentElement; |
|
68 if (docEl.className.indexOf("reftest-wait") >= 0) { |
|
69 if (currentIteration++ > MAX_ITERATIONS) { |
|
70 ok(false, "iframe load for " + url + " timed out"); |
|
71 endTest(); |
|
72 } else { |
|
73 setTimeout(iframeLoadCompleted, 10); |
|
74 } |
|
75 return; |
|
76 } |
|
77 iframe.remotePageLoaded(function() { |
|
78 if (next) { |
|
79 setTimeout(function(){createIframe(next,null);}, 0) |
|
80 } |
|
81 }); |
|
82 } |
|
83 iframe.addEventListener("load", iframeLoadCompleted, false); |
|
84 window.document.body.appendChild(iframe); |
|
85 iframe.focus(); |
|
86 }; |
|
87 |
|
88 function refTest(test,ref) { |
|
89 createIframe(test,ref); |
|
90 }; |
|
91 |
|
92 var caretBlinkTime = null; |
|
93 function endTest() { |
|
94 if (caretBlinkTime !== null) { |
|
95 SpecialPowers.setIntPref("ui.caretBlinkTime", caretBlinkTime); |
|
96 } else { |
|
97 SpecialPowers.clearUserPref("ui.caretBlinkTime"); |
|
98 } |
|
99 |
|
100 // finish(), yet let the test actually end first, to be safe. |
|
101 SimpleTest.executeSoon(SimpleTest.finish); |
|
102 } |
|
103 |
|
104 var tests = [ |
|
105 [ 'bug106855-1.html' , 'bug106855-1-ref.html' ] , |
|
106 [ 'bug106855-2.html' , 'bug106855-1-ref.html' ] , |
|
107 [ 'bug240933-1.html' , 'bug240933-1-ref.html' ] , |
|
108 [ 'bug240933-2.html' , 'bug240933-1-ref.html' ] , |
|
109 [ 'bug389321-1.html' , 'bug389321-1-ref.html' ] , |
|
110 [ 'bug389321-2.html' , 'bug389321-2-ref.html' ] , |
|
111 [ 'bug389321-3.html' , 'bug389321-3-ref.html' ] , |
|
112 [ 'bug482484.html' , 'bug482484-ref.html' ] , |
|
113 [ 'bug585922.html' , 'bug585922-ref.html' ] , |
|
114 [ 'bug597519-1.html' , 'bug597519-1-ref.html' ] , |
|
115 [ 'bug602141-1.html' , 'bug602141-1-ref.html' ] , |
|
116 [ 'bug602141-2.html' , 'bug602141-2-ref.html' ] , |
|
117 [ 'bug602141-3.html' , 'bug602141-3-ref.html' ] , |
|
118 [ 'bug602141-4.html' , 'bug602141-4-ref.html' ] , |
|
119 [ 'bug612271-1.html' , 'bug612271-ref.html' ] , |
|
120 [ 'bug612271-2.html' , 'bug612271-ref.html' ] , |
|
121 [ 'bug612271-3.html' , 'bug612271-ref.html' ] , |
|
122 [ 'bug613433-1.html' , 'bug613433-ref.html' ] , |
|
123 [ 'bug613433-2.html' , 'bug613433-ref.html' ] , |
|
124 [ 'bug613433-3.html' , 'bug613433-ref.html' ] , |
|
125 [ 'bug613807-1.html' , 'bug613807-1-ref.html' ] , |
|
126 [ 'bug632215-1.html' , 'bug632215-ref.html' ] , |
|
127 [ 'bug632215-2.html' , 'bug632215-ref.html' ] , |
|
128 [ 'bug633044-1.html' , 'bug633044-1-ref.html' ] , |
|
129 [ 'bug634406-1.html' , 'bug634406-1-ref.html' ] , |
|
130 [ 'bug644428-1.html' , 'bug644428-1-ref.html' ] , |
|
131 function() {SpecialPowers.setBoolPref("bidi.browser.ui", true);} , |
|
132 [ 'bug646382-1.html' , 'bug646382-1-ref.html' ] , |
|
133 [ 'bug646382-2.html' , 'bug646382-2-ref.html' ] , |
|
134 [ 'bug664087-1.html' , 'bug664087-1-ref.html' ] , |
|
135 [ 'bug664087-2.html' , 'bug664087-2-ref.html' ] , |
|
136 [ 'bug682712-1.html' , 'bug682712-1-ref.html' ] , |
|
137 function() {SpecialPowers.clearUserPref("bidi.browser.ui");} , |
|
138 [ 'bug746993-1.html' , 'bug746993-1-ref.html' ] , |
|
139 [ 'bug1007065-1.html' , 'bug1007065-1-ref.html' ] , |
|
140 ]; |
|
141 |
|
142 if (navigator.appVersion.indexOf("Android") == -1 && |
|
143 SpecialPowers.Services.appinfo.name != "B2G") { |
|
144 tests.push([ 'bug512295-1.html' , 'bug512295-1-ref.html' ]); |
|
145 tests.push([ 'bug512295-2.html' , 'bug512295-2-ref.html' ]); |
|
146 tests.push(function() {SpecialPowers.setBoolPref("layout.css.overflow-clip-box.enabled", true);}); |
|
147 tests.push([ 'bug966992-1.html' , 'bug966992-1-ref.html' ]); |
|
148 tests.push([ 'bug966992-2.html' , 'bug966992-2-ref.html' ]); |
|
149 tests.push([ 'bug966992-3.html' , 'bug966992-3-ref.html' ]); |
|
150 tests.push(function() {SpecialPowers.setBoolPref("layout.css.overflow-clip-box.enabled", false);}); |
|
151 tests.push([ 'bug923376.html' , 'bug923376-ref.html' ]); |
|
152 } else { |
|
153 is(SpecialPowers.getIntPref("layout.spellcheckDefault"), 0, "Spellcheck should be turned off for this platrom or this if..else check removed"); |
|
154 } |
|
155 |
|
156 var testIndex = 0; |
|
157 |
|
158 function nextTest() { |
|
159 if (testIndex < tests.length) { |
|
160 if (typeof(tests[testIndex]) == 'function') { |
|
161 tests[testIndex](); |
|
162 SimpleTest.executeSoon(nextTest); |
|
163 } else { |
|
164 refTest(tests[testIndex][0],tests[testIndex][1]); |
|
165 } |
|
166 ++testIndex; |
|
167 } else { |
|
168 endTest(); |
|
169 } |
|
170 } |
|
171 function runTests() { |
|
172 try { |
|
173 try { |
|
174 caretBlinkTime = SpecialPowers.getIntPref("ui.caretBlinkTime"); |
|
175 } catch (e) {} |
|
176 SpecialPowers.setIntPref("ui.caretBlinkTime", -1); |
|
177 |
|
178 nextTest(); |
|
179 } catch(e) { |
|
180 endTest(); |
|
181 } |
|
182 } |
|
183 |
|
184 SimpleTest.waitForFocus(runTests); |
|
185 |
|
186 </script> |
|
187 </head> |
|
188 <body> |
|
189 </body> |
|
190 </html> |