Commit 7a4828e0 authored by darin's avatar darin

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.



git-svn-id: http://svn.webkit.org/repository/webkit/trunk@15097 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent 1cf94d1a
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.
......
......@@ -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)
......
......@@ -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*);
......
......@@ -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)
......
......@@ -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
......
<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>
<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>
......@@ -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();
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment