Quantcast

[HtmlUnit] SVN: [13846] branches/huThread/htmlunit/src/test/java/com/gargoylesoftware /htmlunit/javascript/PostponedActionTest.java

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

[HtmlUnit] SVN: [13846] branches/huThread/htmlunit/src/test/java/com/gargoylesoftware /htmlunit/javascript/PostponedActionTest.java

asashour-2
Revision: 13846
          http://sourceforge.net/p/htmlunit/code/13846
Author:   asashour
Date:     2017-03-20 16:20:11 +0000 (Mon, 20 Mar 2017)
Log Message:
-----------
thread: fix test

Modified Paths:
--------------
    branches/huThread/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/PostponedActionTest.java

Modified: branches/huThread/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/PostponedActionTest.java
===================================================================
--- branches/huThread/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/PostponedActionTest.java 2017-03-20 16:06:22 UTC (rev 13845)
+++ branches/huThread/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/PostponedActionTest.java 2017-03-20 16:20:11 UTC (rev 13846)
@@ -18,6 +18,7 @@
 
 import org.junit.Test;
 import org.junit.runner.RunWith;
+import org.openqa.selenium.WebDriver;
 
 import com.gargoylesoftware.htmlunit.BrowserRunner;
 import com.gargoylesoftware.htmlunit.BrowserRunner.Alerts;
@@ -44,15 +45,15 @@
         final String html = "<html>\n"
             + "<head><title>First Page</title>\n"
             + "<script>\n"
-            + "  function test() {\n"
-            + "    alert('before');\n"
-            + "    var iframe2 = document.createElement('iframe');\n"
-            + "    iframe2.src = 'frame2.html';\n"
-            + "    document.body.appendChild(iframe2);\n"
-            + "    var iframe3 = document.createElement('iframe');\n"
-            + "    document.body.appendChild(iframe3);\n"
-            + "    iframe3.src = 'frame3.html';\n"
-            + "    alert('after');\n"
+            + "function test() {\n"
+            + "  alert('before');\n"
+            + "  var iframe2 = document.createElement('iframe');\n"
+            + "  iframe2.src = 'frame2.html';\n"
+            + "  document.body.appendChild(iframe2);\n"
+            + "  var iframe3 = document.createElement('iframe');\n"
+            + "  document.body.appendChild(iframe3);\n"
+            + "  iframe3.src = 'frame3.html';\n"
+            + "  alert('after');\n"
             + "}\n"
             + "</script>\n"
             + "</head>\n"
@@ -80,12 +81,12 @@
         final String firstContent = "<html>\n"
             + "<head><title>First Page</title>\n"
             + "<script>\n"
-            + "  function test() {\n"
-            + "    alert('before');\n"
-            + "    var iframe = document.createElement('iframe');\n"
-            + "    document.body.appendChild(iframe);\n"
-            + "    iframe.contentWindow.location.replace('" + URL_SECOND + "');\n"
-            + "    alert('after');\n"
+            + "function test() {\n"
+            + "  alert('before');\n"
+            + "  var iframe = document.createElement('iframe');\n"
+            + "  document.body.appendChild(iframe);\n"
+            + "  iframe.contentWindow.location.replace('" + URL_SECOND + "');\n"
+            + "  alert('after');\n"
             + "}\n"
             + "</script>\n"
             + "</head>\n"
@@ -113,17 +114,17 @@
         final String html = "<html>\n"
                 + "<head><title>First Page</title>\n"
                 + "<script>\n"
-                + "  function test() {\n"
-                + "    alert('before');\n"
-                + "    var iframe = document.createElement('iframe');\n"
-                + "    iframe.src = 'iframe.html';\n"
-                + "    document.body.appendChild(iframe);\n"
-                + "    alert('after');\n"
+                + "function test() {\n"
+                + "  alert('before');\n"
+                + "  var iframe = document.createElement('iframe');\n"
+                + "  iframe.src = 'iframe.html';\n"
+                + "  document.body.appendChild(iframe);\n"
+                + "  alert('after');\n"
                 + "}\n"
-                + "  function timeout() {\n"
-                + "    alert('setting timeout');\n"
-                + "    window.setTimeout(function() {test()}, 400);\n"
-                + "    window.setTimeout(function() {alert('simpleAlert')}, 500);\n"
+                + "function timeout() {\n"
+                + "  alert('setting timeout');\n"
+                + "  window.setTimeout(function() {test()}, 400);\n"
+                + "  window.setTimeout(function() {alert('simpleAlert')}, 500);\n"
                 + "}\n"
                 + "</script>\n"
                 + "</head>\n"
@@ -136,6 +137,14 @@
         final MockWebConnection conn = getMockWebConnection();
         conn.setResponse(new URL(getDefaultUrl(), "iframe.html"), secondContent);
 
-        loadPageWithAlerts2(html);
+        final WebDriver driver = loadPage2(html);
+        final String[] alerts = getExpectedAlerts();
+        verifyAlerts(driver, alerts[0]);
+        Thread.sleep(400);
+        verifyAlerts(driver, alerts[1], alerts[2]);
+        Thread.sleep(100);
+        verifyAlerts(driver, alerts[3]);
+        Thread.sleep(100);
+        verifyAlerts(driver, alerts[4]);
     }
 }


------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
HtmlUnit-develop mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/htmlunit-develop
Loading...