@@ -896,7 +896,7 @@ public void writeScriptInManyTimes() throws Exception {
896896 + " document.write('<script>log(\" foo1\" );</' + 'script>');\n "
897897
898898 + " log('1');\n "
899- + " document.write('<script src=\" scriptA.js\" >; </' + 'script>');\n "
899+ + " document.write('<script src=\" scriptA.js\" ></' + 'script>');\n "
900900 + " log('2');\n "
901901
902902 + " document.write('<script src=\" scriptB.js\" >');\n "
@@ -920,6 +920,83 @@ public void writeScriptInManyTimes() throws Exception {
920920 loadPageVerifyTitle2 (html );
921921 }
922922
923+ /**
924+ * @throws Exception if the test fails
925+ */
926+ @ Test
927+ @ Alerts ({"0" , "foo1" , "1" , "foo2" , "2" , "3" , "4" , "A" , "foo3" })
928+ public void writeScriptPostponed () throws Exception {
929+ final String html = "<html>\n "
930+ + "<head>\n "
931+ + "<script>\n "
932+ + LOG_TITLE_FUNCTION
933+ + " log('0');\n "
934+ + "</script>\n "
935+
936+ + "<script>log(\" foo1\" );</script>'\n "
937+
938+ + "<script>\n "
939+ + " log('1');\n "
940+ + " document.write('<script>log(\" foo2\" );</' + 'script>');\n "
941+ + " log('2');\n "
942+ + " document.write('<script src=\" scriptA.js\" ></' + 'script>');\n "
943+ + " log('3');\n "
944+ + " document.write('<script>log(\" foo3\" );</' + 'script>');\n "
945+ + " log('4');\n "
946+ + "</script>\n "
947+
948+ + "</head>\n "
949+ + "<body>\n "
950+ + "</body></html>" ;
951+
952+ final URL scriptUrlA = new URL (URL_FIRST , "scriptA.js" );
953+ final URL scriptUrlB = new URL (URL_FIRST , "scriptB.js" );
954+
955+ getMockWebConnection ().setDefaultResponse (html );
956+ getMockWebConnection ().setResponse (scriptUrlA , "log('A');\n " , MimeType .TEXT_JAVASCRIPT );
957+
958+ loadPageVerifyTitle2 (html );
959+ }
960+
961+ /**
962+ * @throws Exception if the test fails
963+ */
964+ @ Test
965+ @ Alerts ({"0" , "A" , "1" , "foo2" , "2" , "3" , "4" , "B" , "foo3" })
966+ public void writeScriptPostponedBeforeWrite () throws Exception {
967+ final String html = "<html>\n "
968+ + "<head>\n "
969+ + "<script>\n "
970+ + LOG_TITLE_FUNCTION
971+ + " log('0');\n "
972+ + "</script>\n "
973+
974+ + "<script src='scriptA.js'></script>'\n "
975+
976+ + "<script>\n "
977+ + " log('1');\n "
978+ + " document.write('<script>log(\" foo2\" );</' + 'script>');\n "
979+ + " log('2');\n "
980+ + " document.write('<script src=\" scriptB.js\" ></' + 'script>');\n "
981+ + " log('3');\n "
982+ + " document.write('<script>log(\" foo3\" );</' + 'script>');\n "
983+ + " log('4');\n "
984+ + "</script>\n "
985+
986+ + "</head>\n "
987+ + "<body>\n "
988+ + "</body></html>" ;
989+
990+ final URL scriptUrlA = new URL (URL_FIRST , "scriptA.js" );
991+ final URL scriptUrlB = new URL (URL_FIRST , "scriptB.js" );
992+
993+ getMockWebConnection ().setDefaultResponse (html );
994+ getMockWebConnection ().setResponse (scriptUrlA , "log('A');\n " , MimeType .TEXT_JAVASCRIPT );
995+ getMockWebConnection ().setResponse (scriptUrlB , "log('B');\n " , MimeType .TEXT_JAVASCRIPT );
996+
997+ loadPageVerifyTitle2 (html );
998+ }
999+
9231000 /**
9241001 * Test for bug 1613119.
9251002 * @throws Exception if the test fails
0 commit comments