Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
SeleniumHQ
GitHub Repository: SeleniumHQ/Selenium
Path: blob/trunk/third_party/closure/goog/dom/browserfeature.js
4214 views
1
/**
2
* @license
3
* Copyright The Closure Library Authors.
4
* SPDX-License-Identifier: Apache-2.0
5
*/
6
7
/**
8
* @fileoverview Browser capability checks for the dom package.
9
*/
10
11
12
goog.provide('goog.dom.BrowserFeature');
13
14
goog.require('goog.userAgent');
15
16
17
/**
18
* @define {boolean} Whether we know at compile time that the browser doesn't
19
* support OffscreenCanvas.
20
*/
21
goog.dom.BrowserFeature.ASSUME_NO_OFFSCREEN_CANVAS =
22
goog.define('goog.dom.ASSUME_NO_OFFSCREEN_CANVAS', false);
23
24
/**
25
* @define {boolean} Whether we know at compile time that the browser supports
26
* all OffscreenCanvas contexts.
27
*/
28
// TODO(user): Eventually this should default to "FEATURESET_YEAR >= 202X".
29
goog.dom.BrowserFeature.ASSUME_OFFSCREEN_CANVAS =
30
goog.define('goog.dom.ASSUME_OFFSCREEN_CANVAS', false);
31
32
/**
33
* Detects if a particular OffscreenCanvas context is supported.
34
* @param {string} contextName name of the context to test.
35
* @return {boolean} Whether the browser supports this OffscreenCanvas context.
36
* @private
37
*/
38
goog.dom.BrowserFeature.detectOffscreenCanvas_ = function(contextName) {
39
'use strict';
40
// This code only gets removed because we forced @nosideeffects on
41
// the functions. See: b/138802376
42
try {
43
return Boolean(new self.OffscreenCanvas(0, 0).getContext(contextName));
44
} catch (ex) {
45
}
46
return false;
47
};
48
49
/**
50
* Whether the browser supports OffscreenCanvas 2D context.
51
* @const {boolean}
52
*/
53
goog.dom.BrowserFeature.OFFSCREEN_CANVAS_2D =
54
!goog.dom.BrowserFeature.ASSUME_NO_OFFSCREEN_CANVAS &&
55
(goog.dom.BrowserFeature.ASSUME_OFFSCREEN_CANVAS ||
56
goog.dom.BrowserFeature.detectOffscreenCanvas_('2d'));
57
58
/**
59
* Whether attributes 'name' and 'type' can be added to an element after it's
60
* created. False in Internet Explorer prior to version 9.
61
* @const {boolean}
62
*/
63
goog.dom.BrowserFeature.CAN_ADD_NAME_OR_TYPE_ATTRIBUTES = true;
64
65
/**
66
* Whether we can use element.children to access an element's Element
67
* children. Available since Gecko 1.9.1, IE 9. (IE<9 also includes comment
68
* nodes in the collection.)
69
* @const {boolean}
70
*/
71
goog.dom.BrowserFeature.CAN_USE_CHILDREN_ATTRIBUTE = true;
72
73
/**
74
* Opera, Safari 3, and Internet Explorer 9 all support innerText but they
75
* include text nodes in script and style tags. Not document-mode-dependent.
76
* @const {boolean}
77
*/
78
goog.dom.BrowserFeature.CAN_USE_INNER_TEXT = false;
79
80
/**
81
* MSIE, Opera, and Safari>=4 support element.parentElement to access an
82
* element's parent if it is an Element.
83
* @const {boolean}
84
*/
85
goog.dom.BrowserFeature.CAN_USE_PARENT_ELEMENT_PROPERTY =
86
goog.userAgent.IE || goog.userAgent.WEBKIT;
87
88
/**
89
* Whether NoScope elements need a scoped element written before them in
90
* innerHTML.
91
* MSDN: http://msdn.microsoft.com/en-us/library/ms533897(VS.85).aspx#1
92
* @const {boolean}
93
*/
94
goog.dom.BrowserFeature.INNER_HTML_NEEDS_SCOPED_ELEMENT = goog.userAgent.IE;
95
96