1717import java .net .URL ;
1818import java .text .SimpleDateFormat ;
1919import java .util .ArrayList ;
20+ import java .util .Arrays ;
2021import java .util .Date ;
2122import java .util .List ;
2223import java .util .Map ;
@@ -121,7 +122,7 @@ public void isDisplayed() throws Exception {
121122 * @throws Exception if an error occurs
122123 */
123124 @ Test
124- @ Alerts ({"onLoad" , "body onLoad" })
125+ @ Alerts ({"2" , " onLoad" , "body onLoad" })
125126 public void onLoad () throws Exception {
126127 getMockWebConnection ().setResponse (new URL (URL_FIRST , "simple.css" ), "" , MimeType .TEXT_CSS );
127128 onLoadOnError ("rel='stylesheet' href='simple.css'" );
@@ -131,7 +132,7 @@ public void onLoad() throws Exception {
131132 * @throws Exception if an error occurs
132133 */
133134 @ Test
134- @ Alerts ({"onLoad" , "body onLoad" })
135+ @ Alerts ({"2" , " onLoad" , "body onLoad" })
135136 public void onLoadRelCase () throws Exception {
136137 getMockWebConnection ().setResponse (new URL (URL_FIRST , "simple.css" ), "" , MimeType .TEXT_CSS );
137138 onLoadOnError ("rel='sTYLeSheet' href='simple.css'" );
@@ -141,7 +142,7 @@ public void onLoadRelCase() throws Exception {
141142 * @throws Exception if an error occurs
142143 */
143144 @ Test
144- @ Alerts ({"onLoad" , "body onLoad" })
145+ @ Alerts ({"2" , " onLoad" , "body onLoad" })
145146 public void onLoadMediaScreen () throws Exception {
146147 getMockWebConnection ().setResponse (new URL (URL_FIRST , "simple.css" ), "" , MimeType .TEXT_CSS );
147148 onLoadOnError ("rel='stylesheet' href='simple.css' media='screen'" );
@@ -151,7 +152,7 @@ public void onLoadMediaScreen() throws Exception {
151152 * @throws Exception if an error occurs
152153 */
153154 @ Test
154- @ Alerts ({"onLoad" , "body onLoad" })
155+ @ Alerts ({"2" , " onLoad" , "body onLoad" })
155156 public void onLoadMediaPrint () throws Exception {
156157 getMockWebConnection ().setResponse (new URL (URL_FIRST , "simple.css" ), "" , MimeType .TEXT_CSS );
157158 onLoadOnError ("rel='stylesheet' href='simple.css' media='print'" );
@@ -161,7 +162,7 @@ public void onLoadMediaPrint() throws Exception {
161162 * @throws Exception if an error occurs
162163 */
163164 @ Test
164- @ Alerts ({"onLoad" , "body onLoad" })
165+ @ Alerts ({"2" , " onLoad" , "body onLoad" })
165166 public void onLoadMediaQueryMatch () throws Exception {
166167 getMockWebConnection ().setResponse (new URL (URL_FIRST , "simple.css" ), "" , MimeType .TEXT_CSS );
167168 onLoadOnError ("rel='stylesheet' href='simple.css' media='(min-width: 100px)'" );
@@ -171,7 +172,7 @@ public void onLoadMediaQueryMatch() throws Exception {
171172 * @throws Exception if an error occurs
172173 */
173174 @ Test
174- @ Alerts ({"onLoad" , "body onLoad" })
175+ @ Alerts ({"2" , " onLoad" , "body onLoad" })
175176 public void onLoadMediaQueryNotMatch () throws Exception {
176177 getMockWebConnection ().setResponse (new URL (URL_FIRST , "simple.css" ), "" , MimeType .TEXT_CSS );
177178 onLoadOnError ("rel='stylesheet' href='simple.css' media='(max-width: 10px)'" );
@@ -181,7 +182,7 @@ public void onLoadMediaQueryNotMatch() throws Exception {
181182 * @throws Exception if an error occurs
182183 */
183184 @ Test
184- @ Alerts ({"onLoad" , "body onLoad" })
185+ @ Alerts ({"2" , " onLoad" , "body onLoad" })
185186 public void onLoadRelWhitespace () throws Exception {
186187 getMockWebConnection ().setResponse (new URL (URL_FIRST , "simple.css" ), "" , MimeType .TEXT_CSS );
187188 onLoadOnError ("rel='\t stylesheet ' href='simple.css'" );
@@ -191,7 +192,7 @@ public void onLoadRelWhitespace() throws Exception {
191192 * @throws Exception if an error occurs
192193 */
193194 @ Test
194- @ Alerts ({"onLoad" , "body onLoad" })
195+ @ Alerts ({"2" , " onLoad" , "body onLoad" })
195196 public void onLoadTypeCss () throws Exception {
196197 getMockWebConnection ().setResponse (new URL (URL_FIRST , "simple.css" ), "" , MimeType .TEXT_CSS );
197198 onLoadOnError ("rel='stylesheet' href='simple.css' type='" + MimeType .TEXT_CSS + "'" );
@@ -201,7 +202,9 @@ public void onLoadTypeCss() throws Exception {
201202 * @throws Exception if an error occurs
202203 */
203204 @ Test
204- @ Alerts ("body onLoad" )
205+ @ Alerts (DEFAULT = {"1" , "body onLoad" },
206+ FF = {"2" , "body onLoad" },
207+ FF_ESR = {"2" , "body onLoad" })
205208 public void onLoadTypePlain () throws Exception {
206209 getMockWebConnection ().setResponse (new URL (URL_FIRST , "simple.css" ), "" , MimeType .TEXT_CSS );
207210 onLoadOnError ("rel='stylesheet' href='simple.css' type='" + MimeType .TEXT_PLAIN + "'" );
@@ -211,7 +214,9 @@ public void onLoadTypePlain() throws Exception {
211214 * @throws Exception if an error occurs
212215 */
213216 @ Test
214- @ Alerts ("body onLoad" )
217+ @ Alerts (DEFAULT = {"1" , "body onLoad" },
218+ FF = {"2" , "body onLoad" },
219+ FF_ESR = {"2" , "body onLoad" })
215220 public void onLoadTypeHtml () throws Exception {
216221 getMockWebConnection ().setResponse (new URL (URL_FIRST , "simple.css" ), "" , MimeType .TEXT_CSS );
217222 onLoadOnError ("rel='stylesheet' href='simple.css' type='" + MimeType .TEXT_HTML + "'" );
@@ -221,7 +226,9 @@ public void onLoadTypeHtml() throws Exception {
221226 * @throws Exception if an error occurs
222227 */
223228 @ Test
224- @ Alerts ("body onLoad" )
229+ @ Alerts (DEFAULT = {"1" , "body onLoad" },
230+ FF = {"2" , "body onLoad" },
231+ FF_ESR = {"2" , "body onLoad" })
225232 public void onLoadTypeJs () throws Exception {
226233 getMockWebConnection ().setResponse (new URL (URL_FIRST , "simple.css" ), "" , MimeType .TEXT_CSS );
227234 onLoadOnError ("rel='stylesheet' href='simple.css' type='" + MimeType .TEXT_JAVASCRIPT + "'" );
@@ -231,7 +238,9 @@ public void onLoadTypeJs() throws Exception {
231238 * @throws Exception if an error occurs
232239 */
233240 @ Test
234- @ Alerts ("body onLoad" )
241+ @ Alerts (DEFAULT = {"1" , "body onLoad" },
242+ FF = {"2" , "body onLoad" },
243+ FF_ESR = {"2" , "body onLoad" })
235244 public void onLoadTypeGif () throws Exception {
236245 getMockWebConnection ().setResponse (new URL (URL_FIRST , "simple.css" ), "" , MimeType .TEXT_CSS );
237246 onLoadOnError ("rel='stylesheet' href='simple.css' type='" + MimeType .IMAGE_GIF + "'" );
@@ -242,9 +251,9 @@ public void onLoadTypeGif() throws Exception {
242251 * @throws Exception if an error occurs
243252 */
244253 @ Test
245- @ Alerts (DEFAULT = {"onLoad" , "body onLoad" },
246- FF = {"onError" , "body onLoad" },
247- FF_ESR = {"onError" , "body onLoad" })
254+ @ Alerts (DEFAULT = {"2" , " onLoad" , "body onLoad" },
255+ FF = {"2" , " onError" , "body onLoad" },
256+ FF_ESR = {"2" , " onError" , "body onLoad" })
248257 public void onLoadResponseTypePlain () throws Exception {
249258 getMockWebConnection ().setResponse (new URL (URL_FIRST , "simple.css" ), "" , MimeType .TEXT_PLAIN );
250259 onLoadOnError ("rel='stylesheet' href='simple.css'" );
@@ -254,9 +263,9 @@ public void onLoadResponseTypePlain() throws Exception {
254263 * @throws Exception if an error occurs
255264 */
256265 @ Test
257- @ Alerts (DEFAULT = {"onLoad" , "body onLoad" },
258- FF = {"onError" , "body onLoad" },
259- FF_ESR = {"onError" , "body onLoad" })
266+ @ Alerts (DEFAULT = {"2" , " onLoad" , "body onLoad" },
267+ FF = {"2" , " onError" , "body onLoad" },
268+ FF_ESR = {"2" , " onError" , "body onLoad" })
260269 public void onLoadResponseTypeHtml () throws Exception {
261270 getMockWebConnection ().setResponse (new URL (URL_FIRST , "simple.css" ), "" , MimeType .TEXT_HTML );
262271 onLoadOnError ("rel='stylesheet' href='simple.css'" );
@@ -266,9 +275,9 @@ public void onLoadResponseTypeHtml() throws Exception {
266275 * @throws Exception if an error occurs
267276 */
268277 @ Test
269- @ Alerts (DEFAULT = {"onLoad" , "body onLoad" },
270- FF = {"onError" , "body onLoad" },
271- FF_ESR = {"onError" , "body onLoad" })
278+ @ Alerts (DEFAULT = {"2" , " onLoad" , "body onLoad" },
279+ FF = {"2" , " onError" , "body onLoad" },
280+ FF_ESR = {"2" , " onError" , "body onLoad" })
272281 public void onLoadResponseTypeJs () throws Exception {
273282 getMockWebConnection ().setResponse (new URL (URL_FIRST , "simple.css" ), "" , MimeType .TEXT_JAVASCRIPT );
274283 onLoadOnError ("rel='stylesheet' href='simple.css'" );
@@ -278,9 +287,9 @@ public void onLoadResponseTypeJs() throws Exception {
278287 * @throws Exception if an error occurs
279288 */
280289 @ Test
281- @ Alerts (DEFAULT = {"onLoad" , "body onLoad" },
282- FF = {"onError" , "body onLoad" },
283- FF_ESR = {"onError" , "body onLoad" })
290+ @ Alerts (DEFAULT = {"2" , " onLoad" , "body onLoad" },
291+ FF = {"2" , " onError" , "body onLoad" },
292+ FF_ESR = {"2" , " onError" , "body onLoad" })
284293 public void onLoadResponseTypeGif () throws Exception {
285294 getMockWebConnection ().setResponse (new URL (URL_FIRST , "simple.css" ), "" , MimeType .IMAGE_GIF );
286295 onLoadOnError ("rel='stylesheet' href='simple.css'" );
@@ -290,7 +299,7 @@ public void onLoadResponseTypeGif() throws Exception {
290299 * @throws Exception if an error occurs
291300 */
292301 @ Test
293- @ Alerts ({"onError" , "body onLoad" })
302+ @ Alerts ({"2" , " onError" , "body onLoad" })
294303 public void onError () throws Exception {
295304 onLoadOnError ("rel='stylesheet' href='unknown.css'" );
296305 }
@@ -299,7 +308,7 @@ public void onError() throws Exception {
299308 * @throws Exception if an error occurs
300309 */
301310 @ Test
302- @ Alerts (" body onLoad" )
311+ @ Alerts ({ "1" , " body onLoad"} )
303312 public void onLoadOnErrorWithoutRel () throws Exception {
304313 onLoadOnError ("href='unknown.css'" );
305314 }
@@ -319,18 +328,26 @@ private void onLoadOnError(final String attribs) throws Exception {
319328 + "</html>" ;
320329 getMockWebConnection ().setDefaultResponse ("Error: not found" , 404 , "Not Found" , MimeType .TEXT_HTML );
321330
331+ final int requests = getMockWebConnection ().getRequestCount ();
332+ final String [] expected = getExpectedAlerts ();
333+ setExpectedAlerts (Arrays .copyOfRange (expected , 1 , expected .length ));
322334 loadPageVerifyTitle2 (html );
335+
336+ final int count = Integer .parseInt (expected [0 ]);
337+ assertEquals (count , getMockWebConnection ().getRequestCount () - requests );
323338 }
324339
325340 /**
326341 * @throws Exception if an error occurs
327342 */
328343 @ Test
329- @ Alerts ({"onLoad1" , "onLoadJs1" , "onLoad2" , "body onLoad" })
344+ @ Alerts (DEFAULT = {"4" , "onLoad1" , "onLoadJs1" , "onLoad2" , "body onLoad" },
345+ FF = {"4" , "onLoadJs1" , "onLoad2" , "body onLoad" },
346+ FF_ESR = {"4" , "onLoadJs1" , "onLoad2" , "body onLoad" })
330347 public void onLoadOrder () throws Exception {
331348 getMockWebConnection ().setResponse (new URL (URL_FIRST , "simple1.css" ), "" );
332- getMockWebConnection ().setResponse (new URL (URL_FIRST , "simple2.css" ), "" );
333- getMockWebConnection ().setResponse (new URL (URL_FIRST , "simple1.js" ), "var x=1;" );
349+ getMockWebConnection ().setResponse (new URL (URL_FIRST , "simple2.css" ), "" , MimeType . TEXT_CSS );
350+ getMockWebConnection ().setResponse (new URL (URL_FIRST , "simple1.js" ), "var x=1;" , MimeType . TEXT_JAVASCRIPT );
334351
335352 final String html = DOCTYPE_HTML
336353 + "<html>\n "
@@ -346,7 +363,13 @@ public void onLoadOrder() throws Exception {
346363 + "</body>\n "
347364 + "</html>" ;
348365
366+ final int requests = getMockWebConnection ().getRequestCount ();
367+ final String [] expected = getExpectedAlerts ();
368+ setExpectedAlerts (Arrays .copyOfRange (expected , 1 , expected .length ));
349369 loadPageVerifyTitle2 (html );
370+
371+ final int count = Integer .parseInt (expected [0 ]);
372+ assertEquals (count , getMockWebConnection ().getRequestCount () - requests );
350373 }
351374
352375 /**
0 commit comments