Changeset 12486 in webkit


Ignore:
Timestamp:
Jan 30, 2006 6:52:49 PM (18 years ago)
Author:
ggaren
Message:

Reviewed by mjs.

  • Speculative fix for <rdar://problem/4135845> Crash executing cross-frame script on timeout in KJS::ScheduledAction::execute

If we ever get a reproducible case of 4135845, I'll add a test for it.

This is a re-working of Maciej's fix for 3157014 (circa 2003!). Since
you can't reliably predict what the state of the page will be when
a timer fires, I've made the timer responsbile for making sure that
everything is OK to execute.

I tested @ http://www.javascriptkit.com/script/cut3.shtml with various
combinations of reload, back, and regular navigations with JS enabled/
disabled to ensure that the previous crash didn't return. I also ran a
leaks test and discovered some, but none unique to this patch. (See
<rdar://problem/4427420> TOT REGRESSION: Leaks seen on page with
JavaScript timer.)

  • khtml/ecma/kjs_window.cpp: (KJS::ScheduledAction::execute): Return early if there's no window object. (This happens when JavaScript is disabled.) (KJS::Window::retrieveWindow): Reversed a backwards ASSERT, increased prettiness. (The assert fired while I was testing. Not sure why we haven't seen it before.)
  • page/Frame.cpp: (Frame::didOpenURL): Returned setting of JavaScript enabled/disabled preference to its rightful place. This introduces a new behavior: now, the unload event does not fire after you've disabled JavaScript. That seems like a good thing. (See <rdar://problem/4426506> Disabling JavaScript should immediately end JavaScript execution.) (Frame::begin): Ditto.
Location:
trunk/WebCore
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/WebCore/ChangeLog

    r12480 r12486  
     12006-01-30  Geoffrey Garen  <ggaren@apple.com>
     2
     3        Reviewed by mjs.
     4
     5        - Speculative fix for <rdar://problem/4135845> Crash executing
     6        cross-frame script on timeout in KJS::ScheduledAction::execute
     7
     8        If we ever get a reproducible case of 4135845, I'll add a test for it.
     9
     10        This is a re-working of Maciej's fix for 3157014 (circa 2003!). Since
     11        you can't reliably predict what the state of the page will be when
     12        a timer fires, I've made the timer responsbile for making sure that
     13        everything is OK to execute.
     14
     15        I tested @ http://www.javascriptkit.com/script/cut3.shtml with various
     16        combinations of reload, back, and regular navigations with JS enabled/
     17        disabled to ensure that the previous crash didn't return. I also ran a
     18        leaks test and discovered some, but none unique to this patch. (See
     19        <rdar://problem/4427420> TOT REGRESSION: Leaks seen on page with
     20        JavaScript timer.)
     21
     22        * khtml/ecma/kjs_window.cpp:
     23        (KJS::ScheduledAction::execute): Return early if there's no window
     24        object. (This happens when JavaScript is disabled.)
     25        (KJS::Window::retrieveWindow): Reversed a backwards ASSERT, increased
     26        prettiness. (The assert fired while I was testing. Not sure why we
     27        haven't seen it before.)
     28        * page/Frame.cpp:
     29        (Frame::didOpenURL): Returned setting of JavaScript enabled/disabled
     30        preference to its rightful place. This introduces a new behavior: now,
     31        the unload event does not fire after you've disabled JavaScript. That
     32        seems like a good thing. (See <rdar://problem/4426506> Disabling
     33        JavaScript should immediately end JavaScript execution.)
     34        (Frame::begin): Ditto.
     35
    1362006-01-30  Geoffrey Garen  <ggaren@apple.com>
    237
  • trunk/WebCore/khtml/ecma/kjs_window.cpp

    r12476 r12486  
    331331}
    332332
    333 Window *Window::retrieveWindow(Frame *p)
    334 {
    335   JSObject *obj = retrieve(p)->getObject();
    336   // obj should never be null, except when javascript has been disabled in that frame.
    337   ASSERT(obj || (p && p->jScriptEnabled()));
    338   if (!obj) // JS disabled
    339     return 0;
    340   return static_cast<Window*>(obj);
     333Window *Window::retrieveWindow(Frame *f)
     334{
     335    JSObject *o = retrieve(f)->getObject();
     336
     337    ASSERT(o || !f->jScriptEnabled());
     338    return static_cast<Window *>(o);
    341339}
    342340
     
    18361834void ScheduledAction::execute(Window *window)
    18371835{
    1838     if (!window->m_frame)
     1836    if (!window->m_frame || !window->m_frame->jScript())
    18391837        return;
    18401838
    1841     ScriptInterpreter *interpreter = window->interpreter();
     1839    ScriptInterpreter *interpreter = window->m_frame->jScript()->interpreter();
    18421840
    18431841    interpreter->setProcessingTimerCallback(true);
  • trunk/WebCore/khtml/ecma/kjs_window.h

    r12474 r12486  
    121121     * bindings.
    122122     */
    123     static JSValue *retrieve(Frame *p);
     123    static JSValue *retrieve(Frame *);
    124124    /**
    125125     * Returns the Window object for a given HTML frame
    126126     */
    127     static Window *retrieveWindow(Frame *p);
     127    static Window *retrieveWindow(Frame *);
    128128    /**
    129129     * returns a pointer to the Window object this javascript interpreting instance
  • trunk/WebCore/page/Frame.cpp

    r12480 r12486  
    317317  }
    318318
    319   // set the javascript flags according to the current url
     319  d->m_bJScriptEnabled = d->m_settings->isJavaScriptEnabled(url.host());
    320320  d->m_bJavaEnabled = d->m_settings->isJavaEnabled(url.host());
    321321  d->m_bPluginsEnabled = d->m_settings->isPluginsEnabled(url.host());
     
    755755
    756756  clear();
    757 
    758757  partClearedInBegin();
    759 
    760   // Only do this after clearing the part, so that JavaScript can
    761   // clean up properly if it was on for the last load.
    762   d->m_bJScriptEnabled = d->m_settings->isJavaScriptEnabled(url.host());
    763758
    764759  d->m_bCleared = false;
Note: See TracChangeset for help on using the changeset viewer.