Skip to content

Commit

Permalink
fix: bail out of event blocking for Adobe CEP bug
Browse files Browse the repository at this point in the history
Some Adobe CEP environments have a broken Event.timeStamp implementation that breaks event blocking
logic. The issue specifically affects host applications running on macOS with CEP version 9.3 and
below. This workaround is OS-agnostic so as to maintain identical behavior across platforms. More
details can be found in issue vuejs#10366.

fix vuejs#10366
  • Loading branch information
ericdrobinson committed Sep 6, 2019
1 parent 399b536 commit 1911503
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
1 change: 1 addition & 0 deletions src/core/util/env.js
Expand Up @@ -16,6 +16,7 @@ export const isIOS = (UA && /iphone|ipad|ipod|ios/.test(UA)) || (weexPlatform ==
export const isChrome = UA && /chrome\/\d+/.test(UA) && !isEdge
export const isPhantomJS = UA && /phantomjs/.test(UA)
export const isFF = UA && UA.match(/firefox\/(\d+)/)
export const isCEP = inBrowser && window.__adobe_cep__ !== undefined

// Firefox has a "watch" function on Object.prototype...
export const nativeWatch = ({}).watch
Expand Down
13 changes: 12 additions & 1 deletion src/platforms/web/runtime/modules/events.js
Expand Up @@ -2,7 +2,7 @@

import { isDef, isUndef } from 'shared/util'
import { updateListeners } from 'core/vdom/helpers/index'
import { isIE, isFF, supportsPassive, isUsingMicroTask } from 'core/util/index'
import { isIE, isFF, isCEP, supportsPassive, isUsingMicroTask } from 'core/util/index'
import { RANGE_TOKEN, CHECKBOX_RADIO_TOKEN } from 'web/compiler/directives/model'
import { currentFlushTimestamp } from 'core/observer/scheduler'

Expand Down Expand Up @@ -44,6 +44,14 @@ function createOnceHandler (event, handler, capture) {
// safe to exclude.
const useMicrotaskFix = isUsingMicroTask && !(isFF && Number(isFF[1]) <= 53)

// #10366: CEP <= 9.3.x has a buggy Event.timeStamp implementation. While the
// issue is restricted to macOS, the fix is OS-agnostic to keep behavioral
// differences to a minimum.
const isCEP93orEarlier = isCEP && ((maxBadMajor, maxBadMinor) => {
const version = JSON.parse(window.__adobe_cep__.getCurrentApiVersion())
return version.major <= maxBadMajor && version.minor <= maxBadMinor
})(9, 3)

function add (
name: string,
handler: Function,
Expand Down Expand Up @@ -71,6 +79,9 @@ function add (
// #9462 iOS 9 bug: event.timeStamp is 0 after history.pushState
// #9681 QtWebEngine event.timeStamp is negative value
e.timeStamp <= 0 ||
// #10366 Adobe CEP bug: event.timeStamp is not reliable on macOS for
// host applications with CEP versions prior to 9.4.x.
isCEP93orEarlier ||
// #9448 bail if event is fired in another document in a multi-page
// electron/nw.js app, since event.timeStamp will be using a different
// starting reference
Expand Down

0 comments on commit 1911503

Please sign in to comment.