-
Notifications
You must be signed in to change notification settings - Fork 79
/
Copy pathexterns.js
192 lines (169 loc) · 5.77 KB
/
externs.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
/**
* @license
* Copyright 2017 Google Inc. All Rights Reserved.
*
* Licensed under the W3C SOFTWARE AND DOCUMENT NOTICE AND LICENSE.
*
* https://www.w3.org/Consortium/Legal/2015/copyright-software-and-document
*/
/** @fileoverview @externs */
/**
* Policy defining rules for creating Trusted Types.
* @typedef {TrustedTypesInnerPolicy}
*/
var TrustedTypesInnerPolicy = {
/**
* Function defining rules for creating a TrustedHTML object.
* @param {string} s The input string.
* @return {string} String that will be wrapped in a TrustedHTML object.
*/
createHTML(s){},
/**
* Function defining rules for creating a TrustedScriptURL object.
* @param {string} s The input string.
* @return {string} String that will be wrapped in a TrustedScriptURL object.
*/
createScriptURL(s){},
/**
* Function defining rules for creating a TrustedScript object.
* @param {string} s The input string.
* @return {string} String that will be wrapped in a TrustedScript object.
*/
createScript(s){},
};
/**
* @constructor
*/
var TrustedTypePolicyFactory = function() {};
/**
* Creates a TT policy.
*
* Returns a frozen object representing a policy - a collection of functions
* that may create TT objects based on the user-provided rules specified
* in the builder function.
*
* @param {string} name A unique name of the policy.
* @param {!TrustedTypesInnerPolicy} policy The policy rules.
* @return {!TrustedTypePolicy} The policy that may create TT objects
* according to the rules in the builder.
*/
TrustedTypePolicyFactory.prototype.createPolicy = function(name, policy){};
/**
* A reference to a default policy, if it was created, null otherwise.
* @type {?TrustedTypePolicy}
*/
TrustedTypePolicyFactory.prototype.defaultPolicy;
/**
* Returns the name of the Trusted Type required for a given element
* attribute.
* @param {string} tagName The name of the tag of the element.
* @param {string} attribute The name of the attribute.
* @param {string=} elementNs Element namespace URI.
* @param {string=} attributeNs The attribute namespace URI.
* @return {string|undefined} Required type name or undefined, if a
* Trusted Type is not required.
*/
TrustedTypePolicyFactory.prototype.getAttributeType = function(tagName,
attribute, elementNs = '', attributeNs = ''){};
/**
* Returns the name of the Trusted Type required for a given element property.
* @param {string} tagName The name of the tag of the element.
* @param {string} property The property.
* @param {string=} elementNs Element namespace URI.
* @param {string=} attributeNs The attribute namespace URI.
* @return {string|undefined} Required type name or undefined, if a
* Trusted Type is not required.
*/
TrustedTypePolicyFactory.prototype.getPropertyType = function(tagName,
property, elementNs = ''){};
/**
* Returns the type map-like object, that resolves a name of a type for a given
* tag + attribute / property in a given namespace.
* The keys of the map are uppercase tag names. Map entry has mappings between
* a lowercase attribute name / case-sensitive property name and a name of the
* type that is required for that attribute / property.
*
* Example entry for 'IMG': {"attributes": {"src": "TrustedHTML"}}
*
* The "*" entry contains the type mapping for every other element in a namespace
* not listed separately.
* @param {string=} namespaceUri The namespace URI (will use the current
* document namespace URI if omitted).
* @return {!Object<string, {
* attributes: !Object<string, string>,
* properties: !Object<string, string>}>}
*/
TrustedTypePolicyFactory.prototype.getTypeMapping = function(namespaceUri = ''){};
/**
* Returns true if the value is TrustedHTML created by Trusted Types policy.
* @param {*} value A value to be checked.
* @return {!boolean} true if the value is TrustedHTML.
*/
TrustedTypePolicyFactory.prototype.isHTML = function(value){};
/**
* Returns true if the value is TrustedScriptURL created by Trusted Types policy.
* @param {*} value A value to be checked.
* @return {!boolean} true if the value is TrustedScriptURL.
*/
TrustedTypePolicyFactory.prototype.isScriptURL = function(value){};
/**
* Returns true if the value is TrustedScript created by Trusted Types policy.
* @param {*} value A value to be checked.
* @return {!boolean} true if the value is TrustedScript.
*/
TrustedTypePolicyFactory.prototype.isScript = function(value){};
/**
* Returns empty TrustedHTML.
* @type {!TrustedHTML}
*/
TrustedTypePolicyFactory.prototype.emptyHTML;
/**
* Returns empty TrustedScript.
* @type {!TrustedScript}
*/
TrustedTypePolicyFactory.prototype.emptyScript;
/**
* Object that represents a Trusted HTML code, safe to be inserted into DOM into
* HTML context.
* @constructor
*/
var TrustedHTML = function() {};
/**
* Object that represents a Trusted Script URL, safe to be inserted into DOM as
* a script URL.
* @constructor
*/
var TrustedScriptURL = function() {};
/**
* Object that represents a Trusted JavaScript code string, safe to be executed.
* @constructor
*/
var TrustedScript = function() {};
/**
* Policy allowing to create Trusted Types.
* @constructor
* @property {!string} name
*/
var TrustedTypePolicy = function() {};
/**
* Creates a TrustedHTML object from a string.
* @param {string} s Input string
* @return {!TrustedHTML}
*/
TrustedTypePolicy.prototype.createHTML = function(s) {};
/**
* Creates a TrustedScriptURL object from a string.
* @param {string} s Input string
* @return {!TrustedScriptURL}
*/
TrustedTypePolicy.prototype.createScriptURL = function(s) {};
/**
* Creates a TrustedScript object from a string.
* @param {string} s Input string
* @return {!TrustedScript}
*/
TrustedTypePolicy.prototype.createScript = function(s) {};
/**
* @const {!TrustedTypePolicyFactory}
*/
var trustedTypes;