LayoutTests:
authorggaren <ggaren@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 29 Mar 2007 23:26:30 +0000 (23:26 +0000)
committerggaren <ggaren@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 29 Mar 2007 23:26:30 +0000 (23:26 +0000)
        Reviewed by Beth Dakin.

        Layout test for <rdar://problem/5091330> REGRESSION: Repro crash in
        -[WebBaseNetscapePluginView(WebNPPCallbacks) destroyStream:reason:]
        navigating away from page with DivX movie plug-in (13203)

        * plugins/destroy-stream-twice-expected.txt: Added.
        * plugins/destroy-stream-twice.html: Added.

WebKit:

        Reviewed by Beth Dakin, reviewed by Maciej Stachowiak.

        Layout test for <rdar://problem/5091330> REGRESSION: Repro crash in
        -[WebBaseNetscapePluginView(WebNPPCallbacks) destroyStream:reason:]
        navigating away from page with DivX movie plug-in (13203)

        Changed LOG_ERROR to LOG so the layout test doesn't produce console spew
        every time you run it.

        * Plugins/WebBaseNetscapePluginView.mm:
        (-[WebBaseNetscapePluginView destroyStream:reason:]):

WebKitTools:

        Reviewed by Beth Dakin.

        Layout test for <rdar://problem/5091330> REGRESSION: Repro crash in
        -[WebBaseNetscapePluginView(WebNPPCallbacks) destroyStream:reason:]
        navigating away from page with DivX movie plug-in (13203)

        Added hasStream property and destroyStream function, used by layout test.

        * DumpRenderTree/TestNetscapePlugIn.subproj/PluginObject.c:
        (pluginGetProperty):
        (pluginInvoke):
        (pluginAllocate):
        * DumpRenderTree/TestNetscapePlugIn.subproj/PluginObject.h:
        * DumpRenderTree/TestNetscapePlugIn.subproj/main.c:
        (NPP_NewStream):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@20597 268f45cc-cd09-0410-ab3c-d52691b4dbfc

LayoutTests/ChangeLog
LayoutTests/plugins/destroy-stream-twice-expected.txt [new file with mode: 0644]
LayoutTests/plugins/destroy-stream-twice.html [new file with mode: 0644]
WebKit/ChangeLog
WebKit/Plugins/WebBaseNetscapePluginView.mm
WebKitTools/ChangeLog
WebKitTools/DumpRenderTree/TestNetscapePlugIn.subproj/PluginObject.c
WebKitTools/DumpRenderTree/TestNetscapePlugIn.subproj/PluginObject.h
WebKitTools/DumpRenderTree/TestNetscapePlugIn.subproj/main.c

index 934da1398e8a7d11bab6dbca0b47f04a613b4c3d..b5042b05bf77e8f01c923c91198bbc3246a6e535 100644 (file)
@@ -1,3 +1,14 @@
+2007-03-29  Geoffrey Garen  <ggaren@apple.com>
+
+        Reviewed by Beth Dakin.
+        
+        Layout test for <rdar://problem/5091330> REGRESSION: Repro crash in 
+        -[WebBaseNetscapePluginView(WebNPPCallbacks) destroyStream:reason:] 
+        navigating away from page with DivX movie plug-in (13203)
+
+        * plugins/destroy-stream-twice-expected.txt: Added.
+        * plugins/destroy-stream-twice.html: Added.
+
 2007-03-28  Justin Garcia  <justin.garcia@apple.com>
 
         Reviewed by john
diff --git a/LayoutTests/plugins/destroy-stream-twice-expected.txt b/LayoutTests/plugins/destroy-stream-twice-expected.txt
new file mode 100644 (file)
index 0000000..e19a5ac
--- /dev/null
@@ -0,0 +1,15 @@
+Test for http://bugs.webkit.org/show_bug.cgi?id=13203: REGRESSION: Repro crash in -[WebBaseNetscapePluginView(WebNPPCallbacks) destroyStream:reason:] navigating away from page with DivX movie plug-in
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+destroyStream() returns zero to indicate success, or a non-zero error code to indicate failure
+PASS document.getElementById('plugin').hasStream is true
+PASS document.getElementById('plugin').destroyStream() is 2
+PASS document.getElementById('plugin').destroyStream() is 2
+PASS: You didn't crash.
+
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
diff --git a/LayoutTests/plugins/destroy-stream-twice.html b/LayoutTests/plugins/destroy-stream-twice.html
new file mode 100644 (file)
index 0000000..6a20e94
--- /dev/null
@@ -0,0 +1,45 @@
+<head>
+<link rel="stylesheet" href="../fast/js/resources/js-test-style.css">
+<script src="../fast/js/resources/js-test-pre.js"></script>
+</head>
+<body>
+<p id="description"></p>
+<div id="console"></div>
+<embed id="plugin" 
+       type="application/x-webkit-test-netscape"
+       src="data:text/plain,"
+       style="width:0; height:0">
+</embed>
+
+<script>
+description("Test for http://bugs.webkit.org/show_bug.cgi?id=13203: REGRESSION: Repro crash in -[WebBaseNetscapePluginView(WebNPPCallbacks) destroyStream:reason:] navigating away from page with DivX movie plug-in");
+
+function runTest()
+{
+    debug("destroyStream() returns zero to indicate success, or a non-zero error code to indicate failure");
+
+    shouldBe("document.getElementById('plugin').hasStream", "true");
+    shouldBe("document.getElementById('plugin').destroyStream()", "2"); // we expect to fail because the stream should already have completed loading and destroyed itself
+    shouldBe("document.getElementById('plugin').destroyStream()", "2"); // try again, just for good measure
+
+    debug("PASS: You didn't crash.\n");
+
+    shouldBeTrue("successfullyParsed");
+    debug('<br><span class="pass">TEST COMPLETE</span>');
+    layoutTestController.notifyDone();
+}
+
+function main() 
+{
+    if (!window.layoutTestController) {
+        debug("This test can only run from within DumpRenderTree because it requires TestNetscapePlugin.\n");
+        return;
+    }
+
+    layoutTestController.waitUntilDone();
+    setTimeout(runTest, 5); // FIXME: Don't know how to wait until a plug-in stream has loaded.
+}
+main();
+
+successfullyParsed = true;
+</script>
index c36905a0a96c5afdd48a6c413a2571775480bef1..66b780be2c21f83ccbd0665d46e143151a46fc3f 100644 (file)
@@ -1,3 +1,17 @@
+2007-03-29  Geoffrey Garen  <ggaren@apple.com>
+
+        Reviewed by Beth Dakin, reviewed by Maciej Stachowiak.
+        
+        Layout test for <rdar://problem/5091330> REGRESSION: Repro crash in 
+        -[WebBaseNetscapePluginView(WebNPPCallbacks) destroyStream:reason:] 
+        navigating away from page with DivX movie plug-in (13203)
+        
+        Changed LOG_ERROR to LOG so the layout test doesn't produce console spew
+        every time you run it.
+
+        * Plugins/WebBaseNetscapePluginView.mm:
+        (-[WebBaseNetscapePluginView destroyStream:reason:]):
+
 2007-03-29  Beth Dakin  <bdakin@apple.com>
 
         Reviewed by Brady.
index c25547227d615f4772fd0e0b54ceef7d0f2f4cff..7d81ea39c9685fbcbc7a7c218acde1261f852688 100644 (file)
@@ -2322,7 +2322,7 @@ static OSStatus TSMEventHandler(EventHandlerCallRef inHandlerRef, EventRef inEve
     // belongs to the plug-in that provided it, which fixes a crash in the DivX 
     // plug-in: <rdar://problem/5093862> | http://bugs.webkit.org/show_bug.cgi?id=13203
     if (!stream || [WebBaseNetscapePluginStream ownerForStream:browserStream] != plugin) {
-        LOG_ERROR("Invalid NPStream passed to NPN_DestroyStream: %p\n", stream);
+        LOG(Plugins, "Invalid NPStream passed to NPN_DestroyStream: %p", stream);
         return NPERR_INVALID_INSTANCE_ERROR;
     }
     [browserStream cancelLoadAndDestroyStreamWithError:[browserStream errorForReason:reason]];
index 50fd261f9f7fdb442747ff97f056c91cd734903e..b44c967e31898546710d6209e2070a83f36c5693 100644 (file)
@@ -1,3 +1,21 @@
+2007-03-29  Geoffrey Garen  <ggaren@apple.com>
+
+        Reviewed by Beth Dakin.
+        
+        Layout test for <rdar://problem/5091330> REGRESSION: Repro crash in 
+        -[WebBaseNetscapePluginView(WebNPPCallbacks) destroyStream:reason:] 
+        navigating away from page with DivX movie plug-in (13203)
+        
+        Added hasStream property and destroyStream function, used by layout test.
+
+        * DumpRenderTree/TestNetscapePlugIn.subproj/PluginObject.c:
+        (pluginGetProperty):
+        (pluginInvoke):
+        (pluginAllocate):
+        * DumpRenderTree/TestNetscapePlugIn.subproj/PluginObject.h:
+        * DumpRenderTree/TestNetscapePlugIn.subproj/main.c:
+        (NPP_NewStream):
+
 2007-03-27  Anders Carlsson  <acarlsson@apple.com>
 
         Reviewed by Geoff.
index 38843004a8006872b1d925880685c7bd5b3b89b8..df3340e0a702de64cccacd11ab3fe96435a19347 100644 (file)
@@ -67,12 +67,14 @@ static bool identifiersInitialized = false;
 
 #define ID_PROPERTY_PROPERTY        0
 #define ID_PROPERTY_EVENT_LOGGING   1
-#define NUM_PROPERTY_IDENTIFIERS    2
+#define ID_PROPERTY_HAS_STREAM      2
+#define NUM_PROPERTY_IDENTIFIERS    3
 
 static NPIdentifier pluginPropertyIdentifiers[NUM_PROPERTY_IDENTIFIERS];
 static const NPUTF8 *pluginPropertyIdentifierNames[NUM_PROPERTY_IDENTIFIERS] = {
     "property",
-    "eventLoggingEnabled"
+    "eventLoggingEnabled",
+    "hasStream"
 };
 
 #define ID_TEST_CALLBACK_METHOD     0
@@ -81,7 +83,8 @@ static const NPUTF8 *pluginPropertyIdentifierNames[NUM_PROPERTY_IDENTIFIERS] = {
 #define ID_TEST_DOM_ACCESS          3
 #define ID_TEST_GET_URL_NOTIFY      4
 #define ID_TEST_INVOKE_DEFAULT      5
-#define NUM_METHOD_IDENTIFIERS      6
+#define ID_DESTROY_STREAM           6
+#define NUM_METHOD_IDENTIFIERS      7
 
 static NPIdentifier pluginMethodIdentifiers[NUM_METHOD_IDENTIFIERS];
 static const NPUTF8 *pluginMethodIdentifierNames[NUM_METHOD_IDENTIFIERS] = {
@@ -90,7 +93,8 @@ static const NPUTF8 *pluginMethodIdentifierNames[NUM_METHOD_IDENTIFIERS] = {
     "removeDefaultMethod",
     "testDOMAccess",
     "getURLNotify",
-    "testInvokeDefault"
+    "testInvokeDefault",
+    "destroyStream"
 };
 
 static NPUTF8* createCStringFromNPVariant(const NPVariant *variant)
@@ -132,6 +136,9 @@ static bool pluginGetProperty(NPObject *obj, NPIdentifier name, NPVariant *varia
     } else if (name == pluginPropertyIdentifiers[ID_PROPERTY_EVENT_LOGGING]) {
         BOOLEAN_TO_NPVARIANT(((PluginObject *)obj)->eventLogging, *variant);
         return true;
+    } else if (name == pluginPropertyIdentifiers[ID_PROPERTY_HAS_STREAM]) {
+        BOOLEAN_TO_NPVARIANT(((PluginObject *)obj)->stream != 0, *variant);
+        return true;
     }
     return false;
 }
@@ -242,7 +249,12 @@ static bool pluginInvoke(NPObject *header, NPIdentifier name, const NPVariant *a
         
         BOOLEAN_TO_NPVARIANT(retval, *result);
         return true;        
-    }
+    } else if (name == pluginMethodIdentifiers[ID_DESTROY_STREAM]) {
+        assert(obj->stream);
+        NPError npError = browser->destroystream(obj->npp, obj->stream, NPRES_USER_BREAK);
+        INT32_TO_NPVARIANT(npError, *result);
+        return true;        
+    } 
 
     return false;
 }
@@ -267,8 +279,8 @@ static NPObject *pluginAllocate(NPP npp, NPClass *theClass)
     }
 
     newInstance->npp = npp;
-    
     newInstance->eventLogging = FALSE;
+    newInstance->stream = 0;
     
     return (NPObject *)newInstance;
 }
index ac35a5477f46ee35d8fe0ea819a6fd76e2175bc8..6b33ee24c71530c51b40f870d1033e470a441072 100644 (file)
@@ -39,6 +39,7 @@ typedef struct {
     NPObject header;
     NPP npp;
     Boolean eventLogging;
+    NPStream* stream;
 } PluginObject;
 
 extern NPClass *getPluginClass(void);
index fb21368fb77555743160c4e88a4a0cc44e63b5a6..9d9027a308274c8d1fb7a19c99549d6eab823071 100644 (file)
@@ -92,7 +92,10 @@ NPError NPP_SetWindow(NPP instance, NPWindow *window)
 
 NPError NPP_NewStream(NPP instance, NPMIMEType type, NPStream *stream, NPBool seekable, uint16 *stype)
 {
+    PluginObject* obj = instance->pdata;
+    obj->stream = stream;
     *stype = NP_ASFILEONLY;
+
     return NPERR_NO_ERROR;
 }