@@ -68,287 +68,6 @@ goog.dom.asserts.assertIsLocation = function(o) {
6868} ;
6969
7070
71- /**
72- * Asserts that a given object is either the given subtype of Element
73- * or a non-Element, non-Location Mock.
74- *
75- * To permit this assertion to pass in the context of tests where DOM
76- * APIs might be mocked, also accepts any other type except for
77- * subtypes of {!Element}. This is to ensure that, for instance,
78- * HTMLScriptElement is not being used in place of a HTMLImageElement,
79- * since this could result in security bugs due to stronger contracts
80- * required for assignments to the src property of the latter.
81- *
82- * The DOM type is looked up in the window the object belongs to. In
83- * some contexts, this might not be possible (e.g. when running tests
84- * outside a browser, cross-domain lookup). In this case, the
85- * assertions are skipped.
86- *
87- * @param {?Object } o The object whose type to assert.
88- * @param {string } typename The name of the DOM type.
89- * @return {!Element } The object.
90- * @private
91- */
92- // TODO(bangert): Make an analog of goog.dom.TagName to correctly handle casts?
93- goog . dom . asserts . assertIsElementType_ = function ( o , typename ) {
94- 'use strict' ;
95- if ( goog . asserts . ENABLE_ASSERTS ) {
96- var win = goog . dom . asserts . getWindow_ ( o ) ;
97- if ( win && typeof win [ typename ] != 'undefined' ) {
98- if ( ! o ||
99- ( ! ( o instanceof win [ typename ] ) &&
100- ( o instanceof win . Location || o instanceof win . Element ) ) ) {
101- goog . asserts . fail (
102- 'Argument is not a %s (or a non-Element, non-Location mock); ' +
103- 'got: %s' ,
104- typename , goog . dom . asserts . debugStringForType_ ( o ) ) ;
105- }
106- }
107- }
108- return /** @type {!Element } */ ( o ) ;
109- } ;
110-
111- /**
112- * Asserts that a given object is a HTMLAnchorElement.
113- *
114- * To permit this assertion to pass in the context of tests where elements might
115- * be mocked, also accepts objects that are not of type Location nor a subtype
116- * of Element.
117- *
118- * @param {?Object } o The object whose type to assert.
119- * @return {!HTMLAnchorElement }
120- * @deprecated Use goog.asserts.dom.assertIsHtmlAnchorElement instead.
121- */
122- goog . dom . asserts . assertIsHTMLAnchorElement = function ( o ) {
123- 'use strict' ;
124- return /** @type {!HTMLAnchorElement } */ (
125- goog . dom . asserts . assertIsElementType_ ( o , 'HTMLAnchorElement' ) ) ;
126- } ;
127-
128- /**
129- * Asserts that a given object is a HTMLButtonElement.
130- *
131- * To permit this assertion to pass in the context of tests where elements might
132- * be mocked, also accepts objects that are not a subtype of Element.
133- *
134- * @param {?Object } o The object whose type to assert.
135- * @return {!HTMLButtonElement }
136- * @deprecated Use goog.asserts.dom.assertIsHtmlButtonElement instead.
137- */
138- goog . dom . asserts . assertIsHTMLButtonElement = function ( o ) {
139- 'use strict' ;
140- return /** @type {!HTMLButtonElement } */ (
141- goog . dom . asserts . assertIsElementType_ ( o , 'HTMLButtonElement' ) ) ;
142- } ;
143-
144- /**
145- * Asserts that a given object is a HTMLLinkElement.
146- *
147- * To permit this assertion to pass in the context of tests where elements might
148- * be mocked, also accepts objects that are not a subtype of Element.
149- *
150- * @param {?Object } o The object whose type to assert.
151- * @return {!HTMLLinkElement }
152- * @deprecated Use goog.asserts.dom.assertIsHtmlLinkElement instead.
153- */
154- goog . dom . asserts . assertIsHTMLLinkElement = function ( o ) {
155- 'use strict' ;
156- return /** @type {!HTMLLinkElement } */ (
157- goog . dom . asserts . assertIsElementType_ ( o , 'HTMLLinkElement' ) ) ;
158- } ;
159-
160- /**
161- * Asserts that a given object is a HTMLImageElement.
162- *
163- * To permit this assertion to pass in the context of tests where elements might
164- * be mocked, also accepts objects that are not a subtype of Element.
165- *
166- * @param {?Object } o The object whose type to assert.
167- * @return {!HTMLImageElement }
168- * @deprecated Use goog.asserts.dom.assertIsHtmlImageElement instead.
169- */
170- goog . dom . asserts . assertIsHTMLImageElement = function ( o ) {
171- 'use strict' ;
172- return /** @type {!HTMLImageElement } */ (
173- goog . dom . asserts . assertIsElementType_ ( o , 'HTMLImageElement' ) ) ;
174- } ;
175-
176- /**
177- * Asserts that a given object is a HTMLAudioElement.
178- *
179- * To permit this assertion to pass in the context of tests where elements might
180- * be mocked, also accepts objects that are not a subtype of Element.
181- *
182- * @param {?Object } o The object whose type to assert.
183- * @return {!HTMLAudioElement }
184- * @deprecated Use goog.asserts.dom.assertIsHtmlAudioElement instead.
185- */
186- goog . dom . asserts . assertIsHTMLAudioElement = function ( o ) {
187- 'use strict' ;
188- return /** @type {!HTMLAudioElement } */ (
189- goog . dom . asserts . assertIsElementType_ ( o , 'HTMLAudioElement' ) ) ;
190- } ;
191-
192- /**
193- * Asserts that a given object is a HTMLVideoElement.
194- *
195- * To permit this assertion to pass in the context of tests where elements might
196- * be mocked, also accepts objects that are not a subtype of Element.
197- *
198- * @param {?Object } o The object whose type to assert.
199- * @return {!HTMLVideoElement }
200- * @deprecated Use goog.asserts.dom.assertIsHtmlVideoElement instead.
201- */
202- goog . dom . asserts . assertIsHTMLVideoElement = function ( o ) {
203- 'use strict' ;
204- return /** @type {!HTMLVideoElement } */ (
205- goog . dom . asserts . assertIsElementType_ ( o , 'HTMLVideoElement' ) ) ;
206- } ;
207-
208- /**
209- * Asserts that a given object is a HTMLInputElement.
210- *
211- * To permit this assertion to pass in the context of tests where elements might
212- * be mocked, also accepts objects that are not a subtype of Element.
213- *
214- * @param {?Object } o The object whose type to assert.
215- * @return {!HTMLInputElement }
216- * @deprecated Use goog.asserts.dom.assertIsHtmlInputElement instead.
217- */
218- goog . dom . asserts . assertIsHTMLInputElement = function ( o ) {
219- 'use strict' ;
220- return /** @type {!HTMLInputElement } */ (
221- goog . dom . asserts . assertIsElementType_ ( o , 'HTMLInputElement' ) ) ;
222- } ;
223-
224- /**
225- * Asserts that a given object is a HTMLTextAreaElement.
226- *
227- * To permit this assertion to pass in the context of tests where elements might
228- * be mocked, also accepts objects that are not a subtype of Element.
229- *
230- * @param {?Object } o The object whose type to assert.
231- * @return {!HTMLTextAreaElement }
232- * @deprecated Use goog.asserts.dom.assertIsHtmlTextAreaElement instead.
233- */
234- goog . dom . asserts . assertIsHTMLTextAreaElement = function ( o ) {
235- 'use strict' ;
236- return /** @type {!HTMLTextAreaElement } */ (
237- goog . dom . asserts . assertIsElementType_ ( o , 'HTMLTextAreaElement' ) ) ;
238- } ;
239-
240- /**
241- * Asserts that a given object is a HTMLCanvasElement.
242- *
243- * To permit this assertion to pass in the context of tests where elements might
244- * be mocked, also accepts objects that are not a subtype of Element.
245- *
246- * @param {?Object } o The object whose type to assert.
247- * @return {!HTMLCanvasElement }
248- * @deprecated Use goog.asserts.dom.assertIsHtmlCanvasElement instead.
249- */
250- goog . dom . asserts . assertIsHTMLCanvasElement = function ( o ) {
251- 'use strict' ;
252- return /** @type {!HTMLCanvasElement } */ (
253- goog . dom . asserts . assertIsElementType_ ( o , 'HTMLCanvasElement' ) ) ;
254- } ;
255-
256- /**
257- * Asserts that a given object is a HTMLEmbedElement.
258- *
259- * To permit this assertion to pass in the context of tests where elements might
260- * be mocked, also accepts objects that are not a subtype of Element.
261- *
262- * @param {?Object } o The object whose type to assert.
263- * @return {!HTMLEmbedElement }
264- * @deprecated Use goog.asserts.dom.assertIsHtmlEmbedElement instead.
265- */
266- goog . dom . asserts . assertIsHTMLEmbedElement = function ( o ) {
267- 'use strict' ;
268- return /** @type {!HTMLEmbedElement } */ (
269- goog . dom . asserts . assertIsElementType_ ( o , 'HTMLEmbedElement' ) ) ;
270- } ;
271-
272- /**
273- * Asserts that a given object is a HTMLFormElement.
274- *
275- * To permit this assertion to pass in the context of tests where elements might
276- * be mocked, also accepts objects that are not a subtype of Element.
277- *
278- * @param {?Object } o The object whose type to assert.
279- * @return {!HTMLFormElement }
280- * @deprecated Use goog.asserts.dom.assertIsHtmlFormElement instead.
281- */
282- goog . dom . asserts . assertIsHTMLFormElement = function ( o ) {
283- 'use strict' ;
284- return /** @type {!HTMLFormElement } */ (
285- goog . dom . asserts . assertIsElementType_ ( o , 'HTMLFormElement' ) ) ;
286- } ;
287-
288- /**
289- * Asserts that a given object is a HTMLFrameElement.
290- *
291- * To permit this assertion to pass in the context of tests where elements might
292- * be mocked, also accepts objects that are not a subtype of Element.
293- *
294- * @param {?Object } o The object whose type to assert.
295- * @return {!HTMLFrameElement }
296- * @deprecated Use goog.asserts.dom.assertIsHtmlFrameElement instead.
297- */
298- goog . dom . asserts . assertIsHTMLFrameElement = function ( o ) {
299- 'use strict' ;
300- return /** @type {!HTMLFrameElement } */ (
301- goog . dom . asserts . assertIsElementType_ ( o , 'HTMLFrameElement' ) ) ;
302- } ;
303-
304- /**
305- * Asserts that a given object is a HTMLIFrameElement.
306- *
307- * To permit this assertion to pass in the context of tests where elements might
308- * be mocked, also accepts objects that are not a subtype of Element.
309- *
310- * @param {?Object } o The object whose type to assert.
311- * @return {!HTMLIFrameElement }
312- * @deprecated Use goog.asserts.dom.assertIsHtmlIFrameElement instead.
313- */
314- goog . dom . asserts . assertIsHTMLIFrameElement = function ( o ) {
315- 'use strict' ;
316- return /** @type {!HTMLIFrameElement } */ (
317- goog . dom . asserts . assertIsElementType_ ( o , 'HTMLIFrameElement' ) ) ;
318- } ;
319-
320- /**
321- * Asserts that a given object is a HTMLObjectElement.
322- *
323- * To permit this assertion to pass in the context of tests where elements might
324- * be mocked, also accepts objects that are not a subtype of Element.
325- *
326- * @param {?Object } o The object whose type to assert.
327- * @return {!HTMLObjectElement }
328- * @deprecated Use goog.asserts.dom.assertIsHtmlObjectElement instead.
329- */
330- goog . dom . asserts . assertIsHTMLObjectElement = function ( o ) {
331- 'use strict' ;
332- return /** @type {!HTMLObjectElement } */ (
333- goog . dom . asserts . assertIsElementType_ ( o , 'HTMLObjectElement' ) ) ;
334- } ;
335-
336- /**
337- * Asserts that a given object is a HTMLScriptElement.
338- *
339- * To permit this assertion to pass in the context of tests where elements might
340- * be mocked, also accepts objects that are not a subtype of Element.
341- *
342- * @param {?Object } o The object whose type to assert.
343- * @return {!HTMLScriptElement }
344- * @deprecated Use goog.asserts.dom.assertIsHtmlScriptElement instead.
345- */
346- goog . dom . asserts . assertIsHTMLScriptElement = function ( o ) {
347- 'use strict' ;
348- return /** @type {!HTMLScriptElement } */ (
349- goog . dom . asserts . assertIsElementType_ ( o , 'HTMLScriptElement' ) ) ;
350- } ;
351-
35271/**
35372 * Returns a string representation of a value's type.
35473 *
0 commit comments