Bug 595525 - Double data deletion in streamTest (nptest.cpp), test_streamNotify.html, r=josh, a=blocking:betaN+

This commit is contained in:
Honza Bambas 2010-10-11 21:41:11 +02:00
Родитель 33efabe286
Коммит 5176a08b72
2 изменённых файлов: 18 добавлений и 10 удалений

Просмотреть файл

@ -593,10 +593,15 @@ MakeNewNPAPIStreamInternal(NPP npp, const char *relativeURL, const char *target,
if (!pluginHost) return NPERR_GENERIC_ERROR; if (!pluginHost) return NPERR_GENERIC_ERROR;
nsCOMPtr<nsIPluginStreamListener> listener; nsCOMPtr<nsIPluginStreamListener> listener;
// Set aCallNotify here to false. If pluginHost->GetURL or PostURL fail,
// the listener's destructor will do the notification while we are about to
// return a failure code.
// Call SetCallNotify(true) bellow after we are sure we cannot return a failure
// code.
if (!target) if (!target)
((nsNPAPIPluginInstance*)inst)->NewNotifyStream(getter_AddRefs(listener), ((nsNPAPIPluginInstance*)inst)->NewNotifyStream(getter_AddRefs(listener),
notifyData, notifyData,
bDoNotify, relativeURL); PR_FALSE, relativeURL);
switch (type) { switch (type) {
case eNPPStreamTypeInternal_Get: case eNPPStreamTypeInternal_Get:
@ -616,6 +621,15 @@ MakeNewNPAPIStreamInternal(NPP npp, const char *relativeURL, const char *target,
NS_ERROR("how'd I get here"); NS_ERROR("how'd I get here");
} }
if (listener) {
// SetCallNotify(bDoNotify) here, see comment above.
// XXX Not sure of this cast here, we should probably have an interface API
// for this.
nsNPAPIPluginStreamListener* npAPIPluginStreamListener =
static_cast<nsNPAPIPluginStreamListener*>(listener.get());
npAPIPluginStreamListener->SetCallNotify(bDoNotify);
}
return NPERR_NO_ERROR; return NPERR_NO_ERROR;
} }

Просмотреть файл

@ -9,7 +9,7 @@
<script class="testbody" type="application/javascript"> <script class="testbody" type="application/javascript">
SimpleTest.waitForExplicitFinish(); SimpleTest.waitForExplicitFinish();
var pending = 6; var pending = 5;
function testDone() { function testDone() {
dump("testDone: " + pending + "\n") dump("testDone: " + pending + "\n")
--pending; --pending;
@ -49,10 +49,9 @@
testDone(); testDone();
}), "streamTest GET bad DNS"); }), "streamTest GET bad DNS");
ok(p.streamTest("http://localhost:-8/", false, null, ok(!p.streamTest("http://localhost:-8/", false, null,
function(r, t) { function(r, t) {
is(r, 1, "Shouldn't load invalid URI"); ok(false, "Shouldn't get callback from malformed URI");
testDone();
}), "streamTest GET invalid URL"); }), "streamTest GET invalid URL");
ok(p.streamTest("javascript:'Hello';", false, null, ok(p.streamTest("javascript:'Hello';", false, null,
@ -80,14 +79,9 @@
testDone(); testDone();
}), "streamTest GET data: URI"); }), "streamTest GET data: URI");
/*
* XXX/bsmedberg: disable this test as well, since the pluginhost is broken
* and the testplugin is double-deleting the urlnotify context.
ok(!p.streamTest("data:malformed?", false, null, ok(!p.streamTest("data:malformed?", false, null,
function(r, t) { function(r, t) {
todo(false, "Shouldn't get callback for invalid data: URI"); todo(false, "Shouldn't get callback for invalid data: URI");
}), "streamTest GET bad data: URI"); }), "streamTest GET bad data: URI");
*/
} }
</script> </script>