Project: chromium Issues People Development process History Sign in
New issue
Advanced search Search tips
Issue 522100 Deprecate and remove initTouchEvent
Starred by 2 users Project Member Reported by rbyers@chromium.org, Aug 18 2015 Back to list
Status: Fixed
Owner:
Closed: Aug 2016
Cc:
Components:
EstimatedDays: ----
NextAction: ----
OS: All
Pri: 2
Type: Bug

Blocked on: View detail
issue 508675
issue 629554

Blocking:
issue 518868



Sign in to add a comment
Doing some httparchive searches for usage of initTouchEvent I came across a number of sites (eg. http://www.arccjournals.com/) with code like this:

Browser.Features.iOSTouch = (function() {
    var a = "cantouch"
      , c = document.html
      , f = false;
    if (!c.addEventListener) {
        return false;
    }
    var d = function() {
        c.removeEventListener(a, d, true);
        f = true;
    }
    ;
    try {
        c.addEventListener(a, d, true);
        var e = document.createEvent("TouchEvent");
        e.initTouchEvent(a);
        c.dispatchEvent(e);
        return f;
    } catch (b) {}
    d();
    return false;
}
)();

This apparently returns false in Chrome because initTouchEvent("touchstart") doesn't actually set the event type.  Does this really work on Safari?  The first argument is supposed to be the touches array, not the event type.  initTouchEvent on Chrome should behave exactly as it does on Safari.

Also the use counter data for initTouchEvent is extremely low (https://www.chromestatus.com/metrics/feature/popularity#V8TouchEvent_InitTouchEvent_Method), we should investigate whether sites like this are actually triggering the use counter or not, and if not why not.

Once we're clear on the right behavior for Chrome, we should update the spec to correctly define it: https://github.com/w3c/touch-events/issues/29


 
Comment 1 by rbyers@chromium.org, Aug 18 2015
Note that when making this change we should spot-check a few sites and verify we don't appear to be breaking anything on mobile.  Eg. if the touch code has only ever been hit on Safari before, it's possible it could cause more problems than it fixes by suddenly being enabled on Chrome (eg. maybe there are assumptions based on the user agent string).  I don't expect any major issues, just worth checking.

Here's a list of all the httparchive search results: https://docs.google.com/spreadsheets/d/1EUyotOsyCMKYPavWKFF5vcOOqLeoDzIcqlscCMrzBWY/edit?usp=sharing
Comment 2 by rbyers@chromium.org, Aug 18 2015
Cc: -bokan@chromium.org rbyers@chromium.org
Owner: dtapu...@chromium.org
Comment 3 by rbyers@chromium.org, Aug 18 2015
Blocking: chromium:518868
Cc: dtapu...@chromium.org
Owner: chongz@chromium.org
Status: Started
Changing the initTouchEvent(...) will certainly cause issues;

See the YUI library that has UA checks for android.

https://github.com/yui/yui3/blob/master/src/event-simulate/js/event-simulate.js

We should try to implement the initTouchEvent as described on: https://developer.apple.com/library/iad/documentation/UserExperience/Reference/TouchEventClassReference/index.html#//apple_ref/javascript/instm/TouchEvent/initTouchEvent

in addition to our current implementation.

Yikes, UA checks like that are exactly the thing we're trying to make unnecessary.  Yes if we can support the Safari behavior while also still supporting our existing behavior (to the extend necessary for web compat) that's probably ideal.  We'll have to decide whether we should spec the Safari behavior, or the new weird Safari+Chrome behavior - probably by asking Edge and Mozilla folks what they prefer (I'm guessing the latter - even though it's ugly).

Summary: Make initTouchEvent interoperable with Safari (was: Make initTouchEvent behave exactly the same as it does on Safari)
Status: ExternalDependency
Waiting for Apple's response
Status: Started
Let's not wait any longer for a response, just do our best to match Safari's behavior (given some basic testing)...
I just re-read what I wrote in the W3C bug: https://github.com/w3c/touch-events/issues/29:

Do we have any idea yet why the httparchive data and Chrome UMA data seem so inconsistent?  In particular, if you try loading some of the matching sites from httparchive, do they trigger the Chrome use counter before (or after) your fix?  Eg. if we do the type-checking and whatnot first then Safari-style uses of the API wouldn't trigger our use counter and that could explain the anomaly.

You can check to see if the Chrome use counter is triggered by going to chrome://histograms/WebCore.FeatureObserver and looking at the count for bucket #872 (V8TouchEvent_InitTouchEvent_Method).

FWIW, I'm open to being convinced that this is not worth doing (given that we have the constructors as the right interoperable solution for the future).  But since our goal was always to match Safari and there are apparently a largish number of sites using this from Safari, it's worth some effort to try to reconcile IMHO.
It seems that the major libs (html5player.js, ima3.js, YUI.js) only provide a function to simulate touch events, but websites never use that.

And other libs (rokbox.js(specific version), mootools-mobile.js, powertools-1.2.0.js) will do the iOSTouch check but actually it will return false on both Chrome and Safari. e.g.

'''
var e = document.createEvent("TouchEvent"); // Exception on non-touch devices
e.initTouchEvent('cantouch'); // Safari requires all params, so TypeError
'''


To trigger initTouchEvent use count:
1. Open http://www.kaeufersiegel.de/ on mobile (non-touchscreen desktop won't work)
2. Click any link or do a refresh
3. chrome://histograms/WebCore.FeatureObserver bucket #872 will increase, triggered by http://www.kaeufersiegel.de/modules/mod_djimageslider/assets/powertools-1.2.0.js


After my fix I don't think it will change anything, YUI get data from UA and will continue working, other libs with iOSTouch detection will still return false for Safari and Chrome.
Fascinating, thanks for the details.  So we don't have any specific sites
that behave better with this fix.  This explains why it's not as big of a
problem as I feared, thanks.  Still seems worth doing to me unless anyone
wants to argue otherwise.
Labels: -Type-Bug OWP-Type-NewAPI OWP-Standards-UnofficialSpec
Comment 15 by phil...@opera.com, Dec 4 2015
I've tested the Browser.Features.iOSTouch given in the description, by changing document.html to document.documentElement. It's false in Mobile Safari as well, because  it throws a TypeError on e.initTouchEvent(a).

There's something strange going on here, because WebKit's IDL doesn't match Safari's behavior. Let's discuss in the review.
Labels: -OWP-Type-NewAPI OWP-Type-Deprecation
After further discussion and looking at more of the data, the decision now is to deprecate and remove initTouchEvent.
Labels: -OWP-Standards-UnofficialSpec OWP-Standards-OfficialSpec M-53
Summary: Deprecate and remove initTouchEvent (was: Make initTouchEvent interoperable with Safari)
Note that the deprecation warning says we're going to remove this in M53 but M53 has branched now.  Should we update the warning to say M54 (merge that) then remove it on trunk?
Comment 20 by jmedley@google.com, Jul 11 2016
Rick,

It looks like I missed a step here. Which version of Chrome was it
deprecated in? FYI, we don't have a status entry for this.

Joe

Joe Medley | Technical Writer, Chrome DevRel | jmedley@google.com |
 816-678-7195
*If an API's not documented it doesn't exist.*
Looks to me it was deprecated in 49.
jmedley@,

Apologize if I did the deprecated steps wrong or missed something...

It was deprecated in M49 and here is the status entry:
https://www.chromestatus.com/features/5730982598541312

Thanks!
Comment 23 by jmedley@google.com, Jul 11 2016
No need to apologize. An hour ago I would have sworn it wasn't on Chrome
Status. Weird.

Joe Medley | Technical Writer, Chrome DevRel | jmedley@google.com |
 816-678-7195
*If an API's not documented it doesn't exist.*
Project Member Comment 24 by sheriffbot@chromium.org, Jul 17 2016
Labels: -M-53 M-54 MovedFrom-53
Moving this nonessential bug to the next milestone.

For more details visit https://www.chromium.org/issue-tracking/autotriage - Your friendly Sheriffbot
Blockedon: 629554
Project Member Comment 26 by bugdroid1@chromium.org, Jul 29 2016
The following revision refers to this bug:
  https://chromium.googlesource.com/chromium/src.git/+/44cc3124a56262d937b36a3d6d0d3de626082716

commit 44cc3124a56262d937b36a3d6d0d3de626082716
Author: chongz <chongz@chromium.org>
Date: Fri Jul 29 05:30:39 2016

Remove |TouchEvent.initTouchEvent()| in M54

|TouchEvent.initTouchEvent()| is not standardized and not interoperate
with Firefox or Safari. Developers should be encouraged to use the new
TouchEvent constructor instead.

|initTouchEvent()| was deprecated in M49, and this CL removes it
in M54 (deferred from M53).

Intent to Deprecate and Remove:
https://groups.google.com/a/chromium.org/forum/#!topic/blink-dev/dqlJguVuIHs

Chrome Status Entry:
https://www.chromestatus.com/features/5730982598541312

TBR=timvolodine
BUG= 522100 

Review-Url: https://codereview.chromium.org/2182183003
Cr-Commit-Position: refs/heads/master@{#408579}

[modify] https://crrev.com/44cc3124a56262d937b36a3d6d0d3de626082716/android_webview/tools/system_webview_shell/test/data/webexposed/global-interface-listing-expected.txt
[modify] https://crrev.com/44cc3124a56262d937b36a3d6d0d3de626082716/third_party/WebKit/LayoutTests/fast/events/touch/document-create-touch-list-expected.txt
[modify] https://crrev.com/44cc3124a56262d937b36a3d6d0d3de626082716/third_party/WebKit/LayoutTests/fast/events/touch/script-tests/document-create-touch-list.js
[modify] https://crrev.com/44cc3124a56262d937b36a3d6d0d3de626082716/third_party/WebKit/LayoutTests/fast/events/touch/touch-event-dispatch-no-crash-expected.txt
[modify] https://crrev.com/44cc3124a56262d937b36a3d6d0d3de626082716/third_party/WebKit/LayoutTests/fast/events/touch/touch-event-dispatch-no-crash.html
[modify] https://crrev.com/44cc3124a56262d937b36a3d6d0d3de626082716/third_party/WebKit/LayoutTests/virtual/stable/webexposed/global-interface-listing-expected.txt
[modify] https://crrev.com/44cc3124a56262d937b36a3d6d0d3de626082716/third_party/WebKit/LayoutTests/webexposed/global-interface-listing-expected.txt
[modify] https://crrev.com/44cc3124a56262d937b36a3d6d0d3de626082716/third_party/WebKit/Source/core/events/TouchEvent.cpp
[modify] https://crrev.com/44cc3124a56262d937b36a3d6d0d3de626082716/third_party/WebKit/Source/core/events/TouchEvent.h
[modify] https://crrev.com/44cc3124a56262d937b36a3d6d0d3de626082716/third_party/WebKit/Source/core/events/TouchEvent.idl

Labels: Type-Bug
Status: Fixed
initTouchEvent removed in M54.
Could you please also clean up the removal warning (in Deprecation.cpp)?
Status: Started
Back to chongz@ to remove the deprecation warning.
Project Member Comment 30 by bugdroid1@chromium.org, Aug 24 2016
The following revision refers to this bug:
  https://chromium.googlesource.com/chromium/src.git/+/843b0c5cf6cbcb96d5e1314e37f041e7d2da1959

commit 843b0c5cf6cbcb96d5e1314e37f041e7d2da1959
Author: chongz <chongz@chromium.org>
Date: Wed Aug 24 01:05:56 2016

Cleanup |initTouchEvent| deprecation warning and usecounter

|TouchEvent.initTouchEvent()| was removed in M54, so we no
longer need these deprecation warning and usercounter.

See https://chromium.googlesource.com/chromium/src.git/+/44cc3124a56262d937b36a3d6d0d3de626082716

BUG= 522100 

Review-Url: https://codereview.chromium.org/2276523002
Cr-Commit-Position: refs/heads/master@{#413919}

[modify] https://crrev.com/843b0c5cf6cbcb96d5e1314e37f041e7d2da1959/third_party/WebKit/Source/core/frame/Deprecation.cpp
[modify] https://crrev.com/843b0c5cf6cbcb96d5e1314e37f041e7d2da1959/third_party/WebKit/Source/core/frame/UseCounter.h

Status: Fixed
Blockedon: 508675
Sign in to add a comment