Home | History | Annotate | Download | only in front_end
      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 var console = {}
     33 /** @param {...*} vararg */
     34 console.warn = function(vararg) {}
     35 /** @param {...*} vararg */
     36 console.assert = function(vararg) {}
     37 /** @param {...*} vararg */
     38 console.error = function(vararg) {}
     39 console.trace = function() {}
     40 
     41 /** @type {boolean} */
     42 Event.prototype.isMetaOrCtrlForTest = false;
     43 /** @param {...*} vararg */
     44 Event.prototype.initWebKitWheelEvent = function(vararg) {}
     45 Event.prototype.stopImmediatePropagation = function() {}
     46 
     47 /**
     48  * @constructor
     49  * @extends {KeyboardEvent}
     50  * @param {string} eventType
     51  * @param {Object=} properties
     52  */
     53 window.KeyboardEvent = function(eventType, properties) {}
     54 
     55 /** @param {Element} element */
     56 window.getComputedStyle = function(element) {}
     57 /** @param {*} message */
     58 function postMessage(message) {}
     59 
     60 /** @type {*} */
     61 window.testRunner = null;
     62 
     63 /**
     64  * @constructor
     65  */
     66 function 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  */
     78 function WebKitMutationObserver(callback) {}
     79 /**
     80  * @param {Node} container
     81  * @param {Object} options
     82  */
     83 WebKitMutationObserver.prototype.observe = function(container, options) {}
     84 WebKitMutationObserver.prototype.disconnect = function() {}
     85 
     86 /**
     87  * @param {string} eventName
     88  * @param {Function} listener
     89  * @param {boolean=} capturing
     90  */
     91 function addEventListener(eventName, listener, capturing) {}
     92 
     93 /**
     94  * @param {T} value
     95  * @param {boolean=} onlyFirst
     96  * @this {Array.<T>}
     97  * @template T
     98  */
     99 Array.prototype.remove = function(value, onlyFirst) {}
    100 /**
    101  * @return {!Object.<string, boolean>}
    102  * @this {Array.<*>}
    103  */
    104 Array.prototype.keySet = function() {}
    105 /**
    106  * @param {number} index
    107  * @return {!Array.<T>}
    108  * @this {Array.<T>}
    109  * @template T
    110  */
    111 Array.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  */
    119 Array.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  */
    127 Array.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  */
    135 Array.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  */
    144 Array.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  */
    154 Array.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  */
    162 Array.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  */
    170 Array.prototype.select = function(field) {}
    171 
    172 /**
    173  * @return {T|undefined}
    174  * @this {Array.<T>}
    175  * @template T
    176  */
    177 Array.prototype.peekLast = function() {}
    178 
    179 DOMApplicationCache.prototype.UNCACHED = 0;
    180 DOMApplicationCache.prototype.IDLE = 1;
    181 DOMApplicationCache.prototype.CHECKING = 2;
    182 DOMApplicationCache.prototype.DOWNLOADING = 3;
    183 DOMApplicationCache.prototype.UPDATEREADY = 4;
    184 DOMApplicationCache.prototype.OBSOLETE = 5;
    185 
    186 // File System API
    187 /**
    188  * @constructor
    189  */
    190 function DOMFileSystem() {}
    191 
    192 /**
    193  * @type {DirectoryEntry}
    194  */
    195 DOMFileSystem.prototype.root = null;
    196 
    197 /** @type {Node} */
    198 Range.prototype.startContainer;
    199 
    200 // Inspector Backend
    201 var InspectorBackend = {}
    202 InspectorBackend.runAfterPendingDispatches = function(message) {}
    203 
    204 /** @interface */
    205 function InspectorFrontendHostAPI() {}
    206 InspectorFrontendHostAPI.prototype.platform = function() {}
    207 InspectorFrontendHostAPI.prototype.port = function() {}
    208 InspectorFrontendHostAPI.prototype.bringToFront = function() {}
    209 InspectorFrontendHostAPI.prototype.closeWindow = function() {}
    210 InspectorFrontendHostAPI.prototype.requestSetDockSide = function(dockSide) {}
    211 InspectorFrontendHostAPI.prototype.setAttachedWindowHeight = function(height) {}
    212 InspectorFrontendHostAPI.prototype.moveWindowBy = function(x, y) {}
    213 InspectorFrontendHostAPI.prototype.setInjectedScriptForOrigin = function(origin, script) {}
    214 InspectorFrontendHostAPI.prototype.loaded = function() {}
    215 InspectorFrontendHostAPI.prototype.localizedStringsURL = function() {}
    216 InspectorFrontendHostAPI.prototype.inspectedURLChanged = function(url) {}
    217 InspectorFrontendHostAPI.prototype.documentCopy = function(event) {}
    218 InspectorFrontendHostAPI.prototype.copyText = function(text) {}
    219 InspectorFrontendHostAPI.prototype.openInNewTab = function(url) {}
    220 InspectorFrontendHostAPI.prototype.canSave = function() {}
    221 InspectorFrontendHostAPI.prototype.save = function(url, content, forceSaveAs) {}
    222 InspectorFrontendHostAPI.prototype.close = function(url) {}
    223 InspectorFrontendHostAPI.prototype.append = function(url, content) {}
    224 InspectorFrontendHostAPI.prototype.sendMessageToBackend = function(message) {}
    225 InspectorFrontendHostAPI.prototype.recordActionTaken = function(actionCode) {}
    226 InspectorFrontendHostAPI.prototype.recordPanelShown = function(panelCode) {}
    227 InspectorFrontendHostAPI.prototype.recordSettingChanged = function(settingCode) {}
    228 InspectorFrontendHostAPI.prototype.loadResourceSynchronously = function(url) {}
    229 InspectorFrontendHostAPI.prototype.supportsFileSystems = function() {}
    230 InspectorFrontendHostAPI.prototype.requestFileSystems = function() {}
    231 InspectorFrontendHostAPI.prototype.addFileSystem = function() {}
    232 InspectorFrontendHostAPI.prototype.removeFileSystem = function(fileSystemPath) {}
    233 InspectorFrontendHostAPI.prototype.isolatedFileSystem = function(fileSystemId, registeredName) {}
    234 InspectorFrontendHostAPI.prototype.indexPath = function(requestId, fileSystemPath) {}
    235 InspectorFrontendHostAPI.prototype.stopIndexing = function(requestId) {}
    236 InspectorFrontendHostAPI.prototype.searchInPath = function(requestId, fileSystemPath, query) {}
    237 InspectorFrontendHostAPI.prototype.setZoomFactor = function(zoom) {}
    238 /** @type {InspectorFrontendHostAPI} */
    239 var InspectorFrontendHost;
    240 
    241 /** @constructor */
    242 function 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 */
    253 SourceMapV3.Section = function()
    254 {
    255     /** @type {SourceMapV3} */ this.map;
    256     /** @type {SourceMapV3.Offset} */ this.offset;
    257 }
    258 
    259 /** @constructor */
    260 SourceMapV3.Offset = function()
    261 {
    262     /** @type {number} */ this.line;
    263     /** @type {number} */ this.column;
    264 }
    265 
    266 // FIXME: remove everything below.
    267 var WebInspector = {}
    268 
    269 WebInspector.queryParamsObject = {}
    270 WebInspector.toggleSearchingForNode = function() {}
    271 WebInspector.panels = {};
    272 
    273 /**
    274  * @param {Element} element
    275  * @param {function()=} onclose
    276  */
    277 WebInspector.showViewInDrawer = function(element, view, onclose) {}
    278 
    279 WebInspector.closeViewInDrawer = function() {}
    280 
    281 /**
    282  * @param {string=} messageLevel
    283  * @param {boolean=} showConsole
    284  */
    285 WebInspector.log = function(message, messageLevel, showConsole) {}
    286 
    287 WebInspector.showErrorMessage = function(error) {}
    288 
    289 WebInspector.addMainEventListeners = function(doc) {}
    290 
    291 WebInspector.openResource = function(url, external) {}
    292 
    293 WebInspector.showConsole = function() {}
    294 
    295 /**
    296  * @param {string} expression
    297  * @param {boolean=} showResultOnly
    298  */
    299 WebInspector.evaluateInConsole = function(expression, showResultOnly) {}
    300 
    301 WebInspector.queryParamsObject = {}
    302 
    303 /**
    304  * @param {Element} element
    305  */
    306 WebInspector.showAnchorLocation = function(element) {}
    307 
    308 WebInspector.Events = {
    309     InspectorLoaded: "InspectorLoaded",
    310     InspectorClosing: "InspectorClosing"
    311 }
    312 
    313 /** @type {WebInspector.SettingsController} */
    314 WebInspector.settingsController;
    315 
    316 /** Extensions API */
    317 
    318 /** @constructor */
    319 function AuditCategory() {}
    320 /** @constructor */
    321 function AuditResult() {}
    322 /** @constructor */
    323 function EventSink() {}
    324 /** @constructor */
    325 function ExtensionSidebarPane() {}
    326 /** @constructor */
    327 function Panel() {}
    328 /** @constructor */
    329 function PanelWithSidebar() {}
    330 /** @constructor */
    331 function Request() {}
    332 /** @constructor */
    333 function Resource() {}
    334 /** @constructor */
    335 function Timeline() {}
    336 
    337 var extensionServer;
    338 
    339 /** @type {string} */
    340 Location.prototype.origin = "";
    341 
    342 /**
    343  * @constructor
    344  */
    345 function ExtensionDescriptor() {
    346     this.startPage = "";
    347     this.name = "";
    348 }
    349 
    350 /**
    351  * @constructor
    352  */
    353 function ExtensionReloadOptions() {
    354     this.ignoreCache = false;
    355     this.injectedScript = "";
    356     this.userAgent = "";
    357 }
    358 
    359 WebInspector.showPanel = function(panel)
    360 {
    361 }
    362 
    363 /**
    364  * @param {ExtensionDescriptor} extensionInfo
    365  * @return {string}
    366  */
    367 function buildPlatformExtensionAPI(extensionInfo) {}
    368 
    369 /**
    370  * @type {string}
    371  */
    372 WebInspector.inspectedPageDomain;
    373 
    374 WebInspector.SourceJavaScriptTokenizer = {}
    375 WebInspector.SourceJavaScriptTokenizer.Keywords = {}
    376 
    377 var InspectorTest = {}
    378 
    379 /* jsdifflib API */
    380 var difflib = {};
    381 difflib.stringAsLines = function(text) { return []; }
    382 /** @constructor */
    383 difflib.SequenceMatcher = function(baseText, newText) { }
    384 difflib.SequenceMatcher.prototype.get_opcodes = function() { return []; }
    385 
    386 /** @constructor */
    387 var CodeMirror = function() { }
    388 CodeMirror.on = function(obj, type, handler) { }
    389 CodeMirror.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} */
    495 CodeMirror.prototype.lineCount;
    496 CodeMirror.Pass;
    497 CodeMirror.showHint = function(codeMirror, hintintFunction) { };
    498 CodeMirror.commands = {};
    499 CodeMirror.modes = {};
    500 CodeMirror.mimeModes = {};
    501 CodeMirror.getMode = function(options, spec) { };
    502 CodeMirror.overlayMode = function(mode1, mode2, squashSpans) { };
    503 CodeMirror.defineMode = function(modeName, modeConstructor) { };
    504 
    505 /** @constructor */
    506 CodeMirror.Pos = function(line, ch) { }
    507 /** type {number} */
    508 CodeMirror.Pos.prototype.line;
    509 /** type {number} */
    510 CodeMirror.Pos.prototype.ch;
    511 
    512 /** @constructor */
    513 CodeMirror.StringStream = function() { }
    514 CodeMirror.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>>} */
    537 CodeMirror.keyMap;
    538 
    539 WebInspector.suggestReload = function() { }
    540 WebInspector.reload = function() { }
    541 
    542 WebInspector.settings.continuousPainting = /** type {WebInspector.Setting} */ { }
    543 WebInspector.settings.showDebugBorders = /** type {WebInspector.Setting} */ { }
    544 WebInspector.settings.showScrollBottleneckRects = /** type {WebInspector.Setting} */ { }
    545 WebInspector.settings.forceCompositingMode = /** type {WebInspector.Setting} */ { }
    546 WebInspector.settings.showFPSCounter = /** type {WebInspector.Setting} */ { }
    547 WebInspector.settings.showPaintRects = /** type {WebInspector.Setting} */ { }
    548 
    549 /** @type {boolean} */
    550 window.dispatchStandaloneTestRunnerMessages;
    551