Bug 1352572 - Implement nptest.cpp:streamTest(postFile) parameter; r=bsmedberg

This is an optional parameter that can be used to test streams via file. It may
be necessary to back out this change when NPAPI sandbox is completed as the
testplugin may no longer be able to access files.

MozReview-Commit-ID: FsYxhKKr4hS

--HG--
extra : rebase_source : 5ee413531b5b178c92a1d5cf5c2223e624e02296
This commit is contained in:
Lie Ryan 2017-04-27 03:10:59 +00:00
Родитель 3b84e93d4a
Коммит d52bc4b27e
2 изменённых файлов: 13 добавлений и 4 удалений

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

@ -372,7 +372,7 @@ If the plugin is instantiated as a full-page plugin, the following defaults
are used:
streammode="seek" frame="testframe" range="100,100"
* streamTest(url, doPost, postData, writeCallback, notifyCallback, redirectCallback, allowRedirects)
* streamTest(url, doPost, postData, writeCallback, notifyCallback, redirectCallback, allowRedirects, postFile = false)
This will test how NPN_GetURLNotify and NPN_PostURLNotify behave when they are
called with arbitrary (malformed) URLs. The function will return `true` if
NPN_[Get/Post]URLNotify succeeds, and `false` if it fails.
@ -383,6 +383,7 @@ NPN_[Get/Post]URLNotify succeeds, and `false` if it fails.
@notifyCallback will be called when the urlnotify is received with the notify result
@redirectCallback will be called from urlredirectnotify if a redirect is attempted
@allowRedirects boolean value indicating whether or not to allow redirects
@postFile boolean optional, defaults to false, set to true if postData contains a filename
* postFileToURLTest(url)
Calls NPN_PostURL/NPN_PostURLNotify to make a POST request to the URL with

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

@ -2721,8 +2721,8 @@ convertPointY(NPObject* npobj, const NPVariant* args, uint32_t argCount, NPVaria
static bool
streamTest(NPObject* npobj, const NPVariant* args, uint32_t argCount, NPVariant* result)
{
// .streamTest(url, doPost, postData, writeCallback, notifyCallback, redirectCallback, allowRedirects)
if (7 != argCount)
// .streamTest(url, doPost, postData, writeCallback, notifyCallback, redirectCallback, allowRedirects, postFile = false)
if (!(7 <= argCount && argCount <= 8))
return false;
NPP npp = static_cast<TestNPObject*>(npobj)->npp;
@ -2779,6 +2779,14 @@ streamTest(NPObject* npobj, const NPVariant* args, uint32_t argCount, NPVariant*
return false;
bool allowRedirects = NPVARIANT_TO_BOOLEAN(args[6]);
bool postFile = false;
if (argCount >= 8) {
if (!NPVARIANT_IS_BOOLEAN(args[7])) {
return false;
}
postFile = NPVARIANT_TO_BOOLEAN(args[7]);
}
URLNotifyData* ndata = new URLNotifyData;
ndata->cookie = "dynamic-cookie";
ndata->writeCallback = writeCallback;
@ -2797,7 +2805,7 @@ streamTest(NPObject* npobj, const NPVariant* args, uint32_t argCount, NPVariant*
if (doPost) {
err = NPN_PostURLNotify(npp, urlstr, nullptr,
postData.UTF8Length, postData.UTF8Characters,
false, ndata);
postFile, ndata);
}
else {
err = NPN_GetURLNotify(npp, urlstr, nullptr, ndata);