Quantcast

[HtmlUnit] SVN: [13825] trunk/htmlunit/src

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: [13825] trunk/htmlunit/src

asashour-2
Revision: 13825
          http://sourceforge.net/p/htmlunit/code/13825
Author:   asashour
Date:     2017-03-19 18:11:52 +0000 (Sun, 19 Mar 2017)
Log Message:
-----------
JavaScript: handle calls after webclient.close()

Modified Paths:
--------------
    trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/WebClient.java
    trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/WebClient5Test.java

Modified: trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/WebClient.java
===================================================================
--- trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/WebClient.java 2017-03-19 12:21:56 UTC (rev 13824)
+++ trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/WebClient.java 2017-03-19 18:11:52 UTC (rev 13825)
@@ -498,7 +498,8 @@
         WebAssert.notNull("webResponse", webResponse);
         WebAssert.notNull("webWindow", webWindow);
 
-        if (webResponse.getStatusCode() == HttpStatus.SC_NO_CONTENT) {
+        if (webResponse.getStatusCode() == HttpStatus.SC_NO_CONTENT
+                || scriptEngine_ == null) {
             return webWindow.getEnclosedPage();
         }
 
@@ -1836,6 +1837,7 @@
         // start a new window that will start the thread again
         if (scriptEngine_ != null) {
             scriptEngine_.shutdown();
+            scriptEngine_ = null;
         }
 
         try {

Modified: trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/WebClient5Test.java
===================================================================
--- trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/WebClient5Test.java 2017-03-19 12:21:56 UTC (rev 13824)
+++ trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/WebClient5Test.java 2017-03-19 18:11:52 UTC (rev 13825)
@@ -72,4 +72,21 @@
             assertEquals(getDefaultUrl(), calledUrls[0]);
         }
     }
+
+    /**
+     * @throws Exception if the test fails
+     */
+    @Test
+    public void useAfterCloseShouldNotCreateThreads() throws Exception {
+        final MockWebConnection connection = getMockWebConnection();
+        connection.setDefaultResponse("hello");
+
+        @SuppressWarnings("resource")
+        final WebClient webClient = new WebClient();
+        webClient.setWebConnection(connection);
+        webClient.close();
+
+        webClient.getPage(URL_FIRST);
+        assertTrue(getJavaScriptThreads().isEmpty());
+    }
 }


------------------------------------------------------------------------------
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...