Changeset 64449 in webkit


Ignore:
Timestamp:
Aug 1, 2010 4:05:55 PM (14 years ago)
Author:
andersca@apple.com
Message:

Implement NPN_SetException
https://bugs.webkit.org/show_bug.cgi?id=43320

Reviewed by Sam Weinig.

  • WebProcess/Plugins/JSNPObject.cpp:

(WebKit::JSNPObject::callConstructor):
(WebKit::JSNPObject::put):
(WebKit::JSNPObject::getOwnPropertyNames):
(WebKit::JSNPObject::propertyGetter):
Call NPRuntimeObjectMap::moveGlobalExceptionToExecState.

  • WebProcess/Plugins/NPRuntimeObjectMap.cpp:

(WebKit::globalExceptionString):
Add static global.

(WebKit::NPRuntimeObjectMap::setGlobalException):
Set the global exception string.

(WebKit::NPRuntimeObjectMap::moveGlobalExceptionToExecState):
Create an error from the exception string.

  • WebProcess/Plugins/NPRuntimeObjectMap.h:
  • WebProcess/Plugins/Netscape/NetscapeBrowserFuncs.cpp:

(WebKit::NPN_SetException):
Call NetscapePlugin::setException.

  • WebProcess/Plugins/Netscape/NetscapePlugin.cpp:

(WebKit::NetscapePlugin::setException):
Call NPRuntimeObjectMap::setGlobalException.

