• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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.
4
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.
8
9/** @type {HTMLElement} */
10Document.prototype.activeElement;
11
12/** @type {Array.<HTMLElement>} */
13Document.prototype.all;
14
15/** @type {boolean} */
16Document.prototype.hidden;
17
18/** @type {function(string): void} */
19Document.prototype.execCommand = function(command) {};
20
21/** @return {void} Nothing. */
22Document.prototype.webkitCancelFullScreen = function() {};
23
24/** @type {boolean} */
25Document.prototype.webkitIsFullScreen;
26
27/** @type {boolean} */
28Document.prototype.webkitHidden;
29
30/** @type {Element} */
31Document.prototype.firstElementChild;
32
33/** @type {number} */
34Element.ALLOW_KEYBOARD_INPUT;
35
36/** @param {number} flags
37/** @return {void} Nothing. */
38Element.prototype.webkitRequestFullScreen = function(flags) {};
39
40/** @type {boolean} */
41Element.prototype.hidden;
42
43/** @type {string} */
44Element.prototype.localName;
45
46/** @type {string} */
47Element.prototype.textContent;
48
49
50/** @constructor
51    @extends {HTMLElement} */
52var HTMLEmbedElement = function() { };
53
54/** @type {number} */
55HTMLEmbedElement.prototype.height;
56
57/** @type {number} */
58HTMLEmbedElement.prototype.width;
59
60/** @type {Window} */
61HTMLIFrameElement.prototype.contentWindow;
62
63
64/** @type {Object} */
65var JSON = {};
66
67/**
68 * @param {string} jsonStr The string to parse.
69 * @param {(function(string, *) : *)=} opt_reviver
70 * @return {*} The JSON object.
71 */
72JSON.parse = function(jsonStr, opt_reviver) {};
73
74/**
75 * @param {*} jsonObj Input object.
76 * @param {(Array.<string>|(function(string, *) : *)|null)=} opt_replacer
77 * @param {(number|string)=} opt_space
78 * @return {string} json string which represents jsonObj.
79 */
80JSON.stringify = function(jsonObj, opt_replacer, opt_space) {};
81
82
83/**
84 * @param {string} name
85 * @return {string}
86 */
87Node.prototype.getAttribute = function(name) { };
88
89/** @type {string} */
90Node.prototype.value;
91
92/** @type {{top: string, left: string, bottom: string, right: string}} */
93Node.prototype.style;
94
95
96/**
97 * @constructor
98 * @param {function(Array.<MutationRecord>):void} callback
99 */
100var MutationObserver = function(callback) {};
101
102/**
103 * @param {Element} element
104 * @param {Object} options
105 */
106MutationObserver.prototype.observe = function(element, options) {};
107
108
109/** @constructor */
110var MutationRecord = function() {};
111
112/** @type {string} */
113MutationRecord.prototype.attributeName;
114
115/** @type {Element} */
116MutationRecord.prototype.target;
117
118/** @type {string} */
119MutationRecord.prototype.type;
120
121
122/** @type {{getRandomValues: function((Uint16Array|Uint8Array)):void}} */
123Window.prototype.crypto;
124
125
126/**
127 * @constructor
128 * @implements {EventTarget} */
129var EventTargetStub = function() {};
130
131/**
132 * @param {string} type
133 * @param {(EventListener|function(Event): (boolean|undefined|null))} listener
134 * @param {boolean=} opt_useCapture
135 */
136EventTargetStub.prototype.addEventListener =
137    function(type, listener, opt_useCapture) {}
138
139/**
140 * @param {string} type
141 * @param {(EventListener|function(Event): (boolean|undefined|null))} listener
142 * @param {boolean=} opt_useCapture
143 */
144EventTargetStub.prototype.removeEventListener =
145    function(type, listener, opt_useCapture) {}
146
147/**
148 * @param {Event} event
149 */
150EventTargetStub.prototype.dispatchEvent =
151    function(event) {}
152
153/**
154 * @constructor
155 * @extends {EventTargetStub}
156 */
157var SourceBuffer = function() {}
158
159/** @type {boolean} */
160SourceBuffer.prototype.updating;
161
162/** @type {TimeRanges} */
163SourceBuffer.prototype.buffered;
164
165/**
166 * @param {ArrayBuffer} buffer
167 */
168SourceBuffer.prototype.appendBuffer = function(buffer) {}
169
170/**
171 * @param {number} start
172 * @param {number} end
173 */
174SourceBuffer.prototype.remove = function(start, end) {}
175
176/**
177 * @constructor
178 * @extends {EventTargetStub}
179 */
180var MediaSource = function() {}
181
182/**
183 * @param {string} format
184 * @return {SourceBuffer}
185 */
186MediaSource.prototype.addSourceBuffer = function(format) {}
187
188/**
189 * @constructor
190 * @param {function(function(*), function(*)) : void} init
191 */
192var Promise = function (init) {};
193
194/**
195 * @param {function(?=) : (Promise|void)} onFulfill
196 * @param {function(?=) : (Promise|void)=} onReject
197 * @return {Promise}
198 */
199Promise.prototype.then = function (onFulfill, onReject) {};
200
201/**
202 * @param {function(*) : void} onReject
203 * @return {Promise}
204 */
205Promise.prototype['catch'] = function (onReject) {};
206
207/**
208 * @param {Array.<Promise>} promises
209 * @return {Promise}
210 */
211Promise.prototype.race = function (promises) {}
212
213/**
214 * @param {Array.<Promise>} promises
215 * @return {Promise}
216 */
217Promise.prototype.all = function (promises) {};
218
219/**
220 * @param {*=} reason
221 * @return {Promise}
222 */
223Promise.reject = function (reason) {};
224
225/**
226 * @param {*=} value
227 * @return {Promise}
228 */
229Promise.resolve = function (value) {};
230
231/**
232 * @param {string} type
233 * @param {boolean} canBubble
234 * @param {boolean} cancelable
235 * @param {Window} view
236 * @param {number} detail
237 * @param {number} screenX
238 * @param {number} screenY
239 * @param {number} clientX
240 * @param {number} clientY
241 * @param {boolean} ctrlKey
242 * @param {boolean} altKey
243 * @param {boolean} shiftKey
244 * @param {boolean} metaKey
245 * @param {number} button
246 * @param {EventTarget} relatedTarget
247 */
248Event.prototype.initMouseEvent = function(
249    type, canBubble, cancelable, view, detail,
250    screenX, screenY, clientX, clientY,
251    ctrlKey, altKey, shiftKey, metaKey,
252    button, relatedTarget) {};
253
254/**
255 * @param {number} begin
256 * @param {number=} end
257 * @return {ArrayBuffer}
258 */
259ArrayBuffer.prototype.slice = function(begin, end) {};
260