Bug 184251

Summary: touchmove bound to the document during a touchstart listener is not cancelable (default cannot be prevented)
Product: WebKit Reporter: Anand Thakker <anand.thakker>
Component: DOMAssignee: Nobody <webkit-unassigned>
Status: NEW ---    
Severity: Normal CC: bugs.webkit.org, dino, herr.ernst, john.firebaugh, mansing.choy, oliverzy, simon.fraser, thorton, toby, webkit-bug-importer
Priority: P2 Keywords: InRadar
Version: Safari 11   
Hardware: iPhone / iPad   
OS: iOS 11   

Description Anand Thakker 2018-04-02 17:48:24 PDT
Tested on: iOS 11.2.6, 11.3

Steps to reproduce:
1. Create a script that:
 - Adds a `touchstart` listener, `onStart`, to some div `myDiv`.
 - In `onStart`, add a `touchmove` listener, `onMove`, (with `{passive: false}`) to `document`.
 - In `onMove(e)`, call `e.preventDefault()`.
2. Load the page in iOS 11.2.6 or 11.3 and attempt a scroll from within `myDiv`.

Expected result: the page does not scroll.
Actual result: the page scrolls.

Self-contained example: https://gist.github.com/anandthakker/2d0e71924285a845f0c4e6c5fd966234
Comment 1 Anand Thakker 2018-04-02 17:59:07 PDT
It's worth noting that this issue arises amidst an attempt to mitigate the breaking change discussed in https://bugs.webkit.org/show_bug.cgi?id=182521.
Comment 2 Radar WebKit Bug Importer 2018-04-03 10:26:59 PDT
<rdar://problem/39145024>
Comment 3 Toby Rahilly 2018-07-18 23:43:27 PDT
Experiencing the same issue on iOS 11.4.1

Full user agent: Mozilla/5.0 (iPad; CPU OS 11_4_1 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/11.0 Mobile/15E148 Safari/604.1

Two workarounds:

1) Register a passive event listener on any non-window/document/body element that the event will bubble though.
2) Register the touchmove event listener outside of the touchstart.
Comment 4 Simon Fraser (smfr) 2018-07-19 08:40:04 PDT
3) register the listener with { passive: false }
Comment 5 Toby Rahilly 2018-07-19 08:44:41 PDT
Hi Simon, the touchmove listener is registered with { passive: false } but unfortunately still experiences the behaviour described in this bug.
Comment 6 Toby Rahilly 2018-07-19 18:10:39 PDT
I also tried registering the touchstart event with {passive: false}, but it didn't fix the problem.
Comment 7 Lucas Forschler 2019-02-06 09:19:11 PST
Mass move bugs into the DOM component.