Changeset 25783 in webkit


Ignore:
Timestamp:
Sep 27, 2007, 4:56:17 PM (17 years ago)
Author:
antti
Message:

WebCore:

Reviewed by Geoff.


Fix for <rdar://problem/5499125>
REGRESSION (r21367): After launching Kidzui beta, a webview frame fails to appear in its main window


If window object properties were modified when it had initial empty document (synchronously after
window.open() for example) those modifications were lost when the real document was switched in.


Match Firefox behavior where window properties are not cleared if the inital document and the loaded one
have matching security domains.

Tests: fast/dom/Window/window-early-properties.html

http/tests/security/window-properties-clear-domain.html
http/tests/security/window-properties-clear-port.html
http/tests/security/window-properties-pass.html

  • WebCore.exp:
  • loader/FrameLoader.cpp: (WebCore::FrameLoader::FrameLoader): (WebCore::FrameLoader::init): (WebCore::FrameLoader::clear): (WebCore::FrameLoader::isSecureTransition): (WebCore::FrameLoader::begin):
  • loader/FrameLoader.h: If we are transitioning from initial empty document to the final one, do a domain security check between old security policy URL and new URL. If that passes don't clear script proxy and script objects.


  • bindings/js/kjs_proxy.cpp: (WebCore::KJSProxy::updateDocumentWrapper):
  • bindings/js/kjs_proxy.h:
  • page/Frame.cpp: (WebCore::Frame::setDocument): Since we don't always clear window properties anymore, we need to update the document property to point to the newly created one.

LayoutTests:

Reviewed by Geoff.


Tests for <rdar://problem/5499125>
REGRESSION (r21359-21368): After launching Kidzui beta, a webview frame fails to appear in its main window

  • fast/dom/Window/window-early-properties-expected.txt: Added.
  • fast/dom/Window/window-early-properties.html: Added.
  • http/tests/security/resources/has-custom-property.html: Added.
  • http/tests/security/resources/no-custom-property.html: Added.
  • http/tests/security/window-properties-clear-domain-expected.txt: Added.
  • http/tests/security/window-properties-clear-domain.html: Added.
  • http/tests/security/window-properties-clear-port-expected.txt: Added.
  • http/tests/security/window-properties-clear-port.html: Added.
  • http/tests/security/window-properties-pass-expected.txt: Added.
  • http/tests/security/window-properties-pass.html: Added.
