Some JS/DOM APIs only work require a user gesture indicator. Since there is no real user input when running via WebDriver, these APIs can only be tested if WebDriver code has a synthetic user gesture indicator, or explicit checks for a user gesture indicator should also allow usage iff page->isControlledByAutomation(). It would be nice to do the first approach since only one source location is needed. However, it's possible via WebDriver to evaluate "async" JavaScript which calls a completion handler some arbitrary amount of time later. The naive approach to set a user gesture indicator would only allow gesture-requiring API calls that happen synchronously. So, we need to either set a user gesture indicator using non-RAII code, or audit every single check and add || page->isControlledByAutomation() to the condition.
<rdar://problem/37959739>
(In reply to Brian Burg from comment #0) > Some JS/DOM APIs only work require a user gesture indicator. Since there is > no real user input when running via WebDriver, these APIs can only be tested > if WebDriver code has a synthetic user gesture indicator, or explicit checks > for a user gesture indicator should also allow usage iff > page->isControlledByAutomation(). > > It would be nice to do the first approach since only one source location is > needed. However, it's possible via WebDriver to evaluate "async" JavaScript > which calls a completion handler some arbitrary amount of time later. The > naive approach to set a user gesture indicator would only allow > gesture-requiring API calls that happen synchronously. > > So, we need to either set a user gesture indicator using non-RAII code, or > audit every single check and add || page->isControlledByAutomation() to the > condition. Actually, it seems like DOMTimer and some other async code will forward the user gesture, so maybe using the UserGestureIndicator when evaluating the JS snippet would be enough.
Created attachment 334948 [details] Proposed Fix
Committed r229206: <https://trac.webkit.org/changeset/229206>