Changeset 26074 in webkit


Ignore:
Timestamp:
Oct 5, 2007 5:54:00 PM (17 years ago)
Author:
ggaren
Message:

JavaScriptCore:

Reviewed by Sam Weinig.


Added JSObject::removeDirect, to support the fix for
<rdar://problem/5522487> REGRESSION: With JavaScript disabled, any
page load causes a crash in PropertyMap::put

  • kjs/object.cpp: (KJS::JSObject::removeDirect):
  • kjs/object.h:

WebCore:

Reviewed by Sam Weinig.


New fix for <rdar://problem/5522487> REGRESSION: With JavaScript
disabled, any page load causes a crash in PropertyMap::put


Explicitly remove the "document" property from the window. The old
solution would leave a stale "document" property around after JavaScript
was re-enabled.

The architecture for disabling JavaScript could use some consolidation.
It seems wrong that a script proxy even exists when JavaScript is
disabled. It also seems wrong that so many individual call sites are
responsible for checking whether JavaScript is enabled. I've filed a
bug about this: http://bugs.webkit.org/show_bug.cgi?id=15385.

  • bindings/js/kjs_proxy.cpp: (WebCore::KJSProxy::clearDocumentWrapper):
  • bindings/js/kjs_proxy.h:
  • page/Frame.cpp: (WebCore::Frame::setDocument):
Location:
trunk
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • trunk/JavaScriptCore/ChangeLog

    r26050 r26074  
     12007-10-05  Geoffrey Garen  <ggaren@apple.com>
     2
     3        Reviewed by Sam Weinig.
     4       
     5        Added JSObject::removeDirect, to support the fix for
     6        <rdar://problem/5522487> REGRESSION: With JavaScript disabled, any
     7        page load causes a crash in PropertyMap::put
     8
     9        * kjs/object.cpp:
     10        (KJS::JSObject::removeDirect):
     11        * kjs/object.h:
     12
    1132007-10-04  Mark Rowe  <mrowe@apple.com>
    214
  • trunk/JavaScriptCore/JavaScriptCore.exp

    r25584 r26074  
    1 _jscore_collector_introspection
    2 _jscore_fastmalloc_introspection
    31_JSCheckScriptSyntax
    42_JSClassCreate
     
    143141__ZN3KJS13SavedBuiltinsC1Ev
    144142__ZN3KJS13SavedBuiltinsD1Ev
     143__ZN3KJS13jsOwnedStringERKNS_7UStringE
    145144__ZN3KJS14StringInstance14deletePropertyEPNS_9ExecStateERKNS_10IdentifierE
    146145__ZN3KJS14StringInstance16getPropertyNamesEPNS_9ExecStateERNS_17PropertyNameArrayE
     
    198197__ZN3KJS8DebuggerD2Ev
    199198__ZN3KJS8JSObject11hasInstanceEPNS_9ExecStateEPNS_7JSValueE
     199__ZN3KJS8JSObject12removeDirectERKNS_10IdentifierE
    200200__ZN3KJS8JSObject14callAsFunctionEPNS_9ExecStateEPS0_RKNS_4ListE
    201201__ZN3KJS8JSObject14deletePropertyEPNS_9ExecStateERKNS_10IdentifierE
     
    214214__ZN3KJS8jsStringEPKc
    215215__ZN3KJS8jsStringERKNS_7UStringE
    216 __ZN3KJS13jsOwnedStringERKNS_7UStringE
    217216__ZN3KJS9Collector15numInterpretersEv
    218217__ZN3KJS9Collector15recordExtraCostEm
     
    283282__ZTVN3KJS19InternalFunctionImpE
    284283__ZTVN3KJS8JSObjectE
     284_jscore_collector_introspection
     285_jscore_fastmalloc_introspection
    285286_kJSClassDefinitionEmpty
    286287_kjs_pcre_compile
  • trunk/JavaScriptCore/kjs/object.cpp

    r25161 r26074  
    559559}
    560560
     561void JSObject::removeDirect(const Identifier &propertyName)
     562{
     563    _prop.remove(propertyName);
     564}
     565
    561566void JSObject::putDirectFunction(InternalFunctionImp* func, int attr)
    562567{
  • trunk/JavaScriptCore/kjs/object.h

    r21736 r26074  
    436436    void putDirect(const Identifier &propertyName, JSValue *value, int attr = 0);
    437437    void putDirect(const Identifier &propertyName, int value, int attr = 0);
    438 
     438    void removeDirect(const Identifier &propertyName);
     439   
    439440    // convenience to add a function property under the function's own built-in name
    440441    void putDirectFunction(InternalFunctionImp*, int attr = 0);
  • trunk/WebCore/ChangeLog

    r26072 r26074  
     12007-10-05  Geoffrey Garen  <ggaren@apple.com>
     2
     3        Reviewed by Sam Weinig.
     4       
     5        New fix for <rdar://problem/5522487> REGRESSION: With JavaScript
     6        disabled, any page load causes a crash in PropertyMap::put
     7       
     8        Explicitly remove the "document" property from the window. The old
     9        solution would leave a stale "document" property around after JavaScript
     10        was re-enabled.
     11
     12        The architecture for disabling JavaScript could use some consolidation.
     13        It seems wrong that a script proxy even exists when JavaScript is
     14        disabled. It also seems wrong that so many individual call sites are
     15        responsible for checking whether JavaScript is enabled. I've filed a
     16        bug about this: http://bugs.webkit.org/show_bug.cgi?id=15385.
     17
     18        * bindings/js/kjs_proxy.cpp:
     19        (WebCore::KJSProxy::clearDocumentWrapper):
     20        * bindings/js/kjs_proxy.h:
     21        * page/Frame.cpp:
     22        (WebCore::Frame::setDocument):
     23
    1242007-10-05  Jon Honeycutt  <jhoneycutt@apple.com>
    225
  • trunk/WebCore/bindings/js/kjs_proxy.cpp

    r26071 r26074  
    168168}
    169169   
    170 void KJSProxy::updateDocumentWrapper()
     170void KJSProxy::clearDocumentWrapper()
    171171{
    172     Settings* settings = m_frame->settings();
    173     if (!settings || !settings->isJavaScriptEnabled())
    174         return;
    175 
    176     if (!m_script || !m_frame->document())
     172    if (!m_script)
    177173        return;
    178174
    179175    JSLock lock;
    180     // this will update 'document' property to point to the current document
    181     toJS(m_script->globalExec(), m_frame->document());
     176    m_script->globalObject()->removeDirect("document");
    182177}
    183178
  • trunk/WebCore/bindings/js/kjs_proxy.h

    r25783 r26074  
    5656    bool haveInterpreter() const { return m_script; }
    5757   
    58     void updateDocumentWrapper();
     58    void clearDocumentWrapper();
    5959
    6060private:
  • trunk/WebCore/page/Frame.cpp

    r25783 r26074  
    281281        d->m_doc->attach();
    282282   
    283     if (d->m_jscript && d->m_doc)
    284         d->m_jscript->updateDocumentWrapper();
     283    // Remove the cached 'document' property, which is now stale.
     284    if (d->m_jscript)
     285        d->m_jscript->clearDocumentWrapper();
    285286}
    286287
Note: See TracChangeset for help on using the changeset viewer.