Location:
trunk/WebKit2
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/WebKit2/ChangeLog

    r64448 r64449  
     12010-08-01  Anders Carlsson  <andersca@apple.com>
     2
     3        Reviewed by Sam Weinig.
     4
     5        Implement NPN_SetException
     6        https://bugs.webkit.org/show_bug.cgi?id=43320
     7
     8        * WebProcess/Plugins/JSNPObject.cpp:
     9        (WebKit::JSNPObject::callConstructor):
     10        (WebKit::JSNPObject::put):
     11        (WebKit::JSNPObject::getOwnPropertyNames):
     12        (WebKit::JSNPObject::propertyGetter):
     13        Call NPRuntimeObjectMap::moveGlobalExceptionToExecState.
     14
     15        * WebProcess/Plugins/NPRuntimeObjectMap.cpp:
     16        (WebKit::globalExceptionString):
     17        Add static global.
     18
     19        (WebKit::NPRuntimeObjectMap::setGlobalException):
     20        Set the global exception string.
     21
     22        (WebKit::NPRuntimeObjectMap::moveGlobalExceptionToExecState):
     23        Create an error from the exception string.
     24
     25        * WebProcess/Plugins/NPRuntimeObjectMap.h:
     26        * WebProcess/Plugins/Netscape/NetscapeBrowserFuncs.cpp:
     27        (WebKit::NPN_SetException):
     28        Call NetscapePlugin::setException.
     29
     30        * WebProcess/Plugins/Netscape/NetscapePlugin.cpp:
     31        (WebKit::NetscapePlugin::setException):
     32        Call NPRuntimeObjectMap::setGlobalException.
     33
    1342010-08-01  Sam Weinig  <sam@webkit.org>
    235
  • trunk/WebKit2/WebProcess/Plugins/JSNPObject.cpp

    r64365 r64449  
    152152        JSLock::DropAllLocks dropAllLocks(SilenceAssertionsOnly);
    153153        returnValue = m_npObject->_class->construct(m_npObject, arguments.data(), argumentCount, &result);
    154 
    155         // FIXME: Handle construct setting an exception.
     154        NPRuntimeObjectMap::moveGlobalExceptionToExecState(exec);
     155       
    156156        // FIXME: Find out what happens if calling construct causes the plug-in to go away.
    157157    }
     
    274274        m_npObject->_class->setProperty(m_npObject, npIdentifier, &variant);
    275275
    276         // FIXME: Handle setProperty setting an exception.
     276        NPRuntimeObjectMap::moveGlobalExceptionToExecState(exec);
     277
    277278        // FIXME: Find out what happens if calling setProperty causes the plug-in to go away.
    278279        // FIXME: Should we throw an exception if setProperty returns false?
     
    298299        JSLock::DropAllLocks dropAllLocks(SilenceAssertionsOnly);
    299300
    300         // FIXME: Handle enumerate setting an exception.
    301301        // FIXME: Find out what happens if calling enumerate causes the plug-in to go away.
    302302        // FIXME: Should we throw an exception if enumerate returns false?
    303303        if (!m_npObject->_class->enumerate(m_npObject, &identifiers, &identifierCount))
    304304            return;
     305
     306        NPRuntimeObjectMap::moveGlobalExceptionToExecState(exec);
    305307    }
    306308
     
    343345        returnValue = thisObj->m_npObject->_class->getProperty(thisObj->m_npObject, npIdentifier, &result);
    344346       
    345         // FIXME: Handle getProperty setting an exception.
     347        NPRuntimeObjectMap::moveGlobalExceptionToExecState(exec);
     348
    346349        // FIXME: Find out what happens if calling getProperty causes the plug-in to go away.
    347350    }
  • trunk/WebKit2/WebProcess/Plugins/NPRuntimeObjectMap.cpp

    r64447 r64449  
    3131#include "NotImplemented.h"
    3232#include "PluginView.h"
     33#include <JavaScriptCore/Error.h>
    3334#include <JavaScriptCore/JSLock.h>
    3435#include <JavaScriptCore/SourceCode.h>
     
    235236}
    236237
     238static String& globalExceptionString()
     239{
     240    DEFINE_STATIC_LOCAL(String, exceptionString, ());
     241    return exceptionString;
     242}
     243
     244void NPRuntimeObjectMap::setGlobalException(const String& exceptionString)
     245{
     246    globalExceptionString() = exceptionString;
     247}
     248   
     249void NPRuntimeObjectMap::moveGlobalExceptionToExecState(ExecState* exec)
     250{
     251    if (globalExceptionString().isNull())
     252        return;
     253
     254    {
     255        JSLock lock(SilenceAssertionsOnly);
     256        throwError(exec, createError(exec, stringToUString(globalExceptionString())));
     257    }
     258   
     259    globalExceptionString() = String();
     260}
     261
    237262} // namespace WebKit
  • trunk/WebKit2/WebProcess/Plugins/NPRuntimeObjectMap.h

    r64377 r64449  
    6666    JSC::JSValue convertNPVariantToJSValue(JSC::ExecState*, JSC::JSGlobalObject*, const NPVariant&);
    6767
    68     bool evaluate(NPObject*, const WebCore::String&scriptString, NPVariant* result);
     68    bool evaluate(NPObject*, const WebCore::String& scriptString, NPVariant* result);
    6969
    7070    // Called when the plug-in is destroyed. Will invalidate all the NPObjects.
     
    7373    JSC::JSGlobalObject* globalObject() const;
    7474    JSC::ExecState* globalExec() const;
     75
     76    static void setGlobalException(const WebCore::String& exceptionString);
     77    static void moveGlobalExceptionToExecState(JSC::ExecState*);
    7578
    7679private:
  • trunk/WebKit2/WebProcess/Plugins/Netscape/NetscapeBrowserFuncs.cpp

    r64447 r64449  
    620620}
    621621
    622 static void NPN_SetException(NPObject* npobj, const NPUTF8* message)
    623 {
    624     notImplemented();
     622static void NPN_SetException(NPObject*, const NPUTF8* message)
     623{
     624    NetscapePlugin::setException(message);
    625625}
    626626
  • trunk/WebKit2/WebProcess/Plugins/Netscape/NetscapePlugin.cpp

    r64377 r64449  
    2626#include "NetscapePlugin.h"
    2727
     28#include "NPRuntimeObjectMap.h"
    2829#include "NetscapePluginStream.h"
    2930#include "PluginController.h"
     
    149150}
    150151
     152void NetscapePlugin::setException(const String& exceptionString)
     153{
     154    // FIXME: If the plug-in is running in its own process, this needs to send a CoreIPC message instead of
     155    // calling the runtime object map directly.
     156    NPRuntimeObjectMap::setGlobalException(exceptionString);
     157}
     158
    151159bool NetscapePlugin::evaluate(NPObject* npObject, const String& scriptString, NPVariant* result)
    152160{
  • trunk/WebKit2/WebProcess/Plugins/Netscape/NetscapePlugin.h

    r64377 r64449  
    6161    NPError destroyStream(NPStream*, NPReason);
    6262    void setStatusbarText(const WebCore::String&);
     63    static void setException(const WebCore::String&);
    6364    bool evaluate(NPObject*, const WebCore::String&scriptString, NPVariant* result);
    6465
Note: See TracChangeset for help on using the changeset viewer.