[HtmlUnit] SVN: [14145] 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: [14145] trunk/htmlunit/src

asashour-2
Revision: 14145
          http://sourceforge.net/p/htmlunit/code/14145
Author:   asashour
Date:     2017-04-21 09:23:57 +0000 (Fri, 21 Apr 2017)
Log Message:
-----------
hu3: fix 'this'

Modified Paths:
--------------
    trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/html/DomNamespaceNode.java
    trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/html/HtmlPage.java
    trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/html/HTMLOptionsCollection.java
    trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/html/HtmlFormTest.java
    trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/Window3Test.java
    trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/html/HTMLElementTest.java
    trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/html/HTMLImageElementTest.java

Modified: trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/html/DomNamespaceNode.java
===================================================================
--- trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/html/DomNamespaceNode.java 2017-04-20 20:35:59 UTC (rev 14144)
+++ trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/html/DomNamespaceNode.java 2017-04-21 09:23:57 UTC (rev 14145)
@@ -118,9 +118,9 @@
         return qualifiedName_;
     }
 
-   /**
-    * {@inheritDoc}
-    */
+    /**
+     * {@inheritDoc}
+     */
     @Override
     public void processImportNode(final Document doc) {
         super.processImportNode(doc);

Modified: trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/html/HtmlPage.java
===================================================================
--- trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/html/HtmlPage.java 2017-04-20 20:35:59 UTC (rev 14144)
+++ trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/html/HtmlPage.java 2017-04-21 09:23:57 UTC (rev 14145)
@@ -83,6 +83,7 @@
 import com.gargoylesoftware.htmlunit.javascript.PostponedAction;
 import com.gargoylesoftware.htmlunit.javascript.SimpleScriptable;
 import com.gargoylesoftware.htmlunit.javascript.host.Window;
+import com.gargoylesoftware.htmlunit.javascript.host.Window2;
 import com.gargoylesoftware.htmlunit.javascript.host.dom.Node;
 import com.gargoylesoftware.htmlunit.javascript.host.dom.Node2;
 import com.gargoylesoftware.htmlunit.javascript.host.event.BeforeUnloadEvent;
@@ -731,33 +732,33 @@
         return Collections.unmodifiableList(list);
     }
 
-   /**
-    * Returns a list of all elements that are tabbable in the order that will
-    * be used for tabbing.<p>
-    *
-    * The rules for determining tab order are as follows:
-    * <ol>
-    *   <li>Those elements that support the tabindex attribute and assign a
-    *   positive value to it are navigated first. Navigation proceeds from the
-    *   element with the lowest tabindex value to the element with the highest
-    *   value. Values need not be sequential nor must they begin with any
-    *   particular value. Elements that have identical tabindex values should
-    *   be navigated in the order they appear in the character stream.
-    *   <li>Those elements that do not support the tabindex attribute or
-    *   support it and assign it a value of "0" are navigated next. These
-    *   elements are navigated in the order they appear in the character
-    *   stream.
-    *   <li>Elements that are disabled do not participate in the tabbing
-    *   order.
-    * </ol>
-    * Additionally, the value of tabindex must be within 0 and 32767. Any
-    * values outside this range will be ignored.<p>
-    *
-    * The following elements support the <tt>tabindex</tt> attribute: A, AREA, BUTTON,
-    * INPUT, OBJECT, SELECT, and TEXTAREA.<p>
-    *
-    * @return all the tabbable elements in proper tab order
-    */
+    /**
+     * Returns a list of all elements that are tabbable in the order that will
+     * be used for tabbing.<p>
+     *
+     * The rules for determining tab order are as follows:
+     * <ol>
+     *   <li>Those elements that support the tabindex attribute and assign a
+     *   positive value to it are navigated first. Navigation proceeds from the
+     *   element with the lowest tabindex value to the element with the highest
+     *   value. Values need not be sequential nor must they begin with any
+     *   particular value. Elements that have identical tabindex values should
+     *   be navigated in the order they appear in the character stream.
+     *   <li>Those elements that do not support the tabindex attribute or
+     *   support it and assign it a value of "0" are navigated next. These
+     *   elements are navigated in the order they appear in the character
+     *   stream.
+     *   <li>Elements that are disabled do not participate in the tabbing
+     *   order.
+     * </ol>
+     * Additionally, the value of tabindex must be within 0 and 32767. Any
+     * values outside this range will be ignored.<p>
+     *
+     * The following elements support the <tt>tabindex</tt> attribute: A, AREA, BUTTON,
+     * INPUT, OBJECT, SELECT, and TEXTAREA.<p>
+     *
+     * @return all the tabbable elements in proper tab order
+     */
     public List<HtmlElement> getTabbableElements() {
         final List<HtmlElement> tabbableElements = new ArrayList<>();
         for (final HtmlElement element : getHtmlElementDescendants()) {
@@ -2599,8 +2600,11 @@
     }
 
     private ScriptResult executeJavaScriptFunction(final ScriptFunction function,
-            final ScriptObject thisObject, final Object[] args, final DomNode htmlElementScope) {
+            ScriptObject thisObject, final Object[] args, final DomNode htmlElementScope) {
 
+        if (thisObject instanceof Window2) {
+            thisObject = ((Window2) thisObject).getGlobal();
+        }
         final ScriptFunction functionToCall;
         if (":program".equals(function.getName()) && args.length != 0) {
             ScriptRuntime.apply(function, thisObject);
@@ -2617,7 +2621,9 @@
             if (globalChanged) {
                 com.gargoylesoftware.js.nashorn.internal.runtime.Context.setGlobal(global);
             }
-            thisObject.addBoundProperties(global);
+            if (!(thisObject instanceof Global)) {
+                thisObject.addBoundProperties(global);
+            }
             final Object result = ScriptRuntime.apply(functionToCall, thisObject, args);
             getWebClient().getJavaScriptEngine().processPostponedActions();
             return new ScriptResult(result, getWebClient().getCurrentWindow().getEnclosedPage());

Modified: trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/html/HTMLOptionsCollection.java
===================================================================
--- trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/html/HTMLOptionsCollection.java 2017-04-20 20:35:59 UTC (rev 14144)
+++ trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/html/HTMLOptionsCollection.java 2017-04-21 09:23:57 UTC (rev 14145)
@@ -194,11 +194,11 @@
         }
     }
 
-   /**
-    * Returns the number of elements in this array.
-    *
-    * @return the number of elements in the array
-    */
+    /**
+     * Returns the number of elements in this array.
+     *
+     * @return the number of elements in the array
+     */
     @JsxGetter
     public int getLength() {
         return htmlSelect_.getOptionSize();

Modified: trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/html/HtmlFormTest.java
===================================================================
--- trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/html/HtmlFormTest.java 2017-04-20 20:35:59 UTC (rev 14144)
+++ trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/html/HtmlFormTest.java 2017-04-21 09:23:57 UTC (rev 14145)
@@ -652,9 +652,9 @@
         assertEquals(expectedParameters, collectedParameters);
     }
 
-   /**
-    * @throws Exception if the test fails
-    */
+    /**
+     * @throws Exception if the test fails
+     */
     @Test
     public void submit_IgnoresDisabledControls() throws Exception {
         final String html

Modified: trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/Window3Test.java
===================================================================
--- trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/Window3Test.java 2017-04-20 20:35:59 UTC (rev 14144)
+++ trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/Window3Test.java 2017-04-21 09:23:57 UTC (rev 14145)
@@ -914,7 +914,7 @@
         loadPageWithAlerts2(html);
     }
 
-   /**
+    /**
      * @throws Exception if the test fails
      */
     @Test
@@ -1237,7 +1237,7 @@
     }
 
     /**
-     * Verifies that the onload handler is executed with "this" referring to the window.
+     * Verifies that the {@code onload} handler is executed with {@code this} referring to the window.
      *
      * @throws Exception if an error occurs
      */

Modified: trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/html/HTMLElementTest.java
===================================================================
--- trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/html/HTMLElementTest.java 2017-04-20 20:35:59 UTC (rev 14144)
+++ trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/html/HTMLElementTest.java 2017-04-21 09:23:57 UTC (rev 14145)
@@ -1688,7 +1688,7 @@
         loadPageWithAlerts2(html);
     }
 
-   /**
+    /**
      * Test the removal of behaviors.
      *
      * @throws Exception if the test fails

Modified: trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/html/HTMLImageElementTest.java
===================================================================
--- trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/html/HTMLImageElementTest.java 2017-04-20 20:35:59 UTC (rev 14144)
+++ trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/html/HTMLImageElementTest.java 2017-04-21 09:23:57 UTC (rev 14145)
@@ -424,7 +424,7 @@
         loadPageWithAlerts2(html);
     }
 
-   /**
+    /**
      * Test that image's width and height are numbers.
      * @throws Exception if the test fails
      */


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