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
32var console = {}
33/** @param {...*} vararg */
34console.warn = function(vararg) {}
35/** @param {...*} vararg */
36console.assert = function(vararg) {}
37/** @param {...*} vararg */
38console.error = function(vararg) {}
39console.trace = function() {}
40
41/** @type {boolean} */
42Event.prototype.isMetaOrCtrlForTest = false;
43/** @param {...*} vararg */
44Event.prototype.initWebKitWheelEvent = function(vararg) {}
45Event.prototype.stopImmediatePropagation = function() {}
46
47/**
48 * @constructor
49 * @extends {KeyboardEvent}
50 * @param {string} eventType
51 * @param {Object=} properties
52 */
53window.KeyboardEvent = function(eventType, properties) {}
54
55/** @param {Element} element */
56window.getComputedStyle = function(element) {}
57/** @param {*} message */
58function postMessage(message) {}
59
60/** @type {*} */
61window.testRunner = null;
62
63/**
64 * @constructor
65 */
66function WebKitMutation(callback)
67{
68    this.type = "";
69    /** @type {Node} */ this.target = null;
70    /** @type {Array.<Node>} */ this.addedNodes = [];
71    /** @type {Array.<Node>} */ this.removedNodes = [];
72}
73
74/**
75 * @constructor
76 * @param {function(Array.<WebKitMutation>)} callback
77 */
78function WebKitMutationObserver(callback) {}
79/**
80 * @param {Node} container
81 * @param {Object} options
82 */
83WebKitMutationObserver.prototype.observe = function(container, options) {}
84WebKitMutationObserver.prototype.disconnect = function() {}
85
86/**
87 * @param {string} eventName
88 * @param {Function} listener
89 * @param {boolean=} capturing
90 */
91function addEventListener(eventName, listener, capturing) {}
92
93/**
94 * @param {T} value
95 * @param {boolean=} onlyFirst
96 * @this {Array.<T>}
97 * @template T
98 */
99Array.prototype.remove = function(value, onlyFirst) {}
100/**
101 * @return {!Object.<string, boolean>}
102 * @this {Array.<*>}
103 */
104Array.prototype.keySet = function() {}
105/**
106 * @param {number} index
107 * @return {!Array.<T>}
108 * @this {Array.<T>}
109 * @template T
110 */
111Array.prototype.rotate = function(index) {}
112/**
113 * @param {T} object
114 * @param {function(T,S):number=} comparator
115 * @return {number}
116 * @this {Array.<S>}
117 * @template T,S
118 */
119Array.prototype.lowerBound = function(object, comparator) {}
120/**
121 * @param {T} object
122 * @param {function(T,S):number=} comparator
123 * @return {number}
124 * @this {Array.<S>}
125 * @template T,S
126 */
127Array.prototype.upperBound = function(object, comparator) {}
128/**
129 * @param {T} value
130 * @param {function(T,S):number} comparator
131 * @return {number}
132 * @this {Array.<S>}
133 * @template T,S
134 */
135Array.prototype.binaryIndexOf = function(value, comparator) {}
136/**
137 * @param {function(number, number): number} comparator
138 * @param {number} leftBound
139 * @param {number} rightBound
140 * @param {number} k
141 * @return {!Array.<number>}
142 * @this {Array.<number>}
143 */
144Array.prototype.sortRange = function(comparator, leftBound, rightBound, k) {}
145
146/**
147 * @this {Array.<number>}
148 * @param {function(number,number):boolean} comparator
149 * @param {number} left
150 * @param {number} right
151 * @param {number} pivotIndex
152 * @return {number}
153 */
154Array.prototype.partition = function(comparator, left, right, pivotIndex) {}
155
156/**
157 * @this {Array.<number>}
158 * @param {number} k
159 * @param {function(number,number):boolean=} comparator
160 * @return {number}
161 */
162Array.prototype.qselect = function(k, comparator) {}
163
164/**
165 * @param {string} field
166 * @return {!Array.<T>}
167 * @this {Array.<Object.<string,T>>}
168 * @template T
169 */
170Array.prototype.select = function(field) {}
171
172/**
173 * @return {T|undefined}
174 * @this {Array.<T>}
175 * @template T
176 */
177Array.prototype.peekLast = function() {}
178
179DOMApplicationCache.prototype.UNCACHED = 0;
180DOMApplicationCache.prototype.IDLE = 1;
181DOMApplicationCache.prototype.CHECKING = 2;
182DOMApplicationCache.prototype.DOWNLOADING = 3;
183DOMApplicationCache.prototype.UPDATEREADY = 4;
184DOMApplicationCache.prototype.OBSOLETE = 5;
185
186// File System API
187/**
188 * @constructor
189 */
190function DOMFileSystem() {}
191
192/**
193 * @type {DirectoryEntry}
194 */
195DOMFileSystem.prototype.root = null;
196
197/** @type {Node} */
198Range.prototype.startContainer;
199
200// Inspector Backend
201var InspectorBackend = {}
202InspectorBackend.runAfterPendingDispatches = function(message) {}
203
204/** @interface */
205function InspectorFrontendHostAPI() {}
206InspectorFrontendHostAPI.prototype.platform = function() {}
207InspectorFrontendHostAPI.prototype.port = function() {}
208InspectorFrontendHostAPI.prototype.bringToFront = function() {}
209InspectorFrontendHostAPI.prototype.closeWindow = function() {}
210InspectorFrontendHostAPI.prototype.requestSetDockSide = function(dockSide) {}
211InspectorFrontendHostAPI.prototype.setAttachedWindowHeight = function(height) {}
212InspectorFrontendHostAPI.prototype.moveWindowBy = function(x, y) {}
213InspectorFrontendHostAPI.prototype.setInjectedScriptForOrigin = function(origin, script) {}
214InspectorFrontendHostAPI.prototype.loaded = function() {}
215InspectorFrontendHostAPI.prototype.localizedStringsURL = function() {}
216InspectorFrontendHostAPI.prototype.inspectedURLChanged = function(url) {}
217InspectorFrontendHostAPI.prototype.documentCopy = function(event) {}
218InspectorFrontendHostAPI.prototype.copyText = function(text) {}
219InspectorFrontendHostAPI.prototype.openInNewTab = function(url) {}
220InspectorFrontendHostAPI.prototype.canSave = function() {}
221InspectorFrontendHostAPI.prototype.save = function(url, content, forceSaveAs) {}
222InspectorFrontendHostAPI.prototype.close = function(url) {}
223InspectorFrontendHostAPI.prototype.append = function(url, content) {}
224InspectorFrontendHostAPI.prototype.sendMessageToBackend = function(message) {}
225InspectorFrontendHostAPI.prototype.recordActionTaken = function(actionCode) {}
226InspectorFrontendHostAPI.prototype.recordPanelShown = function(panelCode) {}
227InspectorFrontendHostAPI.prototype.recordSettingChanged = function(settingCode) {}
228InspectorFrontendHostAPI.prototype.loadResourceSynchronously = function(url) {}
229InspectorFrontendHostAPI.prototype.supportsFileSystems = function() {}
230InspectorFrontendHostAPI.prototype.requestFileSystems = function() {}
231InspectorFrontendHostAPI.prototype.addFileSystem = function() {}
232InspectorFrontendHostAPI.prototype.removeFileSystem = function(fileSystemPath) {}
233InspectorFrontendHostAPI.prototype.isolatedFileSystem = function(fileSystemId, registeredName) {}
234InspectorFrontendHostAPI.prototype.indexPath = function(requestId, fileSystemPath) {}
235InspectorFrontendHostAPI.prototype.stopIndexing = function(requestId) {}
236InspectorFrontendHostAPI.prototype.searchInPath = function(requestId, fileSystemPath, query) {}
237InspectorFrontendHostAPI.prototype.setZoomFactor = function(zoom) {}
238/** @type {InspectorFrontendHostAPI} */
239var InspectorFrontendHost;
240
241/** @constructor */
242function SourceMapV3()
243{
244    /** @type {number} */ this.version;
245    /** @type {string} */ this.file;
246    /** @type {Array.<string>} */ this.sources;
247    /** @type {Array.<SourceMapV3.Section>} */ this.sections;
248    /** @type {string} */ this.mappings;
249    /** @type {string} */ this.sourceRoot;
250}
251
252/** @constructor */
253SourceMapV3.Section = function()
254{
255    /** @type {SourceMapV3} */ this.map;
256    /** @type {SourceMapV3.Offset} */ this.offset;
257}
258
259/** @constructor */
260SourceMapV3.Offset = function()
261{
262    /** @type {number} */ this.line;
263    /** @type {number} */ this.column;
264}
265
266// FIXME: remove everything below.
267var WebInspector = {}
268
269WebInspector.queryParamsObject = {}
270WebInspector.toggleSearchingForNode = function() {}
271WebInspector.panels = {};
272
273/**
274 * @param {Element} element
275 * @param {function()=} onclose
276 */
277WebInspector.showViewInDrawer = function(element, view, onclose) {}
278
279WebInspector.closeViewInDrawer = function() {}
280
281/**
282 * @param {string=} messageLevel
283 * @param {boolean=} showConsole
284 */
285WebInspector.log = function(message, messageLevel, showConsole) {}
286
287WebInspector.showErrorMessage = function(error) {}
288
289WebInspector.addMainEventListeners = function(doc) {}
290
291WebInspector.openResource = function(url, external) {}
292
293WebInspector.showConsole = function() {}
294
295/**
296 * @param {string} expression
297 * @param {boolean=} showResultOnly
298 */
299WebInspector.evaluateInConsole = function(expression, showResultOnly) {}
300
301WebInspector.queryParamsObject = {}
302
303/**
304 * @param {Element} element
305 */
306WebInspector.showAnchorLocation = function(element) {}
307
308WebInspector.Events = {
309    InspectorLoaded: "InspectorLoaded",
310    InspectorClosing: "InspectorClosing"
311}
312
313/** @type {WebInspector.SettingsController} */
314WebInspector.settingsController;
315
316/** Extensions API */
317
318/** @constructor */
319function AuditCategory() {}
320/** @constructor */
321function AuditResult() {}
322/** @constructor */
323function EventSink() {}
324/** @constructor */
325function ExtensionSidebarPane() {}
326/** @constructor */
327function Panel() {}
328/** @constructor */
329function PanelWithSidebar() {}
330/** @constructor */
331function Request() {}
332/** @constructor */
333function Resource() {}
334/** @constructor */
335function Timeline() {}
336
337var extensionServer;
338
339/** @type {string} */
340Location.prototype.origin = "";
341
342/**
343 * @constructor
344 */
345function ExtensionDescriptor() {
346    this.startPage = "";
347    this.name = "";
348}
349
350/**
351 * @constructor
352 */
353function ExtensionReloadOptions() {
354    this.ignoreCache = false;
355    this.injectedScript = "";
356    this.userAgent = "";
357}
358
359WebInspector.showPanel = function(panel)
360{
361}
362
363/**
364 * @param {ExtensionDescriptor} extensionInfo
365 * @return {string}
366 */
367function buildPlatformExtensionAPI(extensionInfo) {}
368
369/**
370 * @type {string}
371 */
372WebInspector.inspectedPageDomain;
373
374WebInspector.SourceJavaScriptTokenizer = {}
375WebInspector.SourceJavaScriptTokenizer.Keywords = {}
376
377var InspectorTest = {}
378
379/* jsdifflib API */
380var difflib = {};
381difflib.stringAsLines = function(text) { return []; }
382/** @constructor */
383difflib.SequenceMatcher = function(baseText, newText) { }
384difflib.SequenceMatcher.prototype.get_opcodes = function() { return []; }
385
386/** @constructor */
387var CodeMirror = function() { }
388CodeMirror.on = function(obj, type, handler) { }
389CodeMirror.prototype = {
390    addKeyMap: function(map) { },
391    addLineClass: function(handle, where, cls) { },
392    addLineWidget: function(handle, node, options) { },
393    /**
394     * @param {string|Object} spec
395     * @param {Object=} options
396     */
397    addOverlay: function(spec, options) { },
398    addWidget: function(pos, node, scroll, vert, horiz) { },
399    charCoords: function(pos, mode) { },
400    clearGutter: function(gutterID) { },
401    clearHistory: function() { },
402    clipPos: function(pos) { },
403    coordsChar: function(coords, mode) { },
404    cursorCoords: function(start, mode) { },
405    defaultCharWidth: function() { },
406    defaultTextHeight: function() { },
407    deleteH: function(dir, unit) { },
408    eachLine: function(from, to, op) { },
409    execCommand: function(cmd) { },
410    extendSelection: function(from, to) { },
411    findMarksAt: function(pos) { },
412    findMatchingBracket: function() { },
413    findPosH: function(from, amount, unit, visually) { },
414    findPosV: function(from, amount, unit, goalColumn) { },
415    firstLine: function() { },
416    focus: function() { },
417    getAllMarks: function() { },
418    /** @param {string=} start */
419    getCursor: function(start) { },
420    getDoc: function() { },
421    getGutterElement: function() { },
422    getHistory: function() { },
423    getInputField: function(){ },
424    getLine: function(line) { },
425    /**
426     * @return {{wrapClass: string}}
427     */
428    getLineHandle: function(line) { },
429    getLineNumber: function(line) { },
430    getMode: function() { },
431    getOption: function(option) { },
432    getRange: function(from, to, lineSep) { },
433    /**
434     * @return {{left: number, top: number, width: number, height: number, clientWidth: number, clientHeight: number}}
435     */
436    getScrollInfo: function() { },
437    getScrollerElement: function() { },
438    getSelection: function() { },
439    getStateAfter: function(line) { },
440    getTokenAt: function(pos) { },
441    getValue: function(lineSep) { },
442    getViewport: function() { },
443    getWrapperElement: function() { },
444    hasFocus: function() { },
445    historySize: function() { },
446    indentLine: function(n, dir, aggressive) { },
447    indentSelection: function(how) { },
448    indexFromPos: function(coords) { },
449    isClean: function() { },
450    iterLinkedDocs: function(f) { },
451    lastLine: function() { },
452    lineCount: function() { },
453    lineInfo: function(line) { },
454    /**
455     * @param {number} height
456     * @param {string=} mode
457     */
458    lineAtHeight: function(height, mode) { },
459    linkedDoc: function(options) { },
460    markClean: function() { },
461    markText: function(from, to, options) { },
462    moveH: function(dir, unit) { },
463    moveV: function(dir, unit) { },
464    off: function(type, f) { },
465    on: function(type, f) { },
466    operation: function(f) { },
467    posFromIndex: function(off) { },
468    redo: function() { },
469    refresh: function() { },
470    removeKeyMap: function(map) { },
471    removeLine: function(line) { },
472    removeLineClass: function(handle, where, cls) { },
473    removeLineWidget: function(widget) { },
474    removeOverlay: function(spec) { },
475    replaceRange: function(code, from, to, origin) { },
476    replaceSelection: function(code, collapse, origin) { },
477    scrollIntoView: function(pos, margin) { },
478    scrollTo: function(x, y) { },
479    setBookmark: function(pos, options) { },
480    setCursor: function(line, ch, extend) { },
481    setExtending: function(val) { },
482    setGutterMarker: function(line, gutterID, value) { },
483    setHistory: function(histData) { },
484    setLine: function(line, text) { },
485    setOption: function(option, value) { },
486    setSelection: function(anchor, head) { },
487    setSize: function(width, height) { },
488    setValue: function(code) { },
489    somethingSelected: function() { },
490    swapDoc: function(doc) { },
491    undo: function() { },
492    unlinkDoc: function(other) { }
493}
494/** @type {number} */
495CodeMirror.prototype.lineCount;
496CodeMirror.Pass;
497CodeMirror.showHint = function(codeMirror, hintintFunction) { };
498CodeMirror.commands = {};
499CodeMirror.modes = {};
500CodeMirror.mimeModes = {};
501CodeMirror.getMode = function(options, spec) { };
502CodeMirror.overlayMode = function(mode1, mode2, squashSpans) { };
503CodeMirror.defineMode = function(modeName, modeConstructor) { };
504
505/** @constructor */
506CodeMirror.Pos = function(line, ch) { }
507/** type {number} */
508CodeMirror.Pos.prototype.line;
509/** type {number} */
510CodeMirror.Pos.prototype.ch;
511
512/** @constructor */
513CodeMirror.StringStream = function() { }
514CodeMirror.StringStream.prototype = {
515    backUp: function (n) { },
516    column: function () { },
517    current: function () { },
518    eat: function (match) { },
519    eatSpace: function () { },
520    eatWhile: function (match) { },
521    eol: function () { },
522    indentation: function () { },
523    /**
524     * @param {RegExp|string} pattern
525     * @param {boolean=} consume
526     * @param {boolean=} caseInsensitive
527     */
528    match: function (pattern, consume, caseInsensitive) { },
529    next: function () { },
530    peek: function () { },
531    skipTo: function (ch) { },
532    skipToEnd: function () { },
533    sol: function () { }
534}
535
536/** @type {Object.<string, Object.<string, string>>} */
537CodeMirror.keyMap;
538
539WebInspector.suggestReload = function() { }
540WebInspector.reload = function() { }
541
542WebInspector.settings.continuousPainting = /** type {WebInspector.Setting} */ { }
543WebInspector.settings.showDebugBorders = /** type {WebInspector.Setting} */ { }
544WebInspector.settings.showScrollBottleneckRects = /** type {WebInspector.Setting} */ { }
545WebInspector.settings.forceCompositingMode = /** type {WebInspector.Setting} */ { }
546WebInspector.settings.showFPSCounter = /** type {WebInspector.Setting} */ { }
547WebInspector.settings.showPaintRects = /** type {WebInspector.Setting} */ { }
548
549/** @type {boolean} */
550window.dispatchStandaloneTestRunnerMessages;
551