[HtmlUnit] SVN: [14140] trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/ html/HtmlScript.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: [14140] trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/ html/HtmlScript.java

asashour-2
Revision: 14140
          http://sourceforge.net/p/htmlunit/code/14140
Author:   asashour
Date:     2017-04-20 11:16:36 +0000 (Thu, 20 Apr 2017)
Log Message:
-----------
hu3: HtmlScript.onAllChildrenAddedToPage

Modified Paths:
--------------
    trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/html/HtmlScript.java

Modified: trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/html/HtmlScript.java
===================================================================
--- trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/html/HtmlScript.java 2017-04-20 09:14:37 UTC (rev 14139)
+++ trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/html/HtmlScript.java 2017-04-20 11:16:36 UTC (rev 14140)
@@ -34,11 +34,13 @@
 import com.gargoylesoftware.htmlunit.javascript.AbstractJavaScriptEngine;
 import com.gargoylesoftware.htmlunit.javascript.PostponedAction;
 import com.gargoylesoftware.htmlunit.javascript.host.Window;
+import com.gargoylesoftware.htmlunit.javascript.host.Window2;
 import com.gargoylesoftware.htmlunit.javascript.host.dom.Document;
 import com.gargoylesoftware.htmlunit.javascript.host.event.Event;
 import com.gargoylesoftware.htmlunit.javascript.host.event.Event2;
 import com.gargoylesoftware.htmlunit.javascript.host.event.EventHandler;
 import com.gargoylesoftware.htmlunit.javascript.host.html.HTMLDocument;
+import com.gargoylesoftware.htmlunit.javascript.host.html.HTMLDocument2;
 import com.gargoylesoftware.htmlunit.javascript.host.html.HTMLScriptElement;
 import com.gargoylesoftware.htmlunit.javascript.host.html.HTMLScriptElement2;
 import com.gargoylesoftware.htmlunit.protocol.javascript.JavaScriptURLConnection;
@@ -237,22 +239,30 @@
         final PostponedAction action = new PostponedAction(getPage(), "Execution of script " + this) {
             @Override
             public void execute() {
-                HTMLDocument jsDoc = null;
+                Object jsDoc = null;
                 final Window window = (Window) getPage().getEnclosingWindow().getScriptableObject();
-                // null for Nashorn
                 if (window != null) {
                     jsDoc = (HTMLDocument) window.getDocument();
-                    jsDoc.setExecutingDynamicExternalPosponed(getStartLineNumber() == -1
+                    ((HTMLDocument) jsDoc).setExecutingDynamicExternalPosponed(getStartLineNumber() == -1
                             && getSrcAttribute() != ATTRIBUTE_NOT_DEFINED);
                 }
+                else {
+                    jsDoc = (HTMLDocument2) Window2.getDocument(getPage().getEnclosingWindow().getGlobal());
+                    ((HTMLDocument2) jsDoc).setExecutingDynamicExternalPosponed(getStartLineNumber() == -1
+                            && getSrcAttribute() != ATTRIBUTE_NOT_DEFINED);
+                    
+                }
 
                 try {
                     executeScriptIfNeeded();
                 }
                 finally {
-                    if (jsDoc != null) {
-                        jsDoc.setExecutingDynamicExternalPosponed(false);
+                    if (jsDoc instanceof HTMLDocument) {
+                        ((HTMLDocument) jsDoc).setExecutingDynamicExternalPosponed(false);
                     }
+                    else if (jsDoc instanceof HTMLDocument2) {
+                        ((HTMLDocument2) jsDoc).setExecutingDynamicExternalPosponed(false);
+                    }
                 }
             }
         };


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