Reviewed by Anders.
authordarin <darin@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 30 Jun 2006 02:56:14 +0000 (02:56 +0000)
committerdarin <darin@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 30 Jun 2006 02:56:14 +0000 (02:56 +0000)
        - fix http://bugzilla.opendarwin.org/show_bug.cgi?id=9622
          showModalDialog returnValue ignored, function result is always "undefined"

        * manual-tests/modal-dialog.html: Added.
        * manual-tests/show-modal-dialog-test.html: Added.

        * page/Frame.cpp: (WebCore::Frame::clear): Call KJSProxy::clear with the
        clearWindowProperties parameter instead of not calling it at all when
        clearWindowProperties is false.

        * bindings/js/kjs_proxy.h: Add boolean clearWindowProperties parameter.
        * bindings/js/kjs_proxy.cpp: (WebCore::KJSProxy::clear): Pass clearWindowProperties
        variable through to Window::clear instead of not calling it at all.

        * bindings/js/kjs_window.h: Add boolean clearWindowProperties parameter.
        * bindings/js/kjs_window.cpp: (KJS::Window::clear): If clearWindowProperties
        is false, do only the returnValue work, not the rest of the work.

        * manual-tests/modal-dialog.html: Added.
        * manual-tests/show-modal-dialog-test.html: Added.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@15097 268f45cc-cd09-0410-ab3c-d52691b4dbfc

WebCore/ChangeLog
WebCore/bindings/js/kjs_proxy.cpp
WebCore/bindings/js/kjs_proxy.h
WebCore/bindings/js/kjs_window.cpp
WebCore/bindings/js/kjs_window.h
WebCore/manual-tests/modal-dialog.html [new file with mode: 0644]
WebCore/manual-tests/show-modal-dialog-test.html [new file with mode: 0644]
WebCore/page/Frame.cpp

index 78bc9b65e87ad149b5372ffa2547e9880899e8cd..f9f70af8ba1f59e7cb3d17d3b3adcb588cdb28ac 100644 (file)
@@ -1,3 +1,28 @@
+2006-06-29  Darin Adler  <darin@apple.com>
+
+        Reviewed by Anders.
+
+        - fix http://bugzilla.opendarwin.org/show_bug.cgi?id=9622
+          showModalDialog returnValue ignored, function result is always "undefined"
+
+        * manual-tests/modal-dialog.html: Added.
+        * manual-tests/show-modal-dialog-test.html: Added.
+
+        * page/Frame.cpp: (WebCore::Frame::clear): Call KJSProxy::clear with the
+        clearWindowProperties parameter instead of not calling it at all when
+        clearWindowProperties is false.
+
+        * bindings/js/kjs_proxy.h: Add boolean clearWindowProperties parameter.
+        * bindings/js/kjs_proxy.cpp: (WebCore::KJSProxy::clear): Pass clearWindowProperties
+        variable through to Window::clear instead of not calling it at all.
+
+        * bindings/js/kjs_window.h: Add boolean clearWindowProperties parameter.
+        * bindings/js/kjs_window.cpp: (KJS::Window::clear): If clearWindowProperties
+        is false, do only the returnValue work, not the rest of the work.
+
+        * manual-tests/modal-dialog.html: Added.
+        * manual-tests/show-modal-dialog-test.html: Added.
+
 2006-06-29  Beth Dakin  <bdakin@apple.com>
 
         Reviewed by Hyatt.
index e13a152db0c498cead9fd502e2448a484dc716b5..264cd80a41fc3812f9e3d2f114a8d1d993bd0707 100644 (file)
@@ -83,15 +83,15 @@ JSValue* KJSProxy::evaluate(const String& filename, int baseLine, const String&
   return 0;
 }
 
