зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1352572 - Add support in nptest plugin to test NPN_PostURL(file=true); r=bsmedberg
MozReview-Commit-ID: BDifZ0vRdgj --HG-- extra : rebase_source : a23a723e016d167a6ab735db463edc19a40a9c86
This commit is contained in:
Родитель
a8215361f6
Коммит
44dd9f66cc
|
@ -384,6 +384,13 @@ NPN_[Get/Post]URLNotify succeeds, and `false` if it fails.
|
|||
@redirectCallback will be called from urlredirectnotify if a redirect is attempted
|
||||
@allowRedirects boolean value indicating whether or not to allow redirects
|
||||
|
||||
* postFileToURLTest(url)
|
||||
Calls NPN_PostURL/NPN_PostURLNotify to make a POST request to the URL with
|
||||
request from postFile.
|
||||
The function will return `0` if NPN_PostURL/NPN_PostURLNotify succeeds, and
|
||||
the error code if it fails.
|
||||
@param url string, url to request
|
||||
|
||||
* setPluginWantsAllStreams(wantsAllStreams)
|
||||
Set the value returned by the plugin for NPPVpluginWantsAllNetworkStreams.
|
||||
|
||||
|
|
|
@ -133,6 +133,7 @@ static bool throwExceptionNextInvoke(NPObject* npobj, const NPVariant* args, uin
|
|||
static bool convertPointX(NPObject* npobj, const NPVariant* args, uint32_t argCount, NPVariant* result);
|
||||
static bool convertPointY(NPObject* npobj, const NPVariant* args, uint32_t argCount, NPVariant* result);
|
||||
static bool streamTest(NPObject* npobj, const NPVariant* args, uint32_t argCount, NPVariant* result);
|
||||
static bool postFileToURLTest(NPObject* npobj, const NPVariant* args, uint32_t argCount, NPVariant* result);
|
||||
static bool setPluginWantsAllStreams(NPObject* npobj, const NPVariant* args, uint32_t argCount, NPVariant* result);
|
||||
static bool crashPlugin(NPObject* npobj, const NPVariant* args, uint32_t argCount, NPVariant* result);
|
||||
static bool crashOnDestroy(NPObject* npobj, const NPVariant* args, uint32_t argCount, NPVariant* result);
|
||||
|
@ -206,6 +207,7 @@ static const NPUTF8* sPluginMethodIdentifierNames[] = {
|
|||
"convertPointX",
|
||||
"convertPointY",
|
||||
"streamTest",
|
||||
"postFileToURLTest",
|
||||
"setPluginWantsAllStreams",
|
||||
"crash",
|
||||
"crashOnDestroy",
|
||||
|
@ -280,6 +282,7 @@ static const ScriptableFunction sPluginMethodFunctions[] = {
|
|||
convertPointX,
|
||||
convertPointY,
|
||||
streamTest,
|
||||
postFileToURLTest,
|
||||
setPluginWantsAllStreams,
|
||||
crashPlugin,
|
||||
crashOnDestroy,
|
||||
|
@ -2822,6 +2825,38 @@ streamTest(NPObject* npobj, const NPVariant* args, uint32_t argCount, NPVariant*
|
|||
return true;
|
||||
}
|
||||
|
||||
static bool
|
||||
postFileToURLTest(NPObject* npobj, const NPVariant* args, uint32_t argCount, NPVariant* result)
|
||||
{
|
||||
if (1 != argCount)
|
||||
return false;
|
||||
|
||||
NPP npp = static_cast<TestNPObject*>(npobj)->npp;
|
||||
|
||||
string url;
|
||||
{
|
||||
if (!NPVARIANT_IS_STRING(args[0]))
|
||||
return false;
|
||||
NPString npurl = NPVARIANT_TO_STRING(args[0]);
|
||||
// make a copy to ensure that the url string is null-terminated
|
||||
url = string(npurl.UTF8Characters, npurl.UTF8Length);
|
||||
}
|
||||
|
||||
|
||||
NPError err;
|
||||
{
|
||||
string buf("/path/to/file");
|
||||
err = NPN_PostURL(npp,
|
||||
url.c_str(),
|
||||
nullptr /* target */,
|
||||
buf.length(), buf.c_str(),
|
||||
true /* file */);
|
||||
}
|
||||
|
||||
BOOLEAN_TO_NPVARIANT(NPERR_NO_ERROR == err, *result);
|
||||
return true;
|
||||
}
|
||||
|
||||
static bool
|
||||
setPluginWantsAllStreams(NPObject* npobj, const NPVariant* args, uint32_t argCount, NPVariant* result)
|
||||
{
|
||||
|
|
Загрузка…
Ссылка в новой задаче