Location:
trunk
Files:
10 added
8 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r25773 r25783  
     12007-09-27  Antti Koivisto  <antti@apple.com>
     2
     3        Reviewed by Geoff.
     4       
     5        Tests for <rdar://problem/5499125>
     6        REGRESSION (r21359-21368): After launching Kidzui beta, a webview frame fails to appear in its main window
     7
     8        * fast/dom/Window/window-early-properties-expected.txt: Added.
     9        * fast/dom/Window/window-early-properties.html: Added.
     10        * http/tests/security/resources/has-custom-property.html: Added.
     11        * http/tests/security/resources/no-custom-property.html: Added.
     12        * http/tests/security/window-properties-clear-domain-expected.txt: Added.
     13        * http/tests/security/window-properties-clear-domain.html: Added.
     14        * http/tests/security/window-properties-clear-port-expected.txt: Added.
     15        * http/tests/security/window-properties-clear-port.html: Added.
     16        * http/tests/security/window-properties-pass-expected.txt: Added.
     17        * http/tests/security/window-properties-pass.html: Added.
     18
    1192007-09-26  Adam Roben  <aroben@apple.com>
    220
  • trunk/WebCore/ChangeLog

    r25781 r25783  
     12007-09-27  Antti Koivisto  <antti@apple.com>
     2
     3        Reviewed by Geoff.
     4       
     5        Fix for <rdar://problem/5499125>
     6        REGRESSION (r21367): After launching Kidzui beta, a webview frame fails to appear in its main window
     7       
     8        If window object properties were modified when it had initial empty document (synchronously after
     9        window.open() for example) those modifications were lost when the real document was switched in.
     10       
     11        Match Firefox behavior where window properties are not cleared if the inital document and the loaded one
     12        have matching security domains.
     13
     14        Tests: fast/dom/Window/window-early-properties.html
     15               http/tests/security/window-properties-clear-domain.html
     16               http/tests/security/window-properties-clear-port.html
     17               http/tests/security/window-properties-pass.html
     18
     19        * WebCore.exp:
     20        * loader/FrameLoader.cpp:
     21        (WebCore::FrameLoader::FrameLoader):
     22        (WebCore::FrameLoader::init):
     23        (WebCore::FrameLoader::clear):
     24        (WebCore::FrameLoader::isSecureTransition):
     25        (WebCore::FrameLoader::begin):
     26        * loader/FrameLoader.h:
     27        If we are transitioning from initial empty document to the final one, do a domain security check
     28        between old security policy URL and new URL. If that passes don't clear script proxy and script objects.
     29       
     30        * bindings/js/kjs_proxy.cpp:
     31        (WebCore::KJSProxy::updateDocumentWrapper):
     32        * bindings/js/kjs_proxy.h:
     33        * page/Frame.cpp:
     34        (WebCore::Frame::setDocument):
     35        Since we don't always clear window properties anymore, we need to update the document property to point to
     36        the newly created one.
     37       
    1382007-09-27  Kevin Decker  <kdecker@apple.com>
    239
  • trunk/WebCore/WebCore.exp

    r25547 r25783  
    169169__ZN7WebCore11FrameLoader4loadERKNS_4KURLEPNS_5EventE
    170170__ZN7WebCore11FrameLoader4loadERKNS_4KURLERKNS_6StringENS_13FrameLoadTypeES6_PNS_5EventEN3WTF10PassRefPtrINS_9FormStateEEE
    171 __ZN7WebCore11FrameLoader5clearEb
     171__ZN7WebCore11FrameLoader5clearEbb
    172172__ZN7WebCore11FrameLoader6reloadEv
    173173__ZN7WebCore11FrameLoader7canLoadERKNS_4KURLEPKNS_8DocumentE
  • trunk/WebCore/bindings/js/kjs_proxy.cpp

    r25754 r25783  
    2727#include "FrameLoader.h"
    2828#include "GCController.h"
     29#include "JSDocument.h"
    2930#include "JSDOMWindow.h"
    3031#include "Page.h"
     
    165166  m_frame->loader()->dispatchWindowObjectAvailable();
    166167}
     168   
     169void KJSProxy::updateDocumentWrapper()
     170{
     171    if (!m_script || !m_frame->document())
     172        return;
     173    JSLock lock;
     174    // this will update 'document' property to point to the current document
     175    toJS(m_script->globalExec(), m_frame->document());
     176}
    167177
    168178}
  • trunk/WebCore/bindings/js/kjs_proxy.h

    r25754 r25783  
    5555
    5656    bool haveInterpreter() const { return m_script; }
     57   
     58    void updateDocumentWrapper();
    5759
    5860private:
  • trunk/WebCore/loader/FrameLoader.cpp

    r25779 r25783  
    237237    , m_openedByDOM(false)
    238238    , m_creatingInitialEmptyDocument(false)
     239    , m_isDisplayingInitialEmptyDocument(false)
    239240    , m_committedFirstRealDocumentLoad(false)
    240241    , m_didPerformFirstNavigation(false)
     
    261262{
    262263    // this somewhat odd set of steps is needed to give the frame an initial empty document
     264    m_isDisplayingInitialEmptyDocument = false;
    263265    m_creatingInitialEmptyDocument = true;
    264266    setPolicyDocumentLoader(m_client->createDocumentLoader(ResourceRequest(String("")), SubstituteData()).get());
     
    764766}
    765767
    766 void FrameLoader::clear(bool clearWindowProperties)
     768void FrameLoader::clear(bool clearWindowProperties, bool clearScriptObjects)
    767769{
    768770    // FIXME: Commenting out the below line causes <http://bugs.webkit.org/show_bug.cgi?id=11212>, but putting it
     
    801803
    802804    m_containsPlugIns = false;
    803     m_frame->clearScriptObjects();
     805   
     806    if (clearScriptObjects)
     807        m_frame->clearScriptObjects();
    804808 
    805809    m_redirectionTimer.stop();
     
    810814
    811815    m_receivedData = false;
     816    m_isDisplayingInitialEmptyDocument = false;
    812817
    813818    if (!m_encodingWasChosenByUser)
     
    854859    m_responseMIMEType = type;
    855860}
     861   
     862bool FrameLoader::isSecureTransition(const KURL& fromURL, const KURL& toURL)
     863{
     864    // new window created by the application
     865    if (fromURL.isEmpty())
     866        return true;
     867   
     868    if (fromURL.isLocalFile())
     869        return true;
     870   
     871    if (equalIgnoringCase(fromURL.host(), toURL.host()) && equalIgnoringCase(fromURL.protocol(), toURL.protocol()) && fromURL.port() == toURL.port())
     872        return true;
     873   
     874    return false;
     875}
    856876
    857877void FrameLoader::begin()
     
    862882void FrameLoader::begin(const KURL& url, bool dispatch)
    863883{
    864     clear();
     884    bool resetScripting = !(m_isDisplayingInitialEmptyDocument && m_frame->document()
     885                            && isSecureTransition(m_frame->document()->securityPolicyURL(), url));
     886    clear(resetScripting, resetScripting);
    865887    if (dispatch)
    866888        dispatchWindowObjectAvailable();
     
    870892    m_didCallImplicitClose = false;
    871893    m_isLoadingMainResource = true;
     894    m_isDisplayingInitialEmptyDocument = m_creatingInitialEmptyDocument;
    872895
    873896    KURL ref(url);
  • trunk/WebCore/loader/FrameLoader.h

    r25576 r25783  
    532532        void updateHistoryAfterClientRedirect();
    533533
    534         void clear(bool clearWindowProperties = true);
     534        void clear(bool clearWindowProperties = true, bool clearScriptObjects = true);
    535535
    536536        bool shouldReloadToHandleUnreachableURL(DocumentLoader*);
     
    546546
    547547        void startIconLoader();
     548       
     549        bool isSecureTransition(const KURL& fromURL, const KURL& toURL);
    548550
    549551#if USE(LOW_BANDWIDTH_DISPLAY)
     
    637639
    638640        bool m_creatingInitialEmptyDocument;
     641        bool m_isDisplayingInitialEmptyDocument;
    639642        bool m_committedFirstRealDocumentLoad;
    640643
  • trunk/WebCore/page/Frame.cpp

    r25754 r25783  
    280280    if (d->m_doc && !d->m_doc->attached())
    281281        d->m_doc->attach();
     282   
     283    if (d->m_jscript && d->m_doc)
     284        d->m_jscript->updateDocumentWrapper();
    282285}
    283286
Note: See TracChangeset for help on using the changeset viewer.