-void KJSProxy::clear() {
-  // clear resources allocated by the interpreter, and make it ready to be used by another page
-  // We have to keep it, so that the Window object for the frame remains the same.
-  // (we used to delete and re-create it, previously)
-  if (m_script) {
-    Window *win = Window::retrieveWindow(m_frame);
-    if (win)
-        win->clear();
-  }
+void KJSProxy::clear(bool clearWindowProperties)
+{
+    // Clear resources allocated by the interpreter, and make it ready to be used by another page.
+    // Earlier versions of this function deleted and re-created the window object, but we have to
+    // keep it because JavaScript can keep a reference to the window object and it must be the same.
+    if (m_script) {
+        if (Window* window = Window::retrieveWindow(m_frame))
+            window->clear(clearWindowProperties);
+    }
 }
 
 EventListener* KJSProxy::createHTMLEventHandler(const String& functionName, const String& code, Node* node)
index 15f79f1d99e81db0bed4cf6f69614796701532b9..8befef489addd35ec77d8eeb927b362a6fb2bede 100644 (file)
@@ -41,7 +41,7 @@ public:
     KJSProxy(Frame*);
     ~KJSProxy();
     KJS::JSValue* evaluate(const String& filename, int baseLine, const String& code, Node*);
-    void clear();
+    void clear(bool clearWindowProperties);
     EventListener* createHTMLEventHandler(const String& functionName, const String& code, Node*);
 #if SVG_SUPPORT
     EventListener* createSVGEventHandler(const String& functionName, const String& code, Node*);
index d59f87fe279ad9807d700099644ce499b2560f0f..b2335ea3c81222c16ef16c90bda6794d1c9651f8 100644 (file)
@@ -1323,23 +1323,25 @@ JSUnprotectedEventListener *Window::getJSUnprotectedEventListener(JSValue *val,
   return new JSUnprotectedEventListener(object, this, html);
 }
 
-void Window::clear()
+void Window::clear(bool clearWindowProperties)
 {
-  JSLock lock;
+    JSLock lock;
 
-  if (m_returnValueSlot)
-    if (JSValue* returnValue = getDirect("returnValue"))
-      *m_returnValueSlot = returnValue;
+    if (m_returnValueSlot)
+        if (JSValue* returnValue = getDirect("returnValue"))
+            *m_returnValueSlot = returnValue;
 
-  clearAllTimeouts();
-  clearProperties();
-  setPrototype(JSDOMWindowProto::self()); // clear the prototype
+    if (clearWindowProperties) {
+        clearAllTimeouts();
+        clearProperties();
+        setPrototype(JSDOMWindowProto::self()); // clear the prototype
 
-  // there's likely to be lots of garbage now
-  Collector::collect();
+        // there's likely to be lots of garbage now
+        Collector::collect();
 
-  // Now recreate a working global object for the next URL that will use us
-  interpreter()->initGlobalObject();
+        // Now recreate a working global object for the next URL that will use us
+        interpreter()->initGlobalObject();
+    }
 }
 
 void Window::setCurrentEvent(Event *evt)
index 3619ed805a9f96e255254a617cd001c7eee208b3..270dad0cf9fbe86f67ea57386465c2cc8b3637c1 100644 (file)
@@ -138,7 +138,7 @@ namespace KJS {
     BarInfo *toolbar(ExecState*) const;
     JSEventListener *getJSEventListener(JSValue*, bool html = false);
     JSUnprotectedEventListener *getJSUnprotectedEventListener(JSValue*, bool html = false);
-    void clear();
+    void clear(bool clearWindowProperties);
     virtual UString toString(ExecState *) const;
 
     // Set the current "event" object
diff --git a/WebCore/manual-tests/modal-dialog.html b/WebCore/manual-tests/modal-dialog.html
new file mode 100644 (file)
index 0000000..7e60835
--- /dev/null
@@ -0,0 +1,12 @@
+<form name="form">
+<p>Here is the text from the main window: <input name="fromWindow"></p>
+<p>Type text here to be sent back to the main window: <input name="toWindow" value="from modal window"></p>
+<p>Then, push this button: <input type="button" value="Close" onClick="closeModal()"></p>
+</form>
+<script>
+document.form.fromWindow.value = window.dialogArguments;
+function closeModal() {
+   window.returnValue = document.form.toWindow.value;
+   window.close();
+}
+</script>
diff --git a/WebCore/manual-tests/show-modal-dialog-test.html b/WebCore/manual-tests/show-modal-dialog-test.html
new file mode 100644 (file)
index 0000000..f34e410
--- /dev/null
@@ -0,0 +1,15 @@
+<script>
+function showModal() {
+    document.form.fromModal.value =
+        showModalDialog("modal-dialog.html",
+            document.form.toModal.value,
+            "dialogHeight:280px,dialogWidth:400px");
+}
+</script>
+<form name="form">
+<p>Type text here to be sent to the modal window and press the button:
+<input name="toModal" value="from main window">
+<input type="button" value="Show Modal" onClick="showModal()"></p>
+<hy>
+<p>Text will appear her from the modal window: <input name="fromModal">
+</form>
index 3ba6206a04ed57323ff0078cfe0eddf230b2d95f..2150edce53d8a9450e093126d8713f59d1cb0b39 100644 (file)
@@ -436,8 +436,8 @@ void Frame::clear(bool clearWindowProperties)
   }
 
   // Moving past doc so that onUnload works.
-  if (clearWindowProperties && d->m_jscript)
-    d->m_jscript->clear();
+  if (d->m_jscript)
+    d->m_jscript->clear(clearWindowProperties);
 
   if (d->m_view)
     d->m_view->clear();