Commit 4d69cd1f authored by aroben@apple.com's avatar aroben@apple.com

Allow blocking of JS event handlers/javascript: URIs per-Frame

        Part of Bug 17133: Should support pausing JavaScript execution without
        hanging the process

        <http://bugs.webkit.org/show_bug.cgi?id=17133>
        <rdar://problem/5719551>

        Two new methods are added to KJSProxy: setPaused and isPaused. When
        setPaused(true) is called, JS event handlers are blocked and
        javascript: URIs will not be evaluated.

        Reviewed by Tim Hatcher.

        * bindings/js/kjs_events.cpp:
        (WebCore::JSAbstractEventListener::handleEvent):
          - Removed some old KJS_DEBUGGER code
          - Don't run the handler if the KJSProxy is paused.
        * bindings/js/kjs_proxy.cpp:
        (WebCore::KJSProxy::KJSProxy): Initialize new member.
        * bindings/js/kjs_proxy.h: Added new methods.
        * loader/FrameLoader.cpp:
        (WebCore::FrameLoader::executeScript): Don't execute the script if the
        KJSProxy is paused.


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@31197 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent 8ff56d59
2008-03-20 Adam Roben <aroben@apple.com>
Allow blocking of JS event handlers/javascript: URIs per-Frame
Part of Bug 17133: Should support pausing JavaScript execution without
hanging the process
<http://bugs.webkit.org/show_bug.cgi?id=17133>
<rdar://problem/5719551>
Two new methods are added to KJSProxy: setPaused and isPaused. When
setPaused(true) is called, JS event handlers are blocked and
javascript: URIs will not be evaluated.
Reviewed by Tim Hatcher.
* bindings/js/kjs_events.cpp:
(WebCore::JSAbstractEventListener::handleEvent):
- Removed some old KJS_DEBUGGER code
- Don't run the handler if the KJSProxy is paused.
* bindings/js/kjs_proxy.cpp:
(WebCore::KJSProxy::KJSProxy): Initialize new member.
* bindings/js/kjs_proxy.h: Added new methods.
* loader/FrameLoader.cpp:
(WebCore::FrameLoader::executeScript): Don't execute the script if the
KJSProxy is paused.
2008-03-20 Jon Honeycutt <jhoneycutt@apple.com>
Reviewed by Anders.
......@@ -48,11 +48,6 @@ JSAbstractEventListener::JSAbstractEventListener(bool html)
void JSAbstractEventListener::handleEvent(Event* ele, bool isWindowEvent)
{
#ifdef KJS_DEBUGGER
if (KJSDebugWin::instance() && KJSDebugWin::instance()->inSession())
return;
#endif
Event* event = ele;
JSObject* listener = listenerObj();
......@@ -67,12 +62,13 @@ void JSAbstractEventListener::handleEvent(Event* ele, bool isWindowEvent)
Frame* frame = window->impl()->frame();
if (!frame)
return;
if (!frame->scriptProxy()->isEnabled())
KJSProxy* scriptProxy = frame->scriptProxy();
if (!scriptProxy->isEnabled() || scriptProxy->isPaused())
return;
JSLock lock;
JSGlobalObject* globalObject = frame->scriptProxy()->globalObject();
JSGlobalObject* globalObject = scriptProxy->globalObject();
ExecState* exec = globalObject->globalExec();
JSValue* handleEventFuncValue = listener->get(exec, "handleEvent");
......
......@@ -49,6 +49,7 @@ KJSProxy::KJSProxy(Frame* frame)
, m_handlerLineno(0)
, m_processingTimerCallback(0)
, m_processingInlineCode(0)
, m_paused(false)
{
}
......
......@@ -70,6 +70,9 @@ public:
void attachDebugger(KJS::Debugger*);
void setPaused(bool b) { m_paused = b; }
bool isPaused() const { return m_paused; }
private:
void initScriptIfNeeded()
{
......@@ -84,6 +87,7 @@ private:
bool m_processingTimerCallback;
bool m_processingInlineCode;
bool m_paused;
};
}
......
......@@ -756,7 +756,9 @@ JSValue* FrameLoader::executeScript(const String& script, bool forceUserGesture)
JSValue* FrameLoader::executeScript(const String& url, int baseLine, const String& script)
{
if (!m_frame->scriptProxy()->isEnabled())
KJSProxy* scriptProxy = m_frame->scriptProxy();
if (!scriptProxy->isEnabled() || scriptProxy->isPaused())
return 0;
bool wasRunningScript = m_isRunningScript;
......
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