Bug 1351148 Part3: Synthesize native input events with priority. f=kats,smaug. r=smaug.

The test helper_touch_action_regions.html uses nsDOMWindowUtils to synthesize native input events and creates some runnables to trigger the test. It expects the runnables which synthesize native input events are processed first, then the runnables to continue the test, and finally the input events are forwarded from chrome process to content process. Enabling event prioritization may change the execution order.
Wraps those runnables to synthesize native input events as priority=input and dispatches those runnables to continue the test with priority=input to make sure the execution order is as expected.

MozReview-Commit-ID: 8hkaB1FRW9T
This commit is contained in:
Stone Shih
2017-05-19 15:41:24 +08:00
parent 419a19e980
commit cef54f76bd
7 changed files with 143 additions and 44 deletions

View File

@@ -88,6 +88,47 @@ already_AddRefed<nsITimer> CreateTimer()
} // namespace detail
} // namespace mozilla
NS_IMPL_ISUPPORTS_INHERITED(PrioritizableRunnable, Runnable,
nsIRunnablePriority)
PrioritizableRunnable::PrioritizableRunnable(already_AddRefed<nsIRunnable>&& aRunnable,
uint32_t aPriority)
// Real runnable name is managed by overridding the GetName function.
: Runnable("PrioritizableRunnable")
, mRunnable(Move(aRunnable))
, mPriority(aPriority)
{
#if DEBUG
nsCOMPtr<nsIRunnablePriority> runnablePrio = do_QueryInterface(mRunnable);
MOZ_ASSERT(!runnablePrio);
#endif
}
NS_IMETHODIMP
PrioritizableRunnable::GetName(nsACString& aName)
{
// Try to get a name from the underlying runnable.
nsCOMPtr<nsINamed> named = do_QueryInterface(mRunnable);
if (named) {
named->GetName(aName);
}
return NS_OK;
}
NS_IMETHODIMP
PrioritizableRunnable::Run()
{
MOZ_RELEASE_ASSERT(NS_IsMainThread());
return mRunnable->Run();
}
NS_IMETHODIMP
PrioritizableRunnable::GetPriority(uint32_t* aPriority)
{
*aPriority = mPriority;
return NS_OK;
}
#endif // XPCOM_GLUE_AVOID_NSPR
//-----------------------------------------------------------------------------