Bug 1313170 - Use the widget-level touch injection instead of the OS-level touch injection for some tests. r=dvander

When using the InjectTouchInput API on Windows, the API requires that the caller
keep providing input frames (by calling the API function) at least every 100ms.
If the caller fails to do so, Windows can return an ERROR_TIMEOUT and throw
away the touch sequence. In some tests, it is hard for us to make this guarantee,
because we need to wait for other events between the touchdown and touchup. For
these tests, we can use the widget-level touch injection code that we have as
a fallback for the OS-level touch injection code. The widget-level touch
injection is less representative of real-world usage but allows us to bypass
the timeout problem.

MozReview-Commit-ID: EoVUSZmERUw

--HG--
extra : rebase_source : 4f7ca1a1e6da4479d51526e8f132f5cb23fceb49
This commit is contained in:
Kartikaya Gupta 2016-10-31 10:05:15 -04:00
Родитель 57194150d3
Коммит cb026d2536
3 изменённых файлов: 19 добавлений и 10 удалений

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

@ -34,6 +34,8 @@ var basic_pan_prefs = [
var touch_action_prefs = basic_pan_prefs.slice(); // make a copy
touch_action_prefs.push(["layout.css.touch_action.enabled", true]);
var isWindows = (getPlatform() == "windows");
var subtests = [
// Simple tests to exercise basic panning behaviour
{'file': 'helper_basic_pan.html', 'prefs': basic_pan_prefs},
@ -53,19 +55,24 @@ var subtests = [
// Taps on media elements to make sure the touchend event is delivered
// properly. We increase the long-tap timeout to ensure it doesn't get trip
// during the tap.
{'file': 'helper_bug1162771.html', 'prefs': [["ui.click_hold_context_menus.delay", 10000]]},
// Also this test (on Windows) cannot satisfy the OS requirement of providing
// an injected touch event every 100ms, because it waits for a paint between
// the touchstart and the touchend, so we have to use the "fake injection"
// code instead.
{'file': 'helper_bug1162771.html', 'prefs': [["ui.click_hold_context_menus.delay", 10000],
["apz.test.fails_with_native_injection", isWindows]]},
// For the long-tap test, reduce the content response timeout because the touchstart
// event doesn't get processed (because of the event listener) until this expires.
// Once we support passive event listeners, we can use that instead and stop mucking
// with the timeout.
{'file': 'helper_long_tap.html'},
// As with the previous test, this test cannot inject touch events every 100ms
// because it waits for a long-tap, so we have to use the "fake injection" code
// instead.
{'file': 'helper_long_tap.html', 'prefs': [["apz.test.fails_with_native_injection", isWindows]]},
// For the following test, we want to make sure APZ doesn't wait for a content
// response that is never going to arrive. To detect this we set the content response
// timeout to a day, so that the entire test times out and fails if APZ does
// end up waiting.
{'file': 'helper_tap_passive.html', 'prefs': [["apz.content_response_timeout", 24 * 60 * 60 * 1000]]},
{'file': 'helper_tap_passive.html', 'prefs': [["apz.content_response_timeout", 24 * 60 * 60 * 1000],
["apz.test.fails_with_native_injection", isWindows]]},
// Simple test to exercise touch-action CSS property
{'file': 'helper_touch_action.html', 'prefs': touch_action_prefs},

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

@ -296,6 +296,7 @@ private:
DECL_GFX_PREF(Live, "apz.peek_messages.enabled", APZPeekMessages, bool, true);
DECL_GFX_PREF(Live, "apz.printtree", APZPrintTree, bool, false);
DECL_GFX_PREF(Live, "apz.record_checkerboarding", APZRecordCheckerboarding, bool, false);
DECL_GFX_PREF(Live, "apz.test.fails_with_native_injection", APZTestFailsWithNativeInjection, bool, false);
DECL_GFX_PREF(Live, "apz.test.logging_enabled", APZTestLoggingEnabled, bool, false);
DECL_GFX_PREF(Live, "apz.touch_move_tolerance", APZTouchMoveTolerance, float, 0.0);
DECL_GFX_PREF(Live, "apz.touch_start_tolerance", APZTouchStartTolerance, float, 1.0f/4.5f);

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

@ -133,9 +133,10 @@ nsWindowBase::SynthesizeNativeTouchPoint(uint32_t aPointerId,
{
AutoObserverNotifier notifier(aObserver, "touchpoint");
if (!InitTouchInjection()) {
// If we don't have touch injection from the OS, we can just fake it and
// synthesize the events from here.
if (gfxPrefs::APZTestFailsWithNativeInjection() || !InitTouchInjection()) {
// If we don't have touch injection from the OS, or if we are running a test
// that cannot properly inject events to satisfy the OS requirements (see bug
// 1313170) we can just fake it and synthesize the events from here.
MOZ_ASSERT(NS_IsMainThread());
if (aPointerState == TOUCH_HOVER) {
return NS_ERROR_UNEXPECTED;