Quantcast

CVS Commit: src/xdocs: JavaScript: added support for property

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

CVS Commit: src/xdocs: JavaScript: added support for property

mguillem
Log Message:
-----------
JavaScript: added support for property contentWindow on (i)frames.

Modified Files:
--------------
    htmlunit/src/java/com/gargoylesoftware/htmlunit/javascript/host:
        Frame.java
        (http://cvs.sourceforge.net/viewcvs.py/htmlunit/htmlunit/src/java/com/gargoylesoftware/htmlunit/javascript/host/Frame.java)
    htmlunit/src/xdocs:
        changes.xml
        (http://cvs.sourceforge.net/viewcvs.py/htmlunit/htmlunit/src/xdocs/changes.xml)
    htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host:
        FrameTest.java
        (http://cvs.sourceforge.net/viewcvs.py/htmlunit/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/FrameTest.java)
    htmlunit/src/java/com/gargoylesoftware/htmlunit/javascript/configuration:
        JavaScriptConfiguration.xml
        (http://cvs.sourceforge.net/viewcvs.py/htmlunit/htmlunit/src/java/com/gargoylesoftware/htmlunit/javascript/configuration/JavaScriptConfiguration.xml)

Revision Data
-------------
Index: FrameTest.java
===================================================================
RCS file: /cvsroot/htmlunit/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/FrameTest.java,v
retrieving revision 1.10
retrieving revision 1.11
diff -Lsrc/test/java/com/gargoylesoftware/htmlunit/javascript/host/FrameTest.java -Lsrc/test/java/com/gargoylesoftware/htmlunit/javascript/host/FrameTest.java -u -d -r1.10 -r1.11
--- src/test/java/com/gargoylesoftware/htmlunit/javascript/host/FrameTest.java
+++ src/test/java/com/gargoylesoftware/htmlunit/javascript/host/FrameTest.java
@@ -154,6 +154,29 @@
     }
 
     /**
+     * @throws Exception if the test fails
+     */
+    public void testContentWindow() throws Exception {
+        final String content
+            = "<html><head><title>first</title>"
+                + "<script>"
+                + "function test()\n"
+                + "{\n"
+                + "  alert(document.getElementById('myFrame').contentWindow == frames.foo);\n"
+                + "}\n"
+                + "</script></head>"
+                + "<frameset rows='*' onload='test()'>"
+                + "<frame name='foo' id='myFrame' src='about:blank'/>"
+                + "</frameset>"
+                + "</html>";
+        final List expectedAlerts = Arrays.asList( new String[]{"true"} );
+
+        final List collectedAlerts = new ArrayList();
+        loadPage(content, collectedAlerts);
+
+        assertEquals(expectedAlerts, collectedAlerts);
+    }
+    /**
      * Regression test for bug 1236048
      * http://sourceforge.net/tracker/index.php?func=detail&aid=1236048&group_id=47038&atid=448266
      * @throws Exception if the test fails
Index: changes.xml
===================================================================
RCS file: /cvsroot/htmlunit/htmlunit/src/xdocs/changes.xml,v
retrieving revision 1.450
retrieving revision 1.451
diff -Lsrc/xdocs/changes.xml -Lsrc/xdocs/changes.xml -u -d -r1.450 -r1.451
--- src/xdocs/changes.xml
+++ src/xdocs/changes.xml
@@ -8,6 +8,9 @@
     <body>
         <release version="NextRelease" date="Unknown">
             <action type="update" dev="mguillem">
+                JavaScript: added support for property contentWindow on (i)frames.
+            </action>
+            <action type="update" dev="mguillem">
                 Upgraded rhino JavaScript library to 1.6R2.
                 Noteworthy is that the JavaScript stack trace is now added in the normal Java
                 stack trace (bug 274467 reported by Daniel Gredler,
Index: Frame.java
===================================================================
RCS file: /cvsroot/htmlunit/htmlunit/src/java/com/gargoylesoftware/htmlunit/javascript/host/Frame.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -Lsrc/java/com/gargoylesoftware/htmlunit/javascript/host/Frame.java -Lsrc/java/com/gargoylesoftware/htmlunit/javascript/host/Frame.java -u -d -r1.4 -r1.5
--- src/java/com/gargoylesoftware/htmlunit/javascript/host/Frame.java
+++ src/java/com/gargoylesoftware/htmlunit/javascript/host/Frame.java
@@ -42,7 +42,8 @@
 import com.gargoylesoftware.htmlunit.html.BaseFrame;
 
 /**
- * A JavaScript object for a frame and iframe.
+ * A JavaScript object for a {@link com.gargoylesoftware.htmlunit.html.HtmlFrame}
+ * and {@link com.gargoylesoftware.htmlunit.html.HtmlInlineFrame}.
  *
  * @version $Revision$
  * @author Marc Guillemot
@@ -85,6 +86,18 @@
     }
 
     /**
+     * Returns the window the frame contains, if any
+     * @return the window
+     * @see <a href="http://www.mozilla.org/docs/dom/domref/dom_frame_ref5.html">
+     * Gecko DOM Reference</a>
+     * @see <a href="http://msdn.microsoft.com/workshop/author/dhtml/reference/properties/contentwindow.asp">
+     * MSDN documentation</a>
+     */
+    public Window jsxGet_contentWindow() {
+        return (Window) getFrame().getEnclosedWindow().getScriptObject();
+    }
+
+    /**
      * Set the value of the source of the contained frame.
      * @param src The new value.
      */
Index: JavaScriptConfiguration.xml
===================================================================
RCS file: /cvsroot/htmlunit/htmlunit/src/java/com/gargoylesoftware/htmlunit/javascript/configuration/JavaScriptConfiguration.xml,v
retrieving revision 1.16
retrieving revision 1.17
diff -Lsrc/java/com/gargoylesoftware/htmlunit/javascript/configuration/JavaScriptConfiguration.xml -Lsrc/java/com/gargoylesoftware/htmlunit/javascript/configuration/JavaScriptConfiguration.xml -u -d -r1.16 -r1.17
--- src/java/com/gargoylesoftware/htmlunit/javascript/configuration/JavaScriptConfiguration.xml
+++ src/java/com/gargoylesoftware/htmlunit/javascript/configuration/JavaScriptConfiguration.xml
@@ -239,6 +239,7 @@
         <property name="contentDocument" readable="true" writable="false">
             <browser name="Netscape"/>
         </property>
+        <property name="contentWindow" readable="true" writable="false"/>
     </class>
 
 


-------------------------------------------------------
This SF.Net email is sponsored by:
Power Architecture Resource Center: Free content, downloads, discussions,
and more. http://solutions.newsforge.com/ibmarch.tmpl
_______________________________________________
HtmlUnit-develop mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/htmlunit-develop
Loading...