1/*
2 * Copyright (C) 2011 Google Inc. All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 *     * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *     * Redistributions in binary form must reproduce the above
11 * copyright notice, this list of conditions and the following disclaimer
12 * in the documentation and/or other materials provided with the
13 * distribution.
14 *     * Neither the name of Google Inc. nor the names of its
15 * contributors may be used to endorse or promote products derived from
16 * this software without specific prior written permission.
17 *
18 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
19 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
20 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
21 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
22 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
23 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 */
30
31// WebKit Web Facing API
32
33/**
34 * @param {!Object} object
35 * @param {!Function} callback
36 */
37Object.observe = function(object, callback) {}
38
39/** @type {boolean} */
40Event.prototype.isMetaOrCtrlForTest;
41
42/**
43 * @type {number}
44 */
45KeyboardEvent.DOM_KEY_LOCATION_NUMPAD;
46
47/**
48 * @param {string} eventName
49 * @param {!Function} listener
50 * @param {boolean=} capturing
51 */
52function addEventListener(eventName, listener, capturing) {}
53
54/**
55 * @param {!T} value
56 * @param {boolean=} onlyFirst
57 * @this {Array.<T>}
58 * @template T
59 */
60Array.prototype.remove = function(value, onlyFirst) {}
61/**
62 * @param {!Array.<!T>} array
63 * @this {Array.<!T>}
64 * @template T
65 */
66Array.prototype.pushAll = function(array) {}
67/**
68 * @return {!Object.<string, boolean>}
69 * @this {Array.<T>}
70 * @template T
71 */
72Array.prototype.keySet = function() {}
73/**
74 * @param {number} index
75 * @return {!Array.<!T>}
76 * @this {Array.<T>}
77 * @template T
78 */
79Array.prototype.rotate = function(index) {}
80/**
81 * @this {Array.<number>}
82 */
83Array.prototype.sortNumbers = function() {}
84/**
85 * @param {!T} object
86 * @param {function(!T,!S):number=} comparator
87 * @return {number}
88 * @this {Array.<S>}
89 * @template T,S
90 */
91Array.prototype.lowerBound = function(object, comparator) {}
92/**
93 * @param {!T} object
94 * @param {function(!T,!S):number=} comparator
95 * @return {number}
96 * @this {Array.<S>}
97 * @template T,S
98 */
99Array.prototype.upperBound = function(object, comparator) {}
100/**
101 * @param {!T} value
102 * @param {function(!T,!S):number} comparator
103 * @return {number}
104 * @this {Array.<S>}
105 * @template T,S
106 */
107Array.prototype.binaryIndexOf = function(value, comparator) {}
108/**
109 * @param {function(number, number): number} comparator
110 * @param {number} leftBound
111 * @param {number} rightBound
112 * @param {number} sortWindowLeft
113 * @param {number} sortWindowRight
114 * @return {!Array.<number>}
115 * @this {Array.<number>}
116 */
117Array.prototype.sortRange = function(comparator, leftBound, rightBound, sortWindowLeft, sortWindowRight) {}
118
119/**
120 * @param {function(!T,!T): number=} comparator
121 * @return {!Array.<T>}
122 * @this {Array.<T>}
123 * @template T
124 */
125Array.prototype.stableSort = function(comparator) {}
126
127/**
128 * @this {Array.<number>}
129 * @param {function(number,number):boolean} comparator
130 * @param {number} left
131 * @param {number} right
132 * @param {number} pivotIndex
133 * @return {number}
134 */
135Array.prototype.partition = function(comparator, left, right, pivotIndex) {}
136
137/**
138 * @this {Array.<number>}
139 * @param {number} k
140 * @param {function(number,number):boolean=} comparator
141 * @return {number}
142 */
143Array.prototype.qselect = function(k, comparator) {}
144
145/**
146 * @param {string} field
147 * @return {!Array.<!T>}
148 * @this {Array.<!Object.<string,T>>}
149 * @template T
150 */
151Array.prototype.select = function(field) {}
152
153/**
154 * @return {!T|undefined}
155 * @this {Array.<T>}
156 * @template T
157 */
158Array.prototype.peekLast = function() {}
159
160/**
161 * @param {!Array.<T>} array
162 * @param {function(T,T):number} comparator
163 * @return {!Array.<T>}
164 * @this {!Array.<T>}
165 * @template T
166 */
167Array.prototype.intersectOrdered = function(array, comparator) {}
168
169/**
170 * @param {!Array.<T>} array
171 * @param {function(T,T):number} comparator
172 * @return {!Array.<T>}
173 * @this {!Array.<T>}
174 * @template T
175 */
176Array.prototype.mergeOrdered = function(array, comparator) {}
177
178// File System API
179/**
180 * @constructor
181 */
182function DOMFileSystem() {}
183
184/**
185 * @type {DirectoryEntry}
186 */
187DOMFileSystem.prototype.root = null;
188
189// FIXME: remove everything below.
190var FormatterWorker = {}
191var WebInspector = {}
192
193WebInspector.panels = {};
194
195WebInspector.reload = function() { }
196
197/** Extensions API */
198
199/** @constructor */
200function AuditCategory() {}
201/** @constructor */
202function AuditResult() {}
203/** @constructor */
204function EventSink() {}
205/** @constructor */
206function ExtensionSidebarPane() {}
207/** @constructor */
208function Panel() {}
209/** @constructor */
210function PanelWithSidebar() {}
211/** @constructor */
212function Request() {}
213/** @constructor */
214function Resource() {}
215/** @constructor */
216function Timeline() {}
217
218var extensionServer;
219
220/**
221 * @constructor
222 */
223function ExtensionDescriptor() {
224    this.startPage = "";
225    this.name = "";
226}
227
228/**
229 * @constructor
230 */
231function ExtensionReloadOptions() {
232    this.ignoreCache = false;
233    this.injectedScript = "";
234    this.preprocessingScript = "";
235    this.userAgent = "";
236}
237
238/* jsdifflib API */
239var difflib = {};
240difflib.stringAsLines = function(text) { return []; }
241/** @constructor */
242difflib.SequenceMatcher = function(baseText, newText) { }
243difflib.SequenceMatcher.prototype.get_opcodes = function() { return []; }
244
245/** @constructor */
246var Doc = function() { }
247Doc.prototype = {
248    /** @type {number} */
249    scrollLeft: 0,
250    /** @type {number} */
251    scrollTop: 0
252}
253
254/** @constructor */
255var CodeMirror = function(element, config) { }
256CodeMirror.on = function(obj, type, handler) { }
257CodeMirror.prototype = {
258    /** @type {!Doc} */
259    doc: null,
260    addKeyMap: function(map) { },
261    addLineClass: function(handle, where, cls) { },
262    /** @param {?Object=} options */
263    addLineWidget: function(handle, node, options) { },
264    /**
265     * @param {string|!Object} spec
266     * @param {!Object=} options
267     */
268    addOverlay: function(spec, options) { },
269    addWidget: function(pos, node, scroll, vert, horiz) { },
270    charCoords: function(pos, mode) { },
271    clearGutter: function(gutterID) { },
272    clearHistory: function() { },
273    clipPos: function(pos) { },
274    /** @param {string=} mode */
275    coordsChar: function(coords, mode) { },
276    /** @param {string=} mode */
277    cursorCoords: function(start, mode) { },
278    defaultCharWidth: function() { },
279    defaultTextHeight: function() { },
280    deleteH: function(dir, unit) { },
281    /**
282     * @param {*=} to
283     * @param {*=} op
284     */
285    eachLine: function(from, to, op) { },
286    execCommand: function(cmd) { },
287    extendSelection: function(from, to) { },
288    findMarksAt: function(pos) { },
289    /**
290     * @param {!CodeMirror.Pos} from
291     * @param {boolean=} strict
292     * @param {Object=} config
293     */
294    findMatchingBracket: function(from, strict, config) { },
295    findPosH: function(from, amount, unit, visually) { },
296    findPosV: function(from, amount, unit, goalColumn) { },
297    firstLine: function() { },
298    focus: function() { },
299    getAllMarks: function() { },
300    /** @param {string=} start */
301    getCursor: function(start) { },
302    getDoc: function() { },
303    getGutterElement: function() { },
304    getHistory: function() { },
305    getInputField: function(){ },
306    getLine: function(line) { },
307    /**
308     * @return {!{wrapClass: string}}
309     */
310    getLineHandle: function(line) { },
311    getLineNumber: function(line) { },
312    getMode: function() { },
313    getOption: function(option) { },
314    /** @param {*=} lineSep */
315    getRange: function(from, to, lineSep) { },
316    /**
317     * @return {!{left: number, top: number, width: number, height: number, clientWidth: number, clientHeight: number}}
318     */
319    getScrollInfo: function() { },
320    getScrollerElement: function() { },
321    getSelection: function() { },
322    getSelections: function() { },
323    getStateAfter: function(line) { },
324    getTokenAt: function(pos) { },
325    /** @param {*=} lineSep */
326    getValue: function(lineSep) { },
327    getViewport: function() { },
328    getWrapperElement: function() { },
329    hasFocus: function() { },
330    historySize: function() { },
331    indentLine: function(n, dir, aggressive) { },
332    indentSelection: function(how) { },
333    indexFromPos: function(coords) { },
334    isClean: function() { },
335    iterLinkedDocs: function(f) { },
336    lastLine: function() { },
337    lineCount: function() { },
338    lineInfo: function(line) { },
339    /**
340     * @param {number} height
341     * @param {string=} mode
342     */
343    lineAtHeight: function(height, mode) { },
344    linkedDoc: function(options) { },
345    listSelections: function() { },
346    markClean: function() { },
347    markText: function(from, to, options) { },
348    moveH: function(dir, unit) { },
349    moveV: function(dir, unit) { },
350    off: function(type, f) { },
351    on: function(type, f) { },
352    operation: function(f) { },
353    posFromIndex: function(off) { },
354    redo: function() { },
355    refresh: function() { },
356    removeKeyMap: function(map) { },
357    removeLine: function(line) { },
358    removeLineClass: function(handle, where, cls) { },
359    removeLineWidget: function(widget) { },
360    removeOverlay: function(spec) { },
361    /** @param {*=} origin */
362    replaceRange: function(code, from, to, origin) { },
363    /**
364     * @param {string} replacement
365     * @param {string=} select
366     */
367    replaceSelection: function(replacement, select) { },
368    /**
369     * @param {!Array.<string>} textPerSelection
370     */
371    replaceSelections: function(textPerSelection) { },
372    /** @param {*=} margin */
373    scrollIntoView: function(pos, margin) { },
374    scrollTo: function(x, y) { },
375    setBookmark: function(pos, options) { },
376    setCursor: function(line, ch, extend) { },
377    setExtending: function(val) { },
378    setGutterMarker: function(line, gutterID, value) { },
379    setHistory: function(histData) { },
380    setLine: function(line, text) { },
381    setOption: function(option, value) { },
382    setSelection: function(anchor, head) { },
383    /**
384     * @param {number=} primaryIndex
385     * @param {?Object=} config
386     */
387    setSelections: function(selections, primaryIndex, config) { },
388    setSize: function(width, height) { },
389    setValue: function(code) { },
390    somethingSelected: function() { },
391    swapDoc: function(doc) { },
392    undo: function() { },
393    unlinkDoc: function(other) { }
394}
395/** @type {!{cursorDiv: Element}} */
396CodeMirror.prototype.display;
397/** @type {!Object} */
398CodeMirror.Pass;
399CodeMirror.showHint = function(codeMirror, hintintFunction) { };
400CodeMirror.commands = {};
401CodeMirror.modes = {};
402CodeMirror.mimeModes = {};
403CodeMirror.getMode = function(options, spec) { };
404CodeMirror.overlayMode = function(mode1, mode2, squashSpans) { };
405CodeMirror.defineMode = function(modeName, modeConstructor) { };
406CodeMirror.startState = function(mode) { };
407
408/** @constructor */
409CodeMirror.Pos = function(line, ch) { }
410/** @type {number} */
411CodeMirror.Pos.prototype.line;
412/** @type {number} */
413CodeMirror.Pos.prototype.ch;
414
415/**
416 * @param {!CodeMirror.Pos} pos1
417 * @param {!CodeMirror.Pos} pos2
418 * @return {number}
419 */
420CodeMirror.cmpPos = function(pos1, pos2) { };
421
422/** @constructor */
423CodeMirror.StringStream = function(line)
424{
425    this.pos = 0;
426    this.start = 0;
427}
428CodeMirror.StringStream.prototype = {
429    backUp: function (n) { },
430    column: function () { },
431    current: function () { },
432    eat: function (match) { },
433    eatSpace: function () { },
434    eatWhile: function (match) { },
435    eol: function () { },
436    indentation: function () { },
437    /**
438     * @param {!RegExp|string} pattern
439     * @param {boolean=} consume
440     * @param {boolean=} caseInsensitive
441     */
442    match: function (pattern, consume, caseInsensitive) { },
443    next: function () { },
444    peek: function () { },
445    skipTo: function (ch) { },
446    skipToEnd: function () { },
447    sol: function () { }
448}
449
450/** @type {Object.<string, !Object.<string, string>>} */
451CodeMirror.keyMap;
452
453/** @type {{scrollLeft: number, scrollTop: number}} */
454CodeMirror.doc;
455
456/**
457 * @constructor
458 * @extends {Event}
459 */
460function ErrorEvent() {}
461
462/** @type {string} */
463ErrorEvent.prototype.message;
464
465/** @type {boolean} */
466window.dispatchStandaloneTestRunnerMessages;
467
468/**
469 * @param {function()} onCatch
470 */
471Promise.prototype.catch = function(onCatch) {};
472
473// FIXME: Remove once ES6 is supported natively by JS compiler.
474
475/** @typedef {string} */
476var symbol;
477
478/**
479 * @param {string} description
480 * @return {symbol}
481 */
482function Symbol(description) {}
483