Changeset 25576 in webkit


Ignore:
Timestamp:
Sep 14, 2007, 4:53:29 PM (17 years ago)
Author:
thatcher
Message:

WebCore:

Reviewed by Sam.

<rdar://problem/5472970> REGRESSION (r24276): TinyMCE popups show an empty window with no content

Accessing the document of a window before the load finished would cause the window
object to hold onto the initial empty document, and never switch over to the real document
once the load finished. This regression was caused by r24276 which added a check to prevent
clearing the window object when the load finished. The absence of this clear allowed the
dialogArguments set with showModalDialog to persist on the window after the load. However,
not clearing the window would keep other properties (and the empty document object) around.

So the fix is to store away the dialog arguments that were passed to showModalDialog and
put them back on the window object in the dialogArguments property each time
the window is cleared.

  • bindings/js/kjs_window.cpp: (KJS::createWindow): No longer put dialogArguments on the window here. (KJS::showModalDialog): Put dialogArguments on the window and call setDialogArgumentsAndReturnValueSlot to remember the arguments. (KJS::Window::clear): Put m_dialogArguments back on the window as dialogArguments. (KJS::WindowFunc::callAsFunction): Call the new setDialogArgumentsAndReturnValue. (KJS::Window::setDialogArgumentsAndReturnValue): Store the arguments in m_dialogArguments.
  • bindings/js/kjs_window.h: Rename setReturnValueSlot to setDialogArgumentsAndReturnValueSlot.
  • manual-tests/modal-dialog-arguments.html: Confirmed that this test still passes.

Reverted r24276 which was all the changes in FrameLoader.cpp and FrameLoader.h.

  • loader/FrameLoader.cpp: (WebCore::FrameLoader::FrameLoader): Remove m_shouldClearWindowProperties. (WebCore::FrameLoader::createWindow): Remove the call to setShouldClearWindowProperties. (WebCore::FrameLoader::clear): No longer check m_shouldClearWindowProperties, clear the window whenever clearWindowProperties is set. (WebCore::FrameLoader::begin): Remove m_shouldClearWindowProperties. (WebCore::FrameLoader::open): Ditto.
  • loader/FrameLoader.h: Remove m_shouldClearWindowProperties.

LayoutTests:

Reviewed by Sam.

<rdar://problem/5472970> REGRESSION (r24276): TinyMCE popups show an empty window with no content

  • fast/dom/Document/early-document-access.html: Added.
  • fast/dom/Document/resources: Added.
  • fast/dom/Document/resources/early-document-access-popup.html: Added.
