Tests for bug 634534 (destroy a stream while a part-request has been requested but OnStartRequest has not yet fired). Fixed test_pluginstream_seek_close.html so that the first iframe onload (for about:blank) is not used with the test. a=blocker-test

--HG--
extra : rebase_source : e2034212a7cb89aed5f0782c4d412954ea1470a8
This commit is contained in:
Benjamin Smedberg 2011-02-23 10:47:17 -05:00
Родитель f68338bc51
Коммит ec2e9ffb13
4 изменённых файлов: 60 добавлений и 4 удалений

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

@ -70,6 +70,7 @@ _MOCHITEST_FILES = \
test_pluginstream_poststream.html \
test_pluginstream_seek.html \
test_pluginstream_newstream.html \
test_pluginstream_seek_close.html \
test_fullpage.html \
loremipsum.xtest \
loremipsum.xtest^headers^ \

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

@ -0,0 +1,44 @@
<body>
<head>
<title>NPAPI Seekable NPStream Test</title>
<script type="text/javascript"
src="/MochiKit/packed.js"></script>
<script type="text/javascript"
src="/tests/SimpleTest/SimpleTest.js"></script>
<link rel="stylesheet" type="text/css"
href="/tests/SimpleTest/test.css" />
</head>
<body>
<p id="display"></p>
<iframe id="testframe" name="testframe" onload="frameLoaded()"></iframe>
<!--
- Tests a seekable stream. Calls NPN_RequestRead with the specified
- range, and verifies that an NPP_Write call is made with the correct
- parameters, including the buffer data for the byte range. Once all
- calls to NPP_Write have finished, the plugin calls NPN_DestroyStream
- and then displays the entire stream's content in a browser frame via
- NPN_GetURL.
-->
<embed src="neverending.sjs" streammode="seek" closestream
frame="testframe" streamchunksize="1024" range="100,100"
id="embedtest" style="width: 400px; height: 100px;"
type="application/x-test"></embed>
<script class="testbody" type="application/javascript">
SimpleTest.waitForExplicitFinish();
var testframe = document.getElementById('testframe');
function frameLoaded() {
var content = testframe.contentDocument.body.innerHTML;
if (!content.length)
return;
ok(true, "We didn't crash");
SimpleTest.finish();
}
</script>
</body>
</html>

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

@ -739,6 +739,7 @@ NPP_New(NPMIMEType pluginType, NPP instance, uint16_t mode, int16_t argc, char*
instanceData->focusState = ACTIVATION_STATE_UNKNOWN;
instanceData->focusEventCount = 0;
instanceData->eventModel = 0;
instanceData->closeStream = false;
instance->pdata = instanceData;
TestNPObject* scriptableObject = (TestNPObject*)NPN_CreateObject(instance, &sNPClass);
@ -854,6 +855,9 @@ NPP_New(NPMIMEType pluginType, NPP instance, uint16_t mode, int16_t argc, char*
strcmp(argv[i], "false") == 0) {
instanceData->cleanupWidget = false;
}
if (!strcmp(argn[i], "closestream")) {
instanceData->closeStream = true;
}
}
if (!browserSupportsWindowless || !pluginSupportsWindowlessMode()) {
@ -1116,7 +1120,6 @@ NPP_WriteReady(NPP instance, NPStream* stream)
int32_t
NPP_Write(NPP instance, NPStream* stream, int32_t offset, int32_t len, void* buffer)
{
printf("NPP_Write, offset=%d, len=%d, end=%d\n", offset, len, stream->end);
InstanceData* instanceData = (InstanceData*)(instance->pdata);
instanceData->writeCount++;
@ -1163,11 +1166,18 @@ NPP_Write(NPP instance, NPStream* stream, int32_t offset, int32_t len, void* buf
return len;
}
// If the complete stream has been written, and we're doing a seek test,
// then call NPN_RequestRead.
if (instanceData->streamMode == NP_SEEK &&
if (instanceData->closeStream) {
instanceData->closeStream = false;
if (instanceData->testrange != NULL) {
NPError err = NPN_RequestRead(stream, instanceData->testrange);
}
NPN_DestroyStream(instance, stream, NPRES_USER_BREAK);
}
else if (instanceData->streamMode == NP_SEEK &&
stream->end != 0 &&
stream->end == ((uint32_t)instanceData->streamBufSize + len)) {
// If the complete stream has been written, and we're doing a seek test,
// then call NPN_RequestRead.
// prevent recursion
instanceData->streamMode = NP_NORMAL;

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

@ -137,6 +137,7 @@ typedef struct InstanceData {
ActivationState focusState;
int32_t focusEventCount;
int32_t eventModel;
bool closeStream;
} InstanceData;
void notifyDidPaint(InstanceData* instanceData);