@@ -90,7 +90,7 @@ public void badExternalScriptReference() throws Exception {
9090 */
9191 @ Test
9292 public void asNormalizedText () throws Exception {
93- final String html = "<html><body><script id='s'>var foo = 132;</script></body></html>" ;
93+ final String html = DOCTYPE_HTML + "<html><body><script id='s'>var foo = 132;</script></body></html>" ;
9494 final HtmlPage page = loadPage (html );
9595 final HtmlScript script = page .getHtmlElementById ("s" );
9696 assertEquals ("" , script .asNormalizedText ());
@@ -102,8 +102,8 @@ public void asNormalizedText() throws Exception {
102102 @ Test
103103 @ Alerts ("hello" )
104104 public void asXml () throws Exception {
105- final String html
106- = "<html><head><title>foo</title></head><body>\n "
105+ final String html = DOCTYPE_HTML
106+ + "<html><head><title>foo</title></head><body>\n "
107107 + "<script id='script1'>\n "
108108 + " alert('hello');\n "
109109 + "</script></body></html>" ;
@@ -123,7 +123,7 @@ public void asXml_scriptNestedInCData() throws Exception {
123123 final String script = "//<![CDATA[\n "
124124 + "var foo = 132;\n "
125125 + "//]]>" ;
126- final String html = "<html><body><script id='s'>" + script + "</script></body></html>" ;
126+ final String html = DOCTYPE_HTML + "<html><body><script id='s'>" + script + "</script></body></html>" ;
127127 final HtmlPage page = loadPage (html );
128128 final HtmlScript scriptElement = page .getHtmlElementById ("s" );
129129 assertEquals ("<script id=\" s\" >\r \n " + script + "\r \n </script>\r \n " ,
@@ -137,7 +137,7 @@ public void asXml_scriptNestedInCData() throws Exception {
137137 @ Test
138138 @ Alerts ("loaded" )
139139 public void scriptCloneDoesNotReloadScript () throws Exception {
140- final String html = "<html><body><script src='" + URL_SECOND + "'></script></body></html>" ;
140+ final String html = DOCTYPE_HTML + "<html><body><script src='" + URL_SECOND + "'></script></body></html>" ;
141141 final String js = "alert('loaded')" ;
142142
143143 final WebClient client = getWebClient ();
@@ -179,8 +179,8 @@ public void addEventListener_error_clientDoesNotThrow() throws Exception {
179179
180180 private void addEventListener_error (final boolean throwOnFailingStatusCode ) throws Exception {
181181 final URL fourOhFour = new URL (URL_FIRST , "/404" );
182- final String html
183- = "<html><head>\n "
182+ final String html = DOCTYPE_HTML
183+ + "<html><head>\n "
184184 + "<script>\n "
185185 + " function test() {\n "
186186 + " var s1 = document.createElement('script');\n "
@@ -238,7 +238,7 @@ private void addEventListener_error(final boolean throwOnFailingStatusCode) thro
238238 */
239239 @ Test
240240 public void isDisplayed () throws Exception {
241- final String html = "<html><head><title>Page A</title></head><body><script>var x = 1;</script></body></html>" ;
241+ final String html = DOCTYPE_HTML + "<html><head><title>Page A</title></head><body><script>var x = 1;</script></body></html>" ;
242242 final HtmlPage page = loadPageWithAlerts (html );
243243 final HtmlScript script = page .getFirstByXPath ("//script" );
244244 assertFalse (script .isDisplayed ());
@@ -252,16 +252,16 @@ public void isDisplayed() throws Exception {
252252 @ Test
253253 @ Alerts ({"First script executes" , "Second page loading" })
254254 public void changingLocationSkipsFurtherScriptsOnPage () throws Exception {
255- final String html
256- = "<html><head></head>\n "
255+ final String html = DOCTYPE_HTML
256+ + "<html><head></head>\n "
257257 + "<body onload='alert(\" body onload executing but should be skipped\" )'>\n "
258258 + "<script>alert('First script executes')</script>\n "
259259 + "<script>window.location.href='" + URL_SECOND + "'</script>\n "
260260 + "<script>alert('Third script executing but should be skipped')</script>\n "
261261 + "</body></html>" ;
262262
263- final String secondPage
264- = "<html><head></head><body>\n "
263+ final String secondPage = DOCTYPE_HTML
264+ + "<html><head></head><body>\n "
265265 + "<script>alert('Second page loading')</script>\n "
266266 + "</body></html>" ;
267267
0 commit comments