зеркало из https://github.com/mozilla/gecko-dev.git
Bug 666529: Fixes for NPAPI timer test. Fix a crash bug discovered by Hiroyuki Ikezoe and a bad dependency on timer event ordering, both of which are sources of intermittent failures. r=jgriffin
This commit is contained in:
Родитель
46f5f74ed3
Коммит
813cf6a627
|
@ -322,8 +322,6 @@ static const char* SUCCESS_STRING = "pass";
|
|||
|
||||
static bool sIdentifiersInitialized = false;
|
||||
|
||||
static uint32_t timerEventCount = 0;
|
||||
|
||||
struct timerEvent {
|
||||
int32_t timerIdReceive;
|
||||
int32_t timerIdSchedule;
|
||||
|
@ -335,15 +333,12 @@ static timerEvent timerEvents[] = {
|
|||
{-1, 0, 200, false, -1},
|
||||
{0, 0, 400, false, -1},
|
||||
{0, 0, 200, true, -1},
|
||||
{0, 1, 100, true, -1},
|
||||
{1, -1, 0, false, -1},
|
||||
{0, -1, 0, false, -1},
|
||||
{1, -1, 0, false, -1},
|
||||
{1, -1, 0, false, -1},
|
||||
{0, 1, 400, true, -1},
|
||||
{0, -1, 0, false, 0},
|
||||
{1, 2, 600, false, 1},
|
||||
{2, -1, 0, false, 2},
|
||||
{1, -1, 0, false, -1},
|
||||
{1, -1, 0, false, 1},
|
||||
};
|
||||
static uint32_t currentTimerEventCount = 0;
|
||||
static uint32_t totalTimerEvents = sizeof(timerEvents) / sizeof(timerEvent);
|
||||
|
||||
/**
|
||||
|
@ -2846,8 +2841,8 @@ getAuthInfo(NPObject* npobj, const NPVariant* args, uint32_t argCount, NPVariant
|
|||
static void timerCallback(NPP npp, uint32_t timerID)
|
||||
{
|
||||
InstanceData* id = static_cast<InstanceData*>(npp->pdata);
|
||||
timerEventCount++;
|
||||
timerEvent event = timerEvents[timerEventCount];
|
||||
currentTimerEventCount++;
|
||||
timerEvent event = timerEvents[currentTimerEventCount];
|
||||
|
||||
NPObject* windowObject;
|
||||
NPN_GetValue(npp, NPNVWindowNPObject, &windowObject);
|
||||
|
@ -2855,10 +2850,11 @@ static void timerCallback(NPP npp, uint32_t timerID)
|
|||
return;
|
||||
|
||||
NPVariant rval;
|
||||
if (timerID != id->timerID[event.timerIdReceive])
|
||||
if (timerID != id->timerID[event.timerIdReceive]) {
|
||||
id->timerTestResult = false;
|
||||
}
|
||||
|
||||
if (timerEventCount == totalTimerEvents - 1) {
|
||||
if (currentTimerEventCount == totalTimerEvents - 1) {
|
||||
NPVariant arg;
|
||||
BOOLEAN_TO_NPVARIANT(id->timerTestResult, arg);
|
||||
NPN_Invoke(npp, windowObject, NPN_GetStringIdentifier(id->timerTestScriptCallback.c_str()), &arg, 1, &rval);
|
||||
|
@ -2880,7 +2876,7 @@ timerTest(NPObject* npobj, const NPVariant* args, uint32_t argCount, NPVariant*
|
|||
{
|
||||
NPP npp = static_cast<TestNPObject*>(npobj)->npp;
|
||||
InstanceData* id = static_cast<InstanceData*>(npp->pdata);
|
||||
timerEventCount = 0;
|
||||
currentTimerEventCount = 0;
|
||||
|
||||
if (argCount < 1 || !NPVARIANT_IS_STRING(args[0]))
|
||||
return false;
|
||||
|
@ -2888,7 +2884,7 @@ timerTest(NPObject* npobj, const NPVariant* args, uint32_t argCount, NPVariant*
|
|||
id->timerTestScriptCallback = argstr->UTF8Characters;
|
||||
|
||||
id->timerTestResult = true;
|
||||
timerEvent event = timerEvents[timerEventCount];
|
||||
timerEvent event = timerEvents[currentTimerEventCount];
|
||||
|
||||
id->timerID[event.timerIdSchedule] = NPN_ScheduleTimer(npp, event.timerInterval, event.timerRepeat, timerCallback);
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче