1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 // This file contains various hacks needed to inform JSCompiler of various
6 // WebKit- and Chrome-specific properties and methods. It is used only with
7 // JSCompiler to verify the type-correctness of our code.
9 /** @type {Array<string>} */
10 ClipboardData
.prototype.types
;
12 /** @type {HTMLElement} */
13 Document
.prototype.activeElement
;
15 /** @type {Array<HTMLElement>} */
16 Document
.prototype.all
;
18 /** @type {boolean} */
19 Document
.prototype.hidden
;
21 /** @return {void} Nothing. */
22 Document
.prototype.exitPointerLock = function() {};
24 /** @type {boolean} */
25 Document
.prototype.webkitIsFullScreen
;
27 /** @type {boolean} */
28 Document
.prototype.webkitHidden
;
30 /** @type {Element} */
31 Document
.prototype.firstElementChild
;
33 /** @return {void} Nothing. */
34 Element
.prototype.requestPointerLock = function() {};
36 /** @type {boolean} */
37 Element
.prototype.disabled
;
39 /** @type {boolean} */
40 Element
.prototype.hidden
;
43 Element
.prototype.innerText
;
46 Element
.prototype.localName
;
49 Element
.prototype.offsetRight
;
52 Element
.prototype.offsetBottom
;
55 Element
.prototype.textContent
;
57 /** @type {DOMTokenList} */
58 Element
.prototype.classList
;
60 /** @type {boolean} */
61 Element
.prototype.checked
;
64 HTMLIFrameElement
.prototype.contentWindow
;
67 * @param {string} selector
68 * @return {?HTMLElement}.
70 HTMLElement
.prototype.querySelector = function(selector
) {};
73 * @param {string} name
76 Node
.prototype.getAttribute = function(name
) { };
81 /** @type {{top: string, left: string, bottom: string, right: string}} */
84 /** @type {boolean} */
85 Node
.prototype.hidden
;
88 /** @type {{getRandomValues: function(!ArrayBufferView):!ArrayBufferView}} */
89 Window
.prototype.crypto
;
93 * @type {DataTransfer}
95 Event
.prototype.dataTransfer
= null;
100 Event
.prototype.movementX
= 0;
105 Event
.prototype.movementY
= 0;
108 * @param {string} type
109 * @param {boolean} canBubble
110 * @param {boolean} cancelable
111 * @param {Window} view
112 * @param {number} detail
113 * @param {number} screenX
114 * @param {number} screenY
115 * @param {number} clientX
116 * @param {number} clientY
117 * @param {boolean} ctrlKey
118 * @param {boolean} altKey
119 * @param {boolean} shiftKey
120 * @param {boolean} metaKey
121 * @param {number} button
122 * @param {EventTarget} relatedTarget
124 Event
.prototype.initMouseEvent = function(
125 type
, canBubble
, cancelable
, view
, detail
,
126 screenX
, screenY
, clientX
, clientY
,
127 ctrlKey
, altKey
, shiftKey
, metaKey
,
128 button
, relatedTarget
) {};
130 /** @type {Object} */
131 Event
.prototype.data
= {};
133 // Chrome implements XMLHttpRequest.responseURL starting from Chrome 37.
134 /** @type {string} */
135 XMLHttpRequest
.prototype.responseURL
= "";
138 /*******************************************************************************
139 * Webview and related declarations
140 ******************************************************************************/
143 * Like chrome.webRequest, but for webview tags.
145 * chrome.webRequest defined in chrome_extensions.js can't be
146 * used because it's not a type.
150 function WebviewWebRequest() {}
152 /** @type {WebRequestEvent} */
153 WebviewWebRequest
.prototype.onBeforeSendHeaders
;
155 /** @type {WebRequestEvent} */
156 WebviewWebRequest
.prototype.onCompleted
;
158 /** @type {WebRequestOnErrorOccurredEvent} */
159 WebviewWebRequest
.prototype.onErrorOccurred
;
162 * Enable access to special APIs of webview DOM element.
165 * @extends {HTMLElement}
167 function Webview() {}
169 /** @type {!WebviewWebRequest} */
170 Webview
.prototype.request
;
172 /** @type {function(InjectDetails, function(Object))} */
173 Webview
.prototype.executeScript
;
175 /** @type {Window} */
176 Webview
.prototype.contentWindow
;
179 * See https://developer.chrome.com/apps/tags/webview#type-InjectDetails
182 * file: (string|undefined),
183 * code: (string|undefined)
188 /*******************************************************************************
189 * ConsoleMessage event
190 ******************************************************************************/
193 * The consolemessage BrowserEvent contains these fields:
194 * e.level: int32, log severity level (for exception/info etc)
195 * e.line: int32, line number
196 * e.message: string, the console message
197 * e.sourceId: string, source identifier (the ones seen in devtools)
202 chrome
.ConsoleMessageBrowserEvent = function() {};
204 /** @type {number} */
205 chrome
.ConsoleMessageBrowserEvent
.prototype.level
;
207 /** @type {number} */
208 chrome
.ConsoleMessageBrowserEvent
.prototype.line
;
210 /** @type {string} */
211 chrome
.ConsoleMessageBrowserEvent
.prototype.message
;
213 /** @type {string} */
214 chrome
.ConsoleMessageBrowserEvent
.prototype.sourceId
;