Changeset 34988 in webkit


Ignore:
Timestamp:
Jul 3, 2008 1:52:56 PM (16 years ago)
Author:
jhoneycutt@apple.com
Message:

<rdar://5983747> Safari crashes trying to load the SilverLight plugin

If a plug-in returned an error code from NPP_NewStream, we would call
NPP_DestroyStream while cleaning up the request. We now only call
NPP_DestroyStream if NPP_NewStream was successful, matching Firefox.

Reviewed by Anders.

Location:
trunk
Files:
2 added
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r34986 r34988  
     12008-07-02  Jon Honeycutt  <jhoneycutt@apple.com>
     2
     3        Test for <rdar://5983747> Safari crashes trying to load the SilverLight plugin
     4
     5        Reviewed by Anders.
     6
     7        * plugins/return-error-from-new-stream-doesnt-invoke-destroy-stream-expected.txt: Added.
     8        * plugins/return-error-from-new-stream-doesnt-invoke-destroy-stream.html: Added.
     9
    1102008-07-03  Alexey Proskuryakov  <ap@webkit.org>
    211
  • trunk/WebCore/ChangeLog

    r34987 r34988  
     12008-07-02  Jon Honeycutt  <jhoneycutt@apple.com>
     2
     3        <rdar://5983747> Safari crashes trying to load the SilverLight plugin
     4
     5        If a plug-in returned an error code from NPP_NewStream, we would call
     6        NPP_DestroyStream while cleaning up the request. We now only call
     7        NPP_DestroyStream if NPP_NewStream was successful, matching Firefox.
     8
     9        Reviewed by Anders.
     10
     11        * plugins/PluginStream.cpp:
     12        (WebCore::PluginStream::startStream): If NPP_NewStream returns an error,
     13        don't set m_streamState to StreamStarted, and return after calling
     14        cancelAndDestroyStream.
     15        (WebCore::PluginStream::destroyStream): Don't call NPP_DestroyStream if
     16        the stream didn't start successfully.
     17
    1182008-07-03  David Hyatt  <hyatt@apple.com>
    219
  • trunk/WebCore/plugins/PluginStream.cpp

    r34536 r34988  
    188188        return;
    189189       
     190    if (npErr != NPERR_NO_ERROR) {
     191        cancelAndDestroyStream(npErr);
     192        return;
     193    }
     194
    190195    m_streamState = StreamStarted;
    191 
    192     if (npErr != NPERR_NO_ERROR)
    193         cancelAndDestroyStream(npErr);
    194196
    195197    if (m_transferMode == NP_NORMAL)
     
    253255        }
    254256
    255         if (m_loader)
    256             m_loader->setDefersLoading(true);
    257         NPError npErr = m_pluginFuncs->destroystream(m_instance, &m_stream, m_reason);
    258         if (m_loader)
    259             m_loader->setDefersLoading(false);
    260         LOG_NPERROR(npErr);
     257        if (m_streamState != StreamBeforeStarted) {
     258            if (m_loader)
     259                m_loader->setDefersLoading(true);
     260
     261            NPError npErr = m_pluginFuncs->destroystream(m_instance, &m_stream, m_reason);
     262
     263            if (m_loader)
     264                m_loader->setDefersLoading(false);
     265
     266            LOG_NPERROR(npErr);
     267        }
    261268
    262269        m_stream.ndata = 0;
  • trunk/WebKitTools/ChangeLog

    r34972 r34988  
     12008-07-02  Jon Honeycutt  <jhoneycutt@apple.com>
     2
     3        Allow tests to define JavaScript to execute when NPP_DestroyStream or
     4        NPP_URLNotify is called.
     5
     6        Reviewed by Anders.
     7
     8        * DumpRenderTree/TestNetscapePlugIn.subproj/PluginObject.cpp: Add a new
     9        property, "returnErrorFromNewStream." This is to support the test for
     10        <rdar://5983747> Safari crashes trying to load the SilverLight plugin,
     11        caused by WebKit calling NPP_DestroyStream after a plug-in returns an
     12        error from NPP_NewStream.
     13        (pluginGetProperty):
     14        (pluginSetProperty):
     15        (pluginAllocate):
     16        * DumpRenderTree/TestNetscapePlugIn.subproj/PluginObject.h: Added new
     17        members, onStreamDestroy and onURLNotify.
     18        * DumpRenderTree/win/TestNetscapePlugin/main.cpp:
     19        (NPP_New): Remove initialization of onStreamLoad; this was moved to
     20        pluginAllocate. Look for new arguments onStreamDestroy and
     21        onURLNotify, and store their values.
     22        (NPP_Destroy): Free new members.
     23        (executeScript): Code moved from onStreamLoad
     24        (NPP_NewStream): If returnErrorFromNewStream has been set to true,
     25        return a generic error code. If onStreamLoad is set, execute it as
     26        JavaScript.
     27        (NPP_DestroyStream): If onStreamDestroy is set, execute it as JS.
     28        (NPP_URLNotify): Same, for onURLNotify.
     29
    1302008-07-02  Brady Eidson  <beidson@apple.com>
    231
  • trunk/WebKitTools/DumpRenderTree/TestNetscapePlugIn.subproj/PluginObject.cpp

    r33076 r34988  
    6262static bool identifiersInitialized = false;
    6363
    64 #define ID_PROPERTY_PROPERTY        0
    65 #define ID_PROPERTY_EVENT_LOGGING   1
    66 #define ID_PROPERTY_HAS_STREAM      2
    67 #define ID_PROPERTY_TEST_OBJECT     3
    68 #define ID_PROPERTY_LOG_DESTROY     4
    69 #define NUM_PROPERTY_IDENTIFIERS    5
     64#define ID_PROPERTY_PROPERTY                    0
     65#define ID_PROPERTY_EVENT_LOGGING               1
     66#define ID_PROPERTY_HAS_STREAM                  2
     67#define ID_PROPERTY_TEST_OBJECT                 3
     68#define ID_PROPERTY_LOG_DESTROY                 4
     69#define ID_PROPERTY_RETURN_ERROR_FROM_NEWSTREAM 5
     70#define NUM_PROPERTY_IDENTIFIERS                6
    7071
    7172static NPIdentifier pluginPropertyIdentifiers[NUM_PROPERTY_IDENTIFIERS];
     
    7677    "testObject",
    7778    "logDestroy",
     79    "returnErrorFromNewStream",
    7880};
    7981
     
    165167        OBJECT_TO_NPVARIANT(testObject, *result);
    166168        return true;
     169    } else if (name == pluginPropertyIdentifiers[ID_PROPERTY_RETURN_ERROR_FROM_NEWSTREAM]) {
     170        BOOLEAN_TO_NPVARIANT(plugin->returnErrorFromNewStream, *result);
     171        return true;
    167172    }
    168173    return false;
     
    177182    } else if (name == pluginPropertyIdentifiers[ID_PROPERTY_LOG_DESTROY]) {
    178183        plugin->logDestroy = NPVARIANT_TO_BOOLEAN(*variant);
     184        return true;
     185    } else if (name == pluginPropertyIdentifiers[ID_PROPERTY_RETURN_ERROR_FROM_NEWSTREAM]) {
     186        plugin->returnErrorFromNewStream = NPVARIANT_TO_BOOLEAN(*variant);
    179187        return true;
    180188    }
     
    575583    newInstance->testObject = browser->createobject(npp, getTestClass());
    576584    newInstance->eventLogging = FALSE;
     585    newInstance->onStreamLoad = 0;
     586    newInstance->onStreamDestroy = 0;
     587    newInstance->onURLNotify = 0;
    577588    newInstance->logDestroy = FALSE;
    578589    newInstance->logSetWindow = FALSE;
  • trunk/WebKitTools/DumpRenderTree/TestNetscapePlugIn.subproj/PluginObject.h

    r30520 r34988  
    3838    NPStream* stream;
    3939    char* onStreamLoad;
     40    char* onStreamDestroy;
     41    char* onURLNotify;
    4042    char* firstUrl;
    4143    char* firstHeaders;
  • trunk/WebKitTools/DumpRenderTree/win/TestNetscapePlugin/main.cpp

    r29663 r34988  
    7777    if (browser->version >= 14) {
    7878        PluginObject* obj = (PluginObject*)browser->createobject(instance, getPluginClass());
    79    
    80         obj->onStreamLoad = NULL;
    8179       
    8280        for (int16 i = 0; i < argc; i++) {
    8381            if (_stricmp(argn[i], "onstreamload") == 0 && !obj->onStreamLoad)
    8482                obj->onStreamLoad = _strdup(argv[i]);
     83            else if (_stricmp(argn[i], "onStreamDestroy") == 0 && !obj->onStreamDestroy)
     84                obj->onStreamDestroy = _strdup(argv[i]);
     85            else if (_stricmp(argn[i], "onURLNotify") == 0 && !obj->onURLNotify)
     86                obj->onURLNotify = _strdup(argv[i]);
    8587        }
    8688       
     
    9799        if (obj->onStreamLoad)
    98100            free(obj->onStreamLoad);
    99        
     101
     102        if (obj->onURLNotify)
     103            free(obj->onURLNotify);
     104
     105        if (obj->onStreamDestroy)
     106            free(obj->onStreamDestroy);
     107
    100108        if (obj->logDestroy)
    101109            printf("PLUGIN: NPP_Destroy\n");
     
    111119}
    112120
     121static void executeScript(const PluginObject* obj, const char* script)
     122{
     123    NPObject *windowScriptObject;
     124    browser->getvalue(obj->npp, NPNVWindowNPObject, &windowScriptObject);
     125
     126    NPString npScript;
     127    npScript.UTF8Characters = script;
     128    npScript.UTF8Length = strlen(script);
     129
     130    NPVariant browserResult;
     131    browser->evaluate(obj->npp, windowScriptObject, &npScript, &browserResult);
     132    browser->releasevariantvalue(&browserResult);
     133}
     134
    113135NPError NPP_NewStream(NPP instance, NPMIMEType type, NPStream *stream, NPBool seekable, uint16 *stype)
    114136{
    115137    PluginObject* obj = (PluginObject*)instance->pdata;
     138
     139    if (obj->returnErrorFromNewStream)
     140        return NPERR_GENERIC_ERROR;
     141
    116142    obj->stream = stream;
    117143    *stype = NP_ASFILEONLY;
    118144
    119     if (obj->onStreamLoad) {
    120         NPObject *windowScriptObject;
    121         browser->getvalue(obj->npp, NPNVWindowNPObject, &windowScriptObject);
    122                
    123         NPString script;
    124         script.UTF8Characters = obj->onStreamLoad;
    125         script.UTF8Length = strlen(obj->onStreamLoad);
    126        
    127         NPVariant browserResult;
    128         browser->evaluate(obj->npp, windowScriptObject, &script, &browserResult);
    129         browser->releasevariantvalue(&browserResult);
    130     }
     145    if (obj->onStreamLoad)
     146        executeScript(obj, obj->onStreamLoad);
    131147   
    132148    return NPERR_NO_ERROR;
     
    135151NPError NPP_DestroyStream(NPP instance, NPStream *stream, NPReason reason)
    136152{
     153    PluginObject* obj = (PluginObject*)instance->pdata;
     154
     155    if (obj->onStreamDestroy)
     156        executeScript(obj, obj->onStreamDestroy);
     157
    137158    return NPERR_NO_ERROR;
    138159}
     
    169190{
    170191    PluginObject *obj = (PluginObject*)instance->pdata;
     192
     193    if (obj->onURLNotify)
     194        executeScript(obj, obj->onURLNotify);
    171195       
    172196    handleCallback(obj, url, reason, notifyData);
Note: See TracChangeset for help on using the changeset viewer.