Changeset 62739 in webkit


Ignore:
Timestamp:
Jul 7, 2010 6:47:59 PM (14 years ago)
Author:
andersca@apple.com
Message:

Test that we call NPP_DestroyStream if a plug-in returns -1 from its NPP_Write function
https://bugs.webkit.org/show_bug.cgi?id=41821

Reviewed by Sam Weinig.

WebKitTools:

  • DumpRenderTree/TestNetscapePlugIn/PluginObject.cpp:

(pluginGetProperty):
(pluginSetProperty):
(pluginAllocate):

  • DumpRenderTree/TestNetscapePlugIn/PluginObject.h:

Add and initialize the returnNegativeOneFromWrite property.

  • DumpRenderTree/TestNetscapePlugIn/main.cpp:

(NPP_NewStream):
Set the stream type to NP_NORMAL so we'll get write callbacks.

(NPP_DestroyStream):
Treat the onstreamdestroy attribute as a function name and not a string.

(NPP_WriteReady):
Have this return a nonzero value.

(NPP_Write):
If returnNegativeOneFromWrite is true return -1.

LayoutTests:

  • plugins/return-error-from-new-stream-doesnt-invoke-destroy-stream.html:

Update for changes to onstreamdestroy.

  • plugins/return-negative-one-from-write-expected.txt: Added.
  • plugins/return-negative-one-from-write.html: Added.

Add new test.

Location:
trunk
Files:
1 added
6 edited
1 copied

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r62735 r62739  
     12010-07-07  Anders Carlsson  <andersca@apple.com>
     2
     3        Reviewed by Sam Weinig.
     4
     5        Test that we call NPP_DestroyStream if a plug-in returns -1 from its NPP_Write function
     6        https://bugs.webkit.org/show_bug.cgi?id=41821
     7
     8        * plugins/return-error-from-new-stream-doesnt-invoke-destroy-stream.html:
     9        Update for changes to onstreamdestroy.
     10
     11        * plugins/return-negative-one-from-write-expected.txt: Added.
     12        * plugins/return-negative-one-from-write.html: Added.
     13        Add new test.
     14
    1152010-07-07  Chris Fleizach  <cfleizach@apple.com>
    216
  • trunk/LayoutTests/plugins/return-error-from-new-stream-doesnt-invoke-destroy-stream.html

    r34988 r62739  
    3939            type="application/x-webkit-test-netscape"
    4040            onStreamLoad="streamStarted()"
    41             onStreamDestroy="streamDestroyed()"
     41            onStreamDestroy="streamDestroyed"
    4242            onURLNotify="requestCompleted()"
    4343            id="plugin">
  • trunk/LayoutTests/plugins/return-negative-one-from-write.html

    r62738 r62739  
    99
    1010        <script>
     11            var newStreamCalled = false;
    1112            var destroyStreamCalled = false;
    1213
     
    2223
    2324            function streamStarted() {
    24                 testFailed("TestNetscapePlugin should have returned an error from NewStream.");
     25                shouldBeFalse('newStreamCalled');
     26                newStreamCalled = true;
    2527            }
    2628
    27             function streamDestroyed() { destroyStreamCalled = true; }
     29            function streamDestroyed(reason) {
     30                window.reason = reason;
    2831
    29             function requestCompleted() {
    30                 shouldBeFalse("destroyStreamCalled");
     32                shouldBeTrue('newStreamCalled')
     33                shouldBe('reason', '1');
    3134
    3235                debug('<br><span class="pass">TEST COMPLETE</span>');
     
    3942            type="application/x-webkit-test-netscape"
    4043            onStreamLoad="streamStarted()"
    41             onStreamDestroy="streamDestroyed()"
    42             onURLNotify="requestCompleted()"
     44            onStreamDestroy="streamDestroyed"
    4345            id="plugin">
    4446    </body>
    4547    <script>
    46         description("This tests that NPP_DestroyStream is not called if a plug-in returns an error from its NPP_NewStream callback.");
     48        description("This tests that NPP_DestroyStream is called with NPRES_NETWORK_ERR not called if a plug-in returns -1 its NPP_Write callback.");
    4749
    4850        var plugin = document.getElementById("plugin");
    4951
    50         plugin.returnErrorFromNewStream = true;
    51         shouldBeTrue("plugin.returnErrorFromNewStream");
     52        plugin.returnNegativeOneFromWrite = true;
     53        shouldBeTrue("plugin.returnNegativeOneFromWrite");
    5254
    53         plugin.getURLNotify("data:,", null, "callback");
     55        plugin.getURLNotify("data:text/html,Test", null, "callback");
    5456    </script>
    5557</html>
  • trunk/WebKitTools/ChangeLog

    r62737 r62739  
     12010-07-07  Anders Carlsson  <andersca@apple.com>
     2
     3        Reviewed by Sam Weinig.
     4
     5        Test that we call NPP_DestroyStream if a plug-in returns -1 from its NPP_Write function
     6        https://bugs.webkit.org/show_bug.cgi?id=41821
     7
     8        * DumpRenderTree/TestNetscapePlugIn/PluginObject.cpp:
     9        (pluginGetProperty):
     10        (pluginSetProperty):
     11        (pluginAllocate):
     12        * DumpRenderTree/TestNetscapePlugIn/PluginObject.h:
     13        Add and initialize the returnNegativeOneFromWrite property.
     14
     15        * DumpRenderTree/TestNetscapePlugIn/main.cpp:
     16        (NPP_NewStream):
     17        Set the stream type to NP_NORMAL so we'll get write callbacks.
     18
     19        (NPP_DestroyStream):
     20        Treat the onstreamdestroy attribute as a function name and not a string.
     21
     22        (NPP_WriteReady):
     23        Have this return a nonzero value.
     24
     25        (NPP_Write):
     26        If returnNegativeOneFromWrite is true return -1.
     27
    1282010-07-07  Kevin Ollivier  <kevino@theolliviers.com>
    229
  • trunk/WebKitTools/DumpRenderTree/TestNetscapePlugIn/PluginObject.cpp

    r62685 r62739  
    133133    ID_PROPERTY_LOG_DESTROY,
    134134    ID_PROPERTY_RETURN_ERROR_FROM_NEWSTREAM,
     135    ID_PROPERTY_RETURN_NEGATIVE_ONE_FROM_WRITE,
    135136    ID_PROPERTY_PRIVATE_BROWSING_ENABLED,
    136137    ID_PROPERTY_CACHED_PRIVATE_BROWSING_ENABLED,
     
    148149    "logDestroy",
    149150    "returnErrorFromNewStream",
     151    "returnNegativeOneFromWrite",
    150152    "privateBrowsingEnabled",
    151153    "cachedPrivateBrowsingEnabled",
     
    283285        BOOLEAN_TO_NPVARIANT(plugin->returnErrorFromNewStream, *result);
    284286        return true;
     287    } else if (name == pluginPropertyIdentifiers[ID_PROPERTY_RETURN_NEGATIVE_ONE_FROM_WRITE]) {
     288        BOOLEAN_TO_NPVARIANT(plugin->returnNegativeOneFromWrite, *result);
     289        return true;
    285290    } else if (name == pluginPropertyIdentifiers[ID_PROPERTY_PRIVATE_BROWSING_ENABLED]) {
    286291        NPBool privateBrowsingEnabled = FALSE;
     
    317322    } else if (name == pluginPropertyIdentifiers[ID_PROPERTY_RETURN_ERROR_FROM_NEWSTREAM]) {
    318323        plugin->returnErrorFromNewStream = NPVARIANT_TO_BOOLEAN(*variant);
     324        return true;
     325    } else if (name == pluginPropertyIdentifiers[ID_PROPERTY_RETURN_NEGATIVE_ONE_FROM_WRITE]) {
     326        plugin->returnNegativeOneFromWrite = NPVARIANT_TO_BOOLEAN(*variant);
    319327        return true;
    320328    } else if (name == pluginPropertyIdentifiers[ID_PROPERTY_THROW_EXCEPTION_PROPERTY]) {
     
    968976    newInstance->logSetWindow = FALSE;
    969977    newInstance->returnErrorFromNewStream = FALSE;
     978    newInstance->returnNegativeOneFromWrite = FALSE;
    970979    newInstance->stream = 0;
    971980
  • trunk/WebKitTools/DumpRenderTree/TestNetscapePlugIn/PluginObject.h

    r62685 r62739  
    3535    NPBool logSetWindow;
    3636    NPBool logDestroy;
     37    NPBool returnNegativeOneFromWrite;
    3738    NPBool returnErrorFromNewStream;
    3839    NPBool cachedPrivateBrowsingMode;
  • trunk/WebKitTools/DumpRenderTree/TestNetscapePlugIn/main.cpp

    r62700 r62739  
    240240    PluginObject* obj = static_cast<PluginObject*>(instance->pdata);
    241241    obj->stream = stream;
    242     *stype = NP_ASFILEONLY;
     242    *stype = NP_NORMAL;
    243243
    244244    if (obj->returnErrorFromNewStream)
     
    258258    PluginObject* obj = (PluginObject*)instance->pdata;
    259259
    260     if (obj->onStreamDestroy)
    261         executeScript(obj, obj->onStreamDestroy);
     260    if (obj->onStreamDestroy) {
     261        NPObject* windowObject = 0;
     262        NPError error = browser->getvalue(instance, NPNVWindowNPObject, &windowObject);
     263       
     264        if (error == NPERR_NO_ERROR) {
     265            NPVariant onStreamDestroyVariant;
     266            if (browser->getproperty(instance, windowObject, browser->getstringidentifier(obj->onStreamDestroy), &onStreamDestroyVariant)) {
     267                if (NPVARIANT_IS_OBJECT(onStreamDestroyVariant)) {
     268                    NPObject* onStreamDestroyFunction = NPVARIANT_TO_OBJECT(onStreamDestroyVariant);
     269
     270                    NPVariant reasonVariant;
     271                    INT32_TO_NPVARIANT(reason, reasonVariant);
     272
     273                    NPVariant result;
     274                    browser->invokeDefault(instance, onStreamDestroyFunction, &reasonVariant, 1, &result);
     275                    browser->releasevariantvalue(&result);
     276                }
     277                browser->releasevariantvalue(&onStreamDestroyVariant);
     278            }
     279            browser->releaseobject(windowObject);
     280        }
     281    }
    262282
    263283    if (obj->testDocumentOpenInDestroyStream) {
     
    271291int32_t NPP_WriteReady(NPP instance, NPStream *stream)
    272292{
    273     return 0;
     293    return 4096;
    274294}
    275295
    276296int32_t NPP_Write(NPP instance, NPStream *stream, int32_t offset, int32_t len, void *buffer)
    277297{
    278     return 0;
     298    PluginObject* obj = (PluginObject*)instance->pdata;
     299
     300    if (obj->returnNegativeOneFromWrite)
     301        return -1;
     302
     303    return len;
    279304}
    280305
Note: See TracChangeset for help on using the changeset viewer.