Location:
trunk
Files:
4 added
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r25563 r25576  
     12007-09-14  Timothy Hatcher  <timothy@apple.com>
     2
     3        Reviewed by Sam.
     4
     5        <rdar://problem/5472970> REGRESSION (r24276): TinyMCE popups show an empty window with no content
     6
     7        * fast/dom/Document/early-document-access.html: Added.
     8        * fast/dom/Document/resources: Added.
     9        * fast/dom/Document/resources/early-document-access-popup.html: Added.
     10
    1112007-09-13  Geoffrey Garen  <ggaren@apple.com>
    212
  • trunk/WebCore/ChangeLog

    r25575 r25576  
     12007-09-14  Timothy Hatcher  <timothy@apple.com>
     2
     3        Reviewed by Sam.
     4
     5        <rdar://problem/5472970> REGRESSION (r24276): TinyMCE popups show an empty window with no content
     6
     7        Accessing the document of a window before the load finished would cause the window
     8        object to hold onto the initial empty document, and never switch over to the real document
     9        once the load finished. This regression was caused by r24276 which added a check to prevent
     10        clearing the window object when the load finished. The absence of this clear allowed the
     11        dialogArguments set with showModalDialog to persist on the window after the load. However,
     12        not clearing the window would keep other properties (and the empty document object) around.
     13
     14        So the fix is to store away the dialog arguments that were passed to showModalDialog and
     15        put them back on the window object in the dialogArguments property each time
     16        the window is cleared.
     17
     18        * bindings/js/kjs_window.cpp:
     19        (KJS::createWindow): No longer put dialogArguments on the window here.
     20        (KJS::showModalDialog): Put dialogArguments on the window and call
     21        setDialogArgumentsAndReturnValueSlot to remember the arguments.
     22        (KJS::Window::clear): Put m_dialogArguments back on the window as dialogArguments.
     23        (KJS::WindowFunc::callAsFunction): Call the new setDialogArgumentsAndReturnValue.
     24        (KJS::Window::setDialogArgumentsAndReturnValue): Store the arguments in m_dialogArguments.
     25        * bindings/js/kjs_window.h: Rename setReturnValueSlot to setDialogArgumentsAndReturnValueSlot.
     26        * manual-tests/modal-dialog-arguments.html: Confirmed that this test still passes.
     27
     28        Reverted r24276 which was all the changes in FrameLoader.cpp and FrameLoader.h.
     29
     30        * loader/FrameLoader.cpp:
     31        (WebCore::FrameLoader::FrameLoader): Remove m_shouldClearWindowProperties.
     32        (WebCore::FrameLoader::createWindow): Remove the call to setShouldClearWindowProperties.
     33        (WebCore::FrameLoader::clear): No longer check m_shouldClearWindowProperties, clear the
     34        window whenever clearWindowProperties is set.
     35        (WebCore::FrameLoader::begin): Remove m_shouldClearWindowProperties.
     36        (WebCore::FrameLoader::open): Ditto.
     37        * loader/FrameLoader.h: Remove m_shouldClearWindowProperties.
     38
    1392007-09-14  Brady Eidson  <beidson@apple.com>
    240
  • trunk/WebCore/bindings/js/kjs_window.cpp

    r25545 r25576  
    9595    mutable Location* loc;
    9696    WebCore::Event *m_evt;
    97     JSValue **m_returnValueSlot;
     97    JSValue* m_dialogArguments;
     98    JSValue** m_returnValueSlot;
    9899    typedef HashMap<int, DOMWindowTimer*> TimeoutsMap;
    99100    TimeoutsMap m_timeouts;
     
    359360
    360361static Frame* createWindow(ExecState* exec, Frame* openerFrame, const String& url,
    361     const String& frameName, const WindowFeatures& windowFeatures, JSValue* dialogArgs)
     362    const String& frameName, const WindowFeatures& windowFeatures)
    362363{
    363364    Frame* activeFrame = Window::retrieveActive(exec)->impl()->frame();
     
    371372    // know what URL we are going to open. Unfortunately, this code passes the empty string
    372373    // for the URL, but there's a reason for that. Before loading we have to set up the opener,
    373     // openedByJS, and dialogArguments values. Also, to decide whether to use the URL we currently
     374    // openedByDOM, and dialogArguments values. Also, to decide whether to use the URL we currently
    374375    // do an isSafeScript call using the window we create, which can't be done before creating it.
    375376    // We'd have to resolve all those issues to pass the URL instead of "".
     
    385386    Window* newWindow = Window::retrieveWindow(newFrame);   
    386387   
    387     if (dialogArgs)
    388         newWindow->putDirect("dialogArguments", dialogArgs);
    389 
    390388    if (!url.startsWith("javascript:", false) || newWindow->isSafeScript(exec)) {
    391389        String completedURL = url.isEmpty() ? url : activeFrame->document()->completeURL(url);
     
    477475    wargs.fullscreen = false;
    478476   
    479     Frame* dialogFrame = createWindow(exec, frame, valueToStringWithUndefinedOrNullCheck(exec, args[0]), "", wargs, args[1]);
     477    Frame* dialogFrame = createWindow(exec, frame, valueToStringWithUndefinedOrNullCheck(exec, args[0]), "", wargs);
    480478    if (!dialogFrame)
    481479        return jsUndefined();
    482480
    483481    Window* dialogWindow = Window::retrieveWindow(dialogFrame);
     482
     483    dialogWindow->putDirect("dialogArguments", args[1]);
    484484
    485485    // Get the return value either just before clearing the dialog window's
    486486    // properties (in Window::clear), or when on return from runModal.
    487487    JSValue* returnValue = 0;
    488     dialogWindow->setReturnValueSlot(&returnValue);
     488    dialogWindow->setDialogArgumentsAndReturnValueSlot(args[1], &returnValue);
    489489    dialogFrame->page()->chrome()->runModal();
    490     dialogWindow->setReturnValueSlot(0);
     490    dialogWindow->setDialogArgumentsAndReturnValueSlot(0, 0);
    491491
    492492    // If we don't have a return value, get it now.
     
    10491049    frame->scriptProxy()->interpreter()->initGlobalObject();
    10501050
     1051  if (d->m_dialogArguments)
     1052    putDirect("dialogArguments", d->m_dialogArguments);
     1053
    10511054  // there's likely to be lots of garbage now
    10521055  gcController().garbageCollectSoon();
     
    13011304      windowFeatures.width = windowRect.width();
    13021305
    1303       frame = createWindow(exec, frame, urlString, frameName, windowFeatures, 0);
     1306      frame = createWindow(exec, frame, urlString, frameName, windowFeatures);
    13041307
    13051308      if (!frame)
     
    14441447}
    14451448
    1446 void Window::setReturnValueSlot(JSValue **slot)
    1447 {
    1448     d->m_returnValueSlot = slot;
     1449void Window::setDialogArgumentsAndReturnValueSlot(JSValue* dialogArgs, JSValue** returnValueSlot)
     1450{
     1451    d->m_dialogArguments = dialogArgs;
     1452    d->m_returnValueSlot = returnValueSlot;
    14491453}
    14501454
  • trunk/WebCore/bindings/js/kjs_window.h

    r24531 r25576  
    129129
    130130    // Set a place to put a dialog return value when the window is cleared.
    131     void setReturnValueSlot(JSValue **slot);
     131    void setDialogArgumentsAndReturnValueSlot(JSValue* arguments, JSValue** returnValueSlot);
    132132
    133133    typedef HashMap<JSObject*, WebCore::JSEventListener*> ListenersMap;
  • trunk/WebCore/loader/FrameLoader.cpp

    r25563 r25576  
    228228    , m_cancellingWithLoadInProgress(false)
    229229    , m_needsClear(false)
    230     , m_shouldClearWindowProperties(true)
    231230    , m_receivedData(false)
    232231    , m_encodingWasChosenByUser(false)
     
    318317        frame->tree()->setName(request.frameName());
    319318
    320     frame->loader()->setShouldClearWindowProperties(false);
    321    
    322319    page->chrome()->setToolbarsVisible(features.toolBarVisible || features.locationBarVisible);
    323320    page->chrome()->setStatusbarVisible(features.statusBarVisible);
     
    789786
    790787    // Do this after detaching the document so that the unload event works.
    791     if (clearWindowProperties && m_shouldClearWindowProperties) {
     788    if (clearWindowProperties) {
    792789        m_frame->clearScriptProxy();
    793790        m_frame->clearDOMWindow();
     
    871868
    872869    m_needsClear = true;
    873     m_shouldClearWindowProperties = true;
    874870    m_isComplete = false;
    875871    m_didCallImplicitClose = false;
     
    26862682
    26872683    m_needsClear = true;
    2688     m_shouldClearWindowProperties = true;
    26892684    m_isComplete = false;
    26902685    m_didCallImplicitClose = false;
  • trunk/WebCore/loader/FrameLoader.h

    r25439 r25576  
    563563        bool dispatchDidLoadResourceFromMemoryCache(DocumentLoader*, const ResourceRequest&, const ResourceResponse&, int length);
    564564
    565         void setShouldClearWindowProperties(bool shouldClearWindowProperties) { m_shouldClearWindowProperties = shouldClearWindowProperties; }
    566        
    567565        Frame* m_frame;
    568566        FrameLoaderClient* m_client;
     
    617615
    618616        bool m_needsClear;
    619         bool m_shouldClearWindowProperties;
    620617        bool m_receivedData;
    621618
Note: See TracChangeset for help on using the changeset viewer.