From 191150361b61d5ed6a5bb68f457e791dd90ca915 Mon Sep 17 00:00:00 2001 From: Eric Robinson Date: Fri, 30 Aug 2019 15:23:09 +0000 Subject: [PATCH 1/3] fix: bail out of event blocking for Adobe CEP bug 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 #10366. fix #10366 --- src/core/util/env.js | 1 + src/platforms/web/runtime/modules/events.js | 13 ++++++++++++- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/src/core/util/env.js b/src/core/util/env.js index 820bacdb405..11c9a024ef4 100644 --- a/src/core/util/env.js +++ b/src/core/util/env.js @@ -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 diff --git a/src/platforms/web/runtime/modules/events.js b/src/platforms/web/runtime/modules/events.js index ecb08af32de..469e12f9023 100644 --- a/src/platforms/web/runtime/modules/events.js +++ b/src/platforms/web/runtime/modules/events.js @@ -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' @@ -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, @@ -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 From ae423f65102d1d30fe098d6ffadfaacba827efc6 Mon Sep 17 00:00:00 2001 From: Eric Robinson Date: Tue, 10 Sep 2019 19:32:47 +0000 Subject: [PATCH 2/3] fix: Adjust existence check to be more explicit Improve type checking of the `__adobe_cep__` object. It shouldn't just be `undefined` but explicitly an object. --- src/core/util/env.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/core/util/env.js b/src/core/util/env.js index 11c9a024ef4..05b1d281bbf 100644 --- a/src/core/util/env.js +++ b/src/core/util/env.js @@ -1,5 +1,7 @@ /* @flow */ +import { isObject } from 'shared/util' + // can we use __proto__? export const hasProto = '__proto__' in {} @@ -16,7 +18,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 +export const isCEP = inBrowser && isObject(window.__adobe_cep__) // Firefox has a "watch" function on Object.prototype... export const nativeWatch = ({}).watch From 88d1da724501036b767dd6a57cd9da5b6696ffbb Mon Sep 17 00:00:00 2001 From: Eric Robinson Date: Tue, 10 Sep 2019 19:37:53 +0000 Subject: [PATCH 3/3] fix: Validate function existence prior to invoking It is possible that extremely early versions of Adobe CEP did not have the `getCurrentApiVersion` function defined. In such cases, assume "CEP 9.3 or earlier". --- src/platforms/web/runtime/modules/events.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/platforms/web/runtime/modules/events.js b/src/platforms/web/runtime/modules/events.js index 469e12f9023..9e33a5b589a 100644 --- a/src/platforms/web/runtime/modules/events.js +++ b/src/platforms/web/runtime/modules/events.js @@ -47,10 +47,12 @@ 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 isCEP93orEarlier = isCEP && + (typeof window.__adobe_cep__.getCurrentApiVersion !== 'function' || + ((maxBadMajor, maxBadMinor) => { const version = JSON.parse(window.__adobe_cep__.getCurrentApiVersion()) return version.major <= maxBadMajor && version.minor <= maxBadMinor -})(9, 3) +})(9, 3)) function add ( name: string,