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