reftest for bug 777946 r=roc

--HG--
extra : transplant_source : -%F70%922y%A0H%9E%F9%1D%20%A2%96u%D3%2A%0F%B5%1E
This commit is contained in:
Karl Tomlinson 2012-09-18 10:15:35 +12:00
parent 87e00dfa4b
commit a22376f716
6 changed files with 72 additions and 5 deletions

View File

@ -25,4 +25,5 @@ random-if(/^Windows\x20NT\x206\.1/.test(http.oscpu)) fails-if(!haveTestPlugin) =
random-if(/^Windows\x20NT\x206\.1/.test(http.oscpu)) fails-if(!haveTestPlugin) == plugin-background-10-step.html plugin-background-ref.html
random-if(!haveTestPlugin) == plugin-transform-1.html plugin-transform-1-ref.html
fails-if(!haveTestPlugin) == plugin-transform-2.html plugin-transform-2-ref.html
skip-if(!haveTestPlugin) == shrink-1.html shrink-1-ref.html
fails-if(!haveTestPlugin) == windowless-layers.html windowless-layers-ref.html

View File

@ -0,0 +1,10 @@
<!DOCTYPE html>
<html>
<head>
</head>
<body>
<embed id="plugin" type="application/x-test"
width="50px" height="40px">
</embed>
</body>
</html>

View File

@ -0,0 +1,23 @@
<!DOCTYPE html>
<html class="reftest-wait">
<head>
<script>
function doShrink()
{
var plugin = document.getElementById("plugin");
plugin.setSlowPaint(true);
plugin.width = "50";
plugin.height = "40";
document.documentElement.removeAttribute("class");
}
document.addEventListener("MozReftestInvalidate", doShrink, false);
</script>
</head>
<body>
<embed id="plugin" type="application/x-test"
width="300" height="500">
</embed>
</body>
</html>

View File

@ -197,6 +197,9 @@ Returns the window width that was current when the plugin last painted.
When value is true, every time the plugin paints, it will invalidate
itself *during the paint* using NPN_Invalidate.
* setSlowPaint(value)
When value is true, the instance will sleep briefly during paint.
== Plugin geometry ==
The test plugin supports the following scriptable methods:

View File

@ -125,6 +125,7 @@ static bool getLastMouseY(NPObject* npobj, const NPVariant* args, uint32_t argCo
static bool getPaintCount(NPObject* npobj, const NPVariant* args, uint32_t argCount, NPVariant* result);
static bool getWidthAtLastPaint(NPObject* npobj, const NPVariant* args, uint32_t argCount, NPVariant* result);
static bool setInvalidateDuringPaint(NPObject* npobj, const NPVariant* args, uint32_t argCount, NPVariant* result);
static bool setSlowPaint(NPObject* npobj, const NPVariant* args, uint32_t argCount, NPVariant* result);
static bool getError(NPObject* npobj, const NPVariant* args, uint32_t argCount, NPVariant* result);
static bool doInternalConsistencyCheck(NPObject* npobj, const NPVariant* args, uint32_t argCount, NPVariant* result);
static bool setColor(NPObject* npobj, const NPVariant* args, uint32_t argCount, NPVariant* result);
@ -186,6 +187,7 @@ static const NPUTF8* sPluginMethodIdentifierNames[] = {
"getPaintCount",
"getWidthAtLastPaint",
"setInvalidateDuringPaint",
"setSlowPaint",
"getError",
"doInternalConsistencyCheck",
"setColor",
@ -248,6 +250,7 @@ static const ScriptableFunction sPluginMethodFunctions[] = {
getPaintCount,
getWidthAtLastPaint,
setInvalidateDuringPaint,
setSlowPaint,
getError,
doInternalConsistencyCheck,
setColor,
@ -499,6 +502,15 @@ static void sendBufferToFrame(NPP instance)
}
}
static void XPSleep(unsigned int seconds)
{
#ifdef XP_WIN
Sleep(1000 * seconds);
#else
sleep(seconds);
#endif
}
TestFunction
getFuncFromString(const char* funcname)
{
@ -765,6 +777,7 @@ NPP_New(NPMIMEType pluginType, NPP instance, uint16_t mode, int16_t argc, char*
instanceData->hasWidget = false;
instanceData->npnNewStream = false;
instanceData->invalidateDuringPaint = false;
instanceData->slowPaint = false;
instanceData->writeCount = 0;
instanceData->writeReadyCount = 0;
memset(&instanceData->window, 0, sizeof(instanceData->window));
@ -2489,6 +2502,22 @@ setInvalidateDuringPaint(NPObject* npobj, const NPVariant* args, uint32_t argCou
return true;
}
static bool
setSlowPaint(NPObject* npobj, const NPVariant* args, uint32_t argCount, NPVariant* result)
{
if (argCount != 1)
return false;
if (!NPVARIANT_IS_BOOLEAN(args[0]))
return false;
bool slow = NPVARIANT_TO_BOOLEAN(args[0]);
NPP npp = static_cast<TestNPObject*>(npobj)->npp;
InstanceData* id = static_cast<InstanceData*>(npp->pdata);
id->slowPaint = slow;
return true;
}
static bool
getError(NPObject* npobj, const NPVariant* args, uint32_t argCount, NPVariant* result)
{
@ -2778,6 +2807,10 @@ void notifyDidPaint(InstanceData* instanceData)
NPN_InvalidateRect(instanceData->npp, &r);
}
if (instanceData->slowPaint) {
XPSleep(1);
}
if (instanceData->runScriptOnPaint) {
NPObject* o = NULL;
NPN_GetValue(instanceData->npp, NPNVPluginElementNPObject, &o);
@ -3166,11 +3199,7 @@ FinishGCRace(void* closure)
{
GCRaceData* rd = static_cast<GCRaceData*>(closure);
#ifdef XP_WIN
Sleep(5000);
#else
sleep(5);
#endif
XPSleep(5);
NPVariant arg;
OBJECT_TO_NPVARIANT(rd->localFunc_, arg);

View File

@ -111,6 +111,7 @@ typedef struct InstanceData {
bool timerTestResult;
bool asyncCallbackResult;
bool invalidateDuringPaint;
bool slowPaint;
int32_t winX;
int32_t winY;
int32_t lastMouseX;