Debian Codegraph @

closure-library/closure/goog/events/eventtype_test.js

raw
1 // Copyright 2017 The Closure Library Authors. All Rights Reserved.
2 //
3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at
6 //
7 // http://www.apache.org/licenses/LICENSE-2.0
8 //
9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS-IS" BASIS,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and
13 // limitations under the License.
14
15 goog.provide('goog.events.EventTypeTest');
16 goog.setTestOnly('goog.events.EventTypeTest');
17
18 goog.require('goog.events.BrowserFeature');
19 goog.require('goog.events.EventType');
20 goog.require('goog.events.PointerFallbackEventType');
21 goog.require('goog.testing.jsunit');
22 goog.require('goog.userAgent');
23
24 function testPointerFallbackEventType() {
25 if (goog.events.BrowserFeature.POINTER_EVENTS) {
26 // Pointer events are supported; use W3C PointerEvent
27 assertEquals(
28 goog.events.EventType.POINTERDOWN,
29 goog.events.PointerFallbackEventType.POINTERDOWN);
30 } else if (goog.events.BrowserFeature.MSPOINTER_EVENTS) {
31 // Only IE10 should support MSPointerEvent
32 assertTrue(
33 goog.userAgent.IE && goog.userAgent.isVersionOrHigher('10') &&
34 !goog.userAgent.isVersionOrHigher('11'));
35 // W3C PointerEvent not supported; fall back to MSPointerEvent
36 assertEquals(
37 goog.events.EventType.MSPOINTERDOWN,
38 goog.events.PointerFallbackEventType.POINTERDOWN);
39 } else {
40 // Pointer events not supported; fall back to MouseEvent
41 assertEquals(
42 goog.events.EventType.MOUSEDOWN,
43 goog.events.PointerFallbackEventType.POINTERDOWN);
44 }
45 }