UNPKG

devil-windows

Version:

Debugger, profiler and runtime with embedded WebKit DevTools client (for Windows).

1,303 lines (1,279 loc) 1.68 MB
var _importedScripts = {}; function loadResource(url) { var xhr = new XMLHttpRequest(); xhr.open("GET", url, false); try { xhr.send(null); } catch (e) { console.error(url + " -> " + new Error().stack); throw e; } return xhr.responseText; } function normalizePath(path) { if (path.indexOf("..") === -1 && path.indexOf('.') === -1) return path; var normalizedSegments = []; var segments = path.split("/"); for (var i = 0; i < segments.length; i++) { var segment = segments[i]; if (segment === ".") continue; else if (segment === "..") normalizedSegments.pop(); else if (segment) normalizedSegments.push(segment); } var normalizedPath = normalizedSegments.join("/"); if (normalizedPath[normalizedPath.length - 1] === "/") return normalizedPath; if (path[0] === "/" && normalizedPath) normalizedPath = "/" + normalizedPath; if ((path[path.length - 1] === "/") || (segments[segments.length - 1] === ".") || (segments[segments.length - 1] === "..")) normalizedPath = normalizedPath + "/"; return normalizedPath; } function importScript(scriptName) { var sourceURL = self._importScriptPathPrefix + scriptName; var schemaIndex = sourceURL.indexOf("://") + 3; sourceURL = sourceURL.substring(0, schemaIndex) + normalizePath(sourceURL.substring(schemaIndex)); if (_importedScripts[sourceURL]) return; _importedScripts[sourceURL] = true; var scriptSource = loadResource(sourceURL); if (!scriptSource) throw"empty response arrived for script '" + sourceURL + "'"; var oldPrefix = self._importScriptPathPrefix; self._importScriptPathPrefix += scriptName.substring(0, scriptName.lastIndexOf("/") + 1); try { self.eval(scriptSource + "\n//# sourceURL=" + sourceURL); } finally { self._importScriptPathPrefix = oldPrefix; } } (function () { var baseUrl = location.origin + location.pathname; self._importScriptPathPrefix = baseUrl.substring(0, baseUrl.lastIndexOf("/") + 1); })(); var loadScript = importScript; var Runtime = function (descriptors) { this._modules = []; this._modulesMap = {}; this._extensions = []; this._cachedTypeClasses = {}; this._descriptorsMap = {}; for (var i = 0; i < descriptors.length; ++i) this._descriptorsMap[descriptors[i]["name"]] = descriptors[i]; } Runtime.startWorker = function (moduleName) { return new Worker(moduleName + "/_module.js"); } Runtime.prototype = { registerModules: function (configuration) { for (var i = 0; i < configuration.length; ++i) this._registerModule(configuration[i]); }, _registerModule: function (moduleName) { if (!this._descriptorsMap[moduleName]) { var content = loadResource(moduleName + "/module.json"); if (!content) throw new Error("Module is not defined: " + moduleName + " " + new Error().stack); var module = (self.eval("(" + content + ")")); module["name"] = moduleName; this._descriptorsMap[moduleName] = module; } var module = new Runtime.Module(this, this._descriptorsMap[moduleName]); this._modules.push(module); this._modulesMap[moduleName] = module; }, loadModule: function (moduleName) { this._modulesMap[moduleName]._load(); }, _checkExtensionApplicability: function (extension, predicate) { if (!predicate) return false; var contextTypes = (extension.descriptor().contextTypes); if (!contextTypes) return true; for (var i = 0; i < contextTypes.length; ++i) { var contextType = this._resolve(contextTypes[i]); var isMatching = !!contextType && predicate(contextType); if (isMatching) return true; } return false; }, isExtensionApplicableToContext: function (extension, context) { if (!context) return true; return this._checkExtensionApplicability(extension, isInstanceOf); function isInstanceOf(targetType) { return context instanceof targetType; } }, isExtensionApplicableToContextTypes: function (extension, currentContextTypes) { if (!extension.descriptor().contextTypes) return true; for (var i = 0; i < currentContextTypes.length; ++i) currentContextTypes[i]["__applicable"] = true; var result = this._checkExtensionApplicability(extension, currentContextTypes ? isContextTypeKnown : null); for (var i = 0; i < currentContextTypes.length; ++i) delete currentContextTypes[i]["__applicable"]; return result; function isContextTypeKnown(targetType) { return !!targetType["__applicable"]; } }, extensions: function (type, context) { function filter(extension) { if (extension._type !== type && extension._typeClass() !== type) return false; return !context || extension.isApplicable(context); } return this._extensions.filter(filter); }, extension: function (type, context) { return this.extensions(type, context)[0] || null; }, instances: function (type, context) { function instantiate(extension) { return extension.instance(); } return this.extensions(type, context).filter(instantiate).map(instantiate); }, instance: function (type, context) { var extension = this.extension(type, context); return extension ? extension.instance() : null; }, orderComparator: function (type, nameProperty, orderProperty) { var extensions = this.extensions(type); var orderForName = {}; for (var i = 0; i < extensions.length; ++i) { var descriptor = extensions[i].descriptor(); orderForName[descriptor[nameProperty]] = descriptor[orderProperty]; } function result(name1, name2) { if (name1 in orderForName && name2 in orderForName) return orderForName[name1] - orderForName[name2]; if (name1 in orderForName) return -1; if (name2 in orderForName) return 1; return compare(name1, name2); } function compare(left, right) { if (left > right) return 1; if (left < right) return -1; return 0; } return result; }, _resolve: function (typeName) { if (!this._cachedTypeClasses[typeName]) { var path = typeName.split("."); var object = window; for (var i = 0; object && (i < path.length); ++i) object = object[path[i]]; if (object) this._cachedTypeClasses[typeName] = (object); } return this._cachedTypeClasses[typeName]; } } Runtime.ModuleDescriptor = function () { this.name; this.extensions; this.dependencies; this.scripts; } Runtime.ExtensionDescriptor = function () { this.type; this.className; this.contextTypes; } Runtime.Module = function (manager, descriptor) { this._manager = manager; this._descriptor = descriptor; this._name = descriptor.name; var extensions = (descriptor.extensions); for (var i = 0; extensions && i < extensions.length; ++i) this._manager._extensions.push(new Runtime.Extension(this, extensions[i])); this._loaded = false; } Runtime.Module.prototype = { name: function () { return this._name; }, _load: function () { if (this._loaded) return; if (this._isLoading) { var oldStackTraceLimit = Error.stackTraceLimit; Error.stackTraceLimit = 50; console.assert(false, "Module " + this._name + " is loaded from itself: " + new Error().stack); Error.stackTraceLimit = oldStackTraceLimit; return; } this._isLoading = true; var dependencies = this._descriptor.dependencies; for (var i = 0; dependencies && i < dependencies.length; ++i) this._manager.loadModule(dependencies[i]); if (this._descriptor.scripts) loadScript(this._name + "/_module.js"); this._isLoading = false; this._loaded = true; } } Runtime.Extension = function (module, descriptor) { this._module = module; this._descriptor = descriptor; this._type = descriptor.type; this._hasTypeClass = this._type.charAt(0) === "@"; this._className = descriptor.className || null; } Runtime.Extension.prototype = { descriptor: function () { return this._descriptor; }, module: function () { return this._module; }, _typeClass: function () { if (!this._hasTypeClass) return null; return this._module._manager._resolve(this._type.substring(1)); }, isApplicable: function (context) { return this._module._manager.isExtensionApplicableToContext(this, context); }, instance: function () { if (!this._className) return null; if (!this._instance) { this._module._load(); var constructorFunction = window.eval(this._className); if (!(constructorFunction instanceof Function)) return null; this._instance = new constructorFunction(); } return this._instance; } } var runtime; Object.isEmpty = function (obj) { for (var i in obj) return false; return true; } Object.values = function (obj) { var result = Object.keys(obj); var length = result.length; for (var i = 0; i < length; ++i) result[i] = obj[result[i]]; return result; } function mod(m, n) { return ((m % n) + n) % n; } String.prototype.findAll = function (string) { var matches = []; var i = this.indexOf(string); while (i !== -1) { matches.push(i); i = this.indexOf(string, i + string.length); } return matches; } String.prototype.lineEndings = function () { if (!this._lineEndings) { this._lineEndings = this.findAll("\n"); this._lineEndings.push(this.length); } return this._lineEndings; } String.prototype.lineCount = function () { var lineEndings = this.lineEndings(); return lineEndings.length; } String.prototype.lineAt = function (lineNumber) { var lineEndings = this.lineEndings(); var lineStart = lineNumber > 0 ? lineEndings[lineNumber - 1] + 1 : 0; var lineEnd = lineEndings[lineNumber]; var lineContent = this.substring(lineStart, lineEnd); if (lineContent.length > 0 && lineContent.charAt(lineContent.length - 1) === "\r") lineContent = lineContent.substring(0, lineContent.length - 1); return lineContent; } String.prototype.escapeCharacters = function (chars) { var foundChar = false; for (var i = 0; i < chars.length; ++i) { if (this.indexOf(chars.charAt(i)) !== -1) { foundChar = true; break; } } if (!foundChar) return String(this); var result = ""; for (var i = 0; i < this.length; ++i) { if (chars.indexOf(this.charAt(i)) !== -1) result += "\\"; result += this.charAt(i); } return result; } String.regexSpecialCharacters = function () { return "^[]{}()\\.^$*+?|-,"; } String.prototype.escapeForRegExp = function () { return this.escapeCharacters(String.regexSpecialCharacters()); } String.prototype.escapeHTML = function () { return this.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;"); } String.prototype.collapseWhitespace = function () { return this.replace(/[\s\xA0]+/g, " "); } String.prototype.trimMiddle = function (maxLength) { if (this.length <= maxLength) return String(this); var leftHalf = maxLength >> 1; var rightHalf = maxLength - leftHalf - 1; return this.substr(0, leftHalf) + "\u2026" + this.substr(this.length - rightHalf, rightHalf); } String.prototype.trimEnd = function (maxLength) { if (this.length <= maxLength) return String(this); return this.substr(0, maxLength - 1) + "\u2026"; } String.prototype.trimURL = function (baseURLDomain) { var result = this.replace(/^(https|http|file):\/\//i, ""); if (baseURLDomain) result = result.replace(new RegExp("^" + baseURLDomain.escapeForRegExp(), "i"), ""); return result; } String.prototype.toTitleCase = function () { return this.substring(0, 1).toUpperCase() + this.substring(1); } String.prototype.compareTo = function (other) { if (this > other) return 1; if (this < other) return -1; return 0; } function sanitizeHref(href) { return href && href.trim().toLowerCase().startsWith("javascript:") ? null : href; } String.prototype.removeURLFragment = function () { var fragmentIndex = this.indexOf("#"); if (fragmentIndex == -1) fragmentIndex = this.length; return this.substring(0, fragmentIndex); } String.prototype.startsWith = function (substring) { return !this.lastIndexOf(substring, 0); } String.prototype.endsWith = function (substring) { return this.indexOf(substring, this.length - substring.length) !== -1; } String.prototype.hashCode = function () { var result = 0; for (var i = 0; i < this.length; ++i) result = (result * 3 + this.charCodeAt(i)) | 0; return result; } String.prototype.isDigitAt = function (index) { var c = this.charCodeAt(index); return 48 <= c && c <= 57; } String.naturalOrderComparator = function (a, b) { var chunk = /^\d+|^\D+/; var chunka, chunkb, anum, bnum; while (1) { if (a) { if (!b) return 1; } else { if (b) return -1; else return 0; } chunka = a.match(chunk)[0]; chunkb = b.match(chunk)[0]; anum = !isNaN(chunka); bnum = !isNaN(chunkb); if (anum && !bnum) return -1; if (bnum && !anum) return 1; if (anum && bnum) { var diff = chunka - chunkb; if (diff) return diff; if (chunka.length !== chunkb.length) { if (!+chunka && !+chunkb) return chunka.length - chunkb.length; else return chunkb.length - chunka.length; } } else if (chunka !== chunkb) return (chunka < chunkb) ? -1 : 1; a = a.substring(chunka.length); b = b.substring(chunkb.length); } } Number.constrain = function (num, min, max) { if (num < min) num = min; else if (num > max) num = max; return num; } Number.gcd = function (a, b) { if (b === 0) return a; else return Number.gcd(b, a % b); } Number.toFixedIfFloating = function (value) { if (!value || isNaN(value)) return value; var number = Number(value); return number % 1 ? number.toFixed(3) : String(number); } Date.prototype.toISO8601Compact = function () { function leadZero(x) { return (x > 9 ? "" : "0") + x; } return this.getFullYear() + leadZero(this.getMonth() + 1) + leadZero(this.getDate()) + "T" + leadZero(this.getHours()) + leadZero(this.getMinutes()) + leadZero(this.getSeconds()); } Date.prototype.toConsoleTime = function () { function leadZero2(x) { return (x > 9 ? "" : "0") + x; } function leadZero3(x) { return (Array(4 - x.toString().length)).join('0') + x; } return this.getFullYear() + "-" + leadZero2(this.getMonth() + 1) + "-" + leadZero2(this.getDate()) + " " + leadZero2(this.getHours()) + ":" + leadZero2(this.getMinutes()) + ":" + leadZero2(this.getSeconds()) + "." + leadZero3(this.getMilliseconds()); } Object.defineProperty(Array.prototype, "remove", { value: function (value, firstOnly) { var index = this.indexOf(value); if (index === -1) return; if (firstOnly) { this.splice(index, 1); return; } for (var i = index + 1, n = this.length; i < n; ++i) { if (this[i] !== value) this[index++] = this[i]; } this.length = index; } }); Object.defineProperty(Array.prototype, "keySet", { value: function () { var keys = {}; for (var i = 0; i < this.length; ++i) keys[this[i]] = true; return keys; } }); Object.defineProperty(Array.prototype, "pushAll", { value: function (array) { Array.prototype.push.apply(this, array); } }); Object.defineProperty(Array.prototype, "rotate", { value: function (index) { var result = []; for (var i = index; i < index + this.length; ++i) result.push(this[i % this.length]); return result; } }); Object.defineProperty(Array.prototype, "sortNumbers", { value: function () { function numericComparator(a, b) { return a - b; } this.sort(numericComparator); } }); Object.defineProperty(Uint32Array.prototype, "sort", {value: Array.prototype.sort}); (function () { var partition = { value: function (comparator, left, right, pivotIndex) { function swap(array, i1, i2) { var temp = array[i1]; array[i1] = array[i2]; array[i2] = temp; } var pivotValue = this[pivotIndex]; swap(this, right, pivotIndex); var storeIndex = left; for (var i = left; i < right; ++i) { if (comparator(this[i], pivotValue) < 0) { swap(this, storeIndex, i); ++storeIndex; } } swap(this, right, storeIndex); return storeIndex; } }; Object.defineProperty(Array.prototype, "partition", partition); Object.defineProperty(Uint32Array.prototype, "partition", partition); var sortRange = { value: function (comparator, leftBound, rightBound, sortWindowLeft, sortWindowRight) { function quickSortRange(array, comparator, left, right, sortWindowLeft, sortWindowRight) { if (right <= left) return; var pivotIndex = Math.floor(Math.random() * (right - left)) + left; var pivotNewIndex = array.partition(comparator, left, right, pivotIndex); if (sortWindowLeft < pivotNewIndex) quickSortRange(array, comparator, left, pivotNewIndex - 1, sortWindowLeft, sortWindowRight); if (pivotNewIndex < sortWindowRight) quickSortRange(array, comparator, pivotNewIndex + 1, right, sortWindowLeft, sortWindowRight); } if (leftBound === 0 && rightBound === (this.length - 1) && sortWindowLeft === 0 && sortWindowRight >= rightBound) this.sort(comparator); else quickSortRange(this, comparator, leftBound, rightBound, sortWindowLeft, sortWindowRight); return this; } } Object.defineProperty(Array.prototype, "sortRange", sortRange); Object.defineProperty(Uint32Array.prototype, "sortRange", sortRange); })(); Object.defineProperty(Array.prototype, "stableSort", { value: function (comparator) { function defaultComparator(a, b) { return a < b ? -1 : (a > b ? 1 : 0); } comparator = comparator || defaultComparator; var indices = new Array(this.length); for (var i = 0; i < this.length; ++i) indices[i] = i; var self = this; function indexComparator(a, b) { var result = comparator(self[a], self[b]); return result ? result : a - b; } indices.sort(indexComparator); for (var i = 0; i < this.length; ++i) { if (indices[i] < 0 || i === indices[i]) continue; var cyclical = i; var saved = this[i]; while (true) { var next = indices[cyclical]; indices[cyclical] = -1; if (next === i) { this[cyclical] = saved; break; } else { this[cyclical] = this[next]; cyclical = next; } } } return this; } }); Object.defineProperty(Array.prototype, "qselect", { value: function (k, comparator) { if (k < 0 || k >= this.length) return; if (!comparator) comparator = function (a, b) { return a - b; } var low = 0; var high = this.length - 1; for (; ;) { var pivotPosition = this.partition(comparator, low, high, Math.floor((high + low) / 2)); if (pivotPosition === k) return this[k]; else if (pivotPosition > k) high = pivotPosition - 1; else low = pivotPosition + 1; } } }); Object.defineProperty(Array.prototype, "lowerBound", { value: function (object, comparator, left, right) { function defaultComparator(a, b) { return a < b ? -1 : (a > b ? 1 : 0); } comparator = comparator || defaultComparator; var l = left || 0; var r = right !== undefined ? right : this.length; while (l < r) { var m = (l + r) >> 1; if (comparator(object, this[m]) > 0) l = m + 1; else r = m; } return r; } }); Object.defineProperty(Array.prototype, "upperBound", { value: function (object, comparator, left, right) { function defaultComparator(a, b) { return a < b ? -1 : (a > b ? 1 : 0); } comparator = comparator || defaultComparator; var l = left || 0; var r = right !== undefined ? right : this.length; while (l < r) { var m = (l + r) >> 1; if (comparator(object, this[m]) >= 0) l = m + 1; else r = m; } return r; } }); Object.defineProperty(Uint32Array.prototype, "lowerBound", {value: Array.prototype.lowerBound}); Object.defineProperty(Uint32Array.prototype, "upperBound", {value: Array.prototype.upperBound}); Object.defineProperty(Float64Array.prototype, "lowerBound", {value: Array.prototype.lowerBound}); Object.defineProperty(Array.prototype, "binaryIndexOf", { value: function (value, comparator) { var index = this.lowerBound(value, comparator); return index < this.length && comparator(value, this[index]) === 0 ? index : -1; } }); Object.defineProperty(Array.prototype, "select", { value: function (field) { var result = new Array(this.length); for (var i = 0; i < this.length; ++i) result[i] = this[i][field]; return result; } }); Object.defineProperty(Array.prototype, "peekLast", { value: function () { return this[this.length - 1]; } }); (function () { function mergeOrIntersect(array1, array2, comparator, mergeNotIntersect) { var result = []; var i = 0; var j = 0; while (i < array1.length && j < array2.length) { var compareValue = comparator(array1[i], array2[j]); if (mergeNotIntersect || !compareValue) result.push(compareValue <= 0 ? array1[i] : array2[j]); if (compareValue <= 0) i++; if (compareValue >= 0) j++; } if (mergeNotIntersect) { while (i < array1.length) result.push(array1[i++]); while (j < array2.length) result.push(array2[j++]); } return result; } Object.defineProperty(Array.prototype, "intersectOrdered", { value: function (array, comparator) { return mergeOrIntersect(this, array, comparator, false); } }); Object.defineProperty(Array.prototype, "mergeOrdered", { value: function (array, comparator) { return mergeOrIntersect(this, array, comparator, true); } }); }()); function insertionIndexForObjectInListSortedByFunction(object, list, comparator, insertionIndexAfter) { if (insertionIndexAfter) return list.upperBound(object, comparator); else return list.lowerBound(object, comparator); } String.sprintf = function (format, var_arg) { return String.vsprintf(format, Array.prototype.slice.call(arguments, 1)); } String.tokenizeFormatString = function (format, formatters) { var tokens = []; var substitutionIndex = 0; function addStringToken(str) { tokens.push({type: "string", value: str}); } function addSpecifierToken(specifier, precision, substitutionIndex) { tokens.push({type: "specifier", specifier: specifier, precision: precision, substitutionIndex: substitutionIndex}); } var index = 0; for (var precentIndex = format.indexOf("%", index); precentIndex !== -1; precentIndex = format.indexOf("%", index)) { addStringToken(format.substring(index, precentIndex)); index = precentIndex + 1; if (format[index] === "%") { addStringToken("%"); ++index; continue; } if (format.isDigitAt(index)) { var number = parseInt(format.substring(index), 10); while (format.isDigitAt(index)) ++index; if (number > 0 && format[index] === "$") { substitutionIndex = (number - 1); ++index; } } var precision = -1; if (format[index] === ".") { ++index; precision = parseInt(format.substring(index), 10); if (isNaN(precision)) precision = 0; while (format.isDigitAt(index)) ++index; } if (!(format[index]in formatters)) { addStringToken(format.substring(precentIndex, index + 1)); ++index; continue; } addSpecifierToken(format[index], precision, substitutionIndex); ++substitutionIndex; ++index; } addStringToken(format.substring(index)); return tokens; } String.standardFormatters = { d: function (substitution) { return !isNaN(substitution) ? substitution : 0; }, f: function (substitution, token) { if (substitution && token.precision > -1) substitution = substitution.toFixed(token.precision); return !isNaN(substitution) ? substitution : (token.precision > -1 ? Number(0).toFixed(token.precision) : 0); }, s: function (substitution) { return substitution; } } String.vsprintf = function (format, substitutions) { return String.format(format, substitutions, String.standardFormatters, "", function (a, b) { return a + b; }).formattedResult; } String.format = function (format, substitutions, formatters, initialValue, append) { if (!format || !substitutions || !substitutions.length) return {formattedResult: append(initialValue, format), unusedSubstitutions: substitutions}; function prettyFunctionName() { return "String.format(\"" + format + "\", \"" + substitutions.join("\", \"") + "\")"; } function warn(msg) { console.warn(prettyFunctionName() + ": " + msg); } function error(msg) { console.error(prettyFunctionName() + ": " + msg); } var result = initialValue; var tokens = String.tokenizeFormatString(format, formatters); var usedSubstitutionIndexes = {}; for (var i = 0; i < tokens.length; ++i) { var token = tokens[i]; if (token.type === "string") { result = append(result, token.value); continue; } if (token.type !== "specifier") { error("Unknown token type \"" + token.type + "\" found."); continue; } if (token.substitutionIndex >= substitutions.length) { error("not enough substitution arguments. Had " + substitutions.length + " but needed " + (token.substitutionIndex + 1) + ", so substitution was skipped."); result = append(result, "%" + (token.precision > -1 ? token.precision : "") + token.specifier); continue; } usedSubstitutionIndexes[token.substitutionIndex] = true; if (!(token.specifier in formatters)) { warn("unsupported format character \u201C" + token.specifier + "\u201D. Treating as a string."); result = append(result, substitutions[token.substitutionIndex]); continue; } result = append(result, formatters[token.specifier](substitutions[token.substitutionIndex], token)); } var unusedSubstitutions = []; for (var i = 0; i < substitutions.length; ++i) { if (i in usedSubstitutionIndexes) continue; unusedSubstitutions.push(substitutions[i]); } return {formattedResult: result, unusedSubstitutions: unusedSubstitutions}; } function createSearchRegex(query, caseSensitive, isRegex) { var regexFlags = caseSensitive ? "g" : "gi"; var regexObject; if (isRegex) { try { regexObject = new RegExp(query, regexFlags); } catch (e) { } } if (!regexObject) regexObject = createPlainTextSearchRegex(query, regexFlags); return regexObject; } function createPlainTextSearchRegex(query, flags) { var regexSpecialCharacters = String.regexSpecialCharacters(); var regex = ""; for (var i = 0; i < query.length; ++i) { var c = query.charAt(i); if (regexSpecialCharacters.indexOf(c) != -1) regex += "\\"; regex += c; } return new RegExp(regex, flags || ""); } function countRegexMatches(regex, content) { var text = content; var result = 0; var match; while (text && (match = regex.exec(text))) { if (match[0].length > 0) ++result; text = text.substring(match.index + 1); } return result; } function numberToStringWithSpacesPadding(value, symbolsCount) { var numberString = value.toString(); var paddingLength = Math.max(0, symbolsCount - numberString.length); var paddingString = Array(paddingLength + 1).join("\u00a0"); return paddingString + numberString; } var createObjectIdentifier = function () { return "_" + ++createObjectIdentifier._last; } createObjectIdentifier._last = 0; var Set = function () { this._set = {}; this._size = 0; } Set.fromArray = function (array) { var result = new Set(); array.forEach(function (item) { result.add(item); }); return result; } Set.prototype = { add: function (item) { var objectIdentifier = item.__identifier; if (!objectIdentifier) { objectIdentifier = createObjectIdentifier(); item.__identifier = objectIdentifier; } if (!this._set[objectIdentifier]) ++this._size; this._set[objectIdentifier] = item; }, remove: function (item) { if (this._set[item.__identifier]) { --this._size; delete this._set[item.__identifier]; return true; } return false; }, values: function () { var result = new Array(this._size); var i = 0; for (var objectIdentifier in this._set) result[i++] = this._set[objectIdentifier]; return result; }, contains: function (item) { return !!this._set[item.__identifier]; }, size: function () { return this._size; }, clear: function () { this._set = {}; this._size = 0; } } var Map = function () { this._map = {}; this._size = 0; } Map.prototype = { put: function (key, value) { var objectIdentifier = key.__identifier; if (!objectIdentifier) { objectIdentifier = createObjectIdentifier(); key.__identifier = objectIdentifier; } if (!this._map[objectIdentifier]) ++this._size; this._map[objectIdentifier] = [key, value]; }, remove: function (key) { var result = this._map[key.__identifier]; if (!result) return undefined; --this._size; delete this._map[key.__identifier]; return result[1]; }, keys: function () { return this._list(0); }, values: function () { return this._list(1); }, _list: function (index) { var result = new Array(this._size); var i = 0; for (var objectIdentifier in this._map) result[i++] = this._map[objectIdentifier][index]; return result; }, get: function (key) { var entry = this._map[key.__identifier]; return entry ? entry[1] : undefined; }, contains: function (key) { var entry = this._map[key.__identifier]; return !!entry; }, size: function () { return this._size; }, clear: function () { this._map = {}; this._size = 0; } } var StringMap = function () { this._map = {}; this._size = 0; } StringMap.prototype = { put: function (key, value) { if (key === "__proto__") { if (!this._hasProtoKey) { ++this._size; this._hasProtoKey = true; } this._protoValue = value; return; } if (!Object.prototype.hasOwnProperty.call(this._map, key)) ++this._size; this._map[key] = value; }, remove: function (key) { var result; if (key === "__proto__") { if (!this._hasProtoKey) return undefined; --this._size; delete this._hasProtoKey; result = this._protoValue; delete this._protoValue; return result; } if (!Object.prototype.hasOwnProperty.call(this._map, key)) return undefined; --this._size; result = this._map[key]; delete this._map[key]; return result; }, keys: function () { var result = Object.keys(this._map) || []; if (this._hasProtoKey) result.push("__proto__"); return result; }, values: function () { var result = Object.values(this._map); if (this._hasProtoKey) result.push(this._protoValue); return result; }, get: function (key) { if (key === "__proto__") return this._protoValue; if (!Object.prototype.hasOwnProperty.call(this._map, key)) return undefined; return this._map[key]; }, contains: function (key) { var result; if (key === "__proto__") return this._hasProtoKey; return Object.prototype.hasOwnProperty.call(this._map, key); }, size: function () { return this._size; }, clear: function () { this._map = {}; this._size = 0; delete this._hasProtoKey; delete this._protoValue; } } var StringMultimap = function () { StringMap.call(this); } StringMultimap.prototype = { put: function (key, value) { if (key === "__proto__") { if (!this._hasProtoKey) { ++this._size; this._hasProtoKey = true; this._protoValue = new Set(); } this._protoValue.add(value); return; } if (!Object.prototype.hasOwnProperty.call(this._map, key)) { ++this._size; this._map[key] = new Set(); } this._map[key].add(value); }, get: function (key) { var result = StringMap.prototype.get.call(this, key); if (!result) result = new Set(); return result; }, remove: function (key, value) { var values = this.get(key); values.remove(value); if (!values.size()) StringMap.prototype.remove.call(this, key) }, removeAll: function (key) { StringMap.prototype.remove.call(this, key); }, values: function () { var result = []; var keys = this.keys(); for (var i = 0; i < keys.length; ++i) result.pushAll(this.get(keys[i]).values()); return result; }, __proto__: StringMap.prototype } var StringSet = function () { this._map = new StringMap(); } StringSet.fromArray = function (array) { var result = new StringSet(); array.forEach(function (item) { result.add(item); }); return result; } StringSet.prototype = { add: function (value) { this._map.put(value, true); }, remove: function (value) { return !!this._map.remove(value); }, values: function () { return this._map.keys(); }, contains: function (value) { return this._map.contains(value); }, size: function () { return this._map.size(); }, clear: function () { this._map.clear(); } } function loadXHR(url, async, callback) { function onReadyStateChanged() { if (xhr.readyState !== XMLHttpRequest.DONE) return; if (xhr.status === 200) { callback(xhr.responseText); return; } callback(null); } var xhr = new XMLHttpRequest(); xhr.open("GET", url, async); if (async) xhr.onreadystatechange = onReadyStateChanged; xhr.send(null); if (!async) { if (xhr.status === 200 || xhr.status === 0) return xhr.responseText; return null; } return null; } function CallbackBarrier() { this._pendingIncomingCallbacksCount = 0; } CallbackBarrier.prototype = { createCallback: function (userCallback) { console.assert(!this._outgoingCallback, "CallbackBarrier.createCallback() is called after CallbackBarrier.callWhenDone()"); ++this._pendingIncomingCallbacksCount; return this._incomingCallback.bind(this, userCallback); }, callWhenDone: function (callback) { console.assert(!this._outgoingCallback, "CallbackBarrier.callWhenDone() is called multiple times"); this._outgoingCallback = callback; if (!this._pendingIncomingCallbacksCount) this._outgoingCallback(); }, _incomingCallback: function (userCallback) { console.assert(this._pendingIncomingCallbacksCount > 0); if (userCallback) { var args = Array.prototype.slice.call(arguments, 1); userCallback.apply(null, args); } if (!--this._pendingIncomingCallbacksCount && this._outgoingCallback) this._outgoingCallback(); } } function suppressUnused(value) { } function WeakReference(targetObject) { this._targetObject = targetObject; } WeakReference.prototype = { get: function () { return this._targetObject; }, clear: function () { this._targetObject = null; } }; self.setImmediate = (function () { var callbacks = []; function run() { var cbList = callbacks.slice(); callbacks.length = 0; cbList.forEach(function (callback) { callback(); }); }; return function setImmediate(callback) { if (!callbacks.length) new Promise(function (resolve, reject) { resolve(null); }).then(run); callbacks.push(callback); }; })(); var allDescriptors = [{ "extensions": [{"className": "WebInspector.AuditsPanel", "order": 6, "type": "@WebInspector.Panel", "name": "audits", "title": "Audits"}], "name": "audits", "scripts": [] }, { "extensions": [{"className": "WebInspector.ConsolePanel", "order": 20, "type": "@WebInspector.Panel", "name": "console", "title": "Console"}, { "className": "WebInspector.ConsolePanel.WrapperView", "order": "0", "type": "drawer-view", "name": "console", "title": "Console" }, {"className": "WebInspector.ConsolePanel.ConsoleRevealer", "contextTypes": ["WebInspector.Console"], "type": "@WebInspector.Revealer"}, { "className": "WebInspector.ConsoleView.ShowConsoleActionDelegate", "bindings": [{"shortcut": "Ctrl+`"}], "type": "@WebInspector.ActionDelegate", "actionId": "console.show" }, {"section": "Console", "settingType": "checkbox", "type": "ui-setting", "settingName": "monitoringXHREnabled", "title": "Log XMLHttpRequests"}, { "section": "Console", "settingType": "checkbox", "type": "ui-setting", "settingName": "preserveConsoleLog", "title": "Preserve log upon navigation" }, {"section": "Console", "settingType": "checkbox", "type": "ui-setting", "settingName": "consoleTimestampsEnabled", "title": "Show timestamps"}], "name": "console", "scripts": [] }, { "extensions": [{"name": "devices", "title": "Devices", "className": "WebInspector.DevicesView", "experiment": "devicesPanel", "type": "drawer-view", "order": "12"}], "name": "devices", "scripts": [] }, { "extensions": [{"className": "WebInspector.DocumentationView.ContextMenuProvider", "contextTypes": ["WebInspector.CodeMirrorTextEditor"], "type": "@WebInspector.ContextMenu.Provider"}], "name": "documentation", "scripts": [] }, { "extensions": [{"className": "WebInspector.ElementsPanel", "order": 0, "type": "@WebInspector.Panel", "name": "elements", "title": "Elements"}, { "className": "WebInspector.ElementsPanel.ContextMenuProvider", "contextTypes": ["WebInspector.RemoteObject", "WebInspector.DOMNode", "WebInspector.DeferredDOMNode"], "type": "@WebInspector.ContextMenu.Provider" }, {"className": "WebInspector.ElementsTreeOutline.Renderer", "contextTypes": ["WebInspector.DOMNode"], "type": "@WebInspector.Renderer"}, { "className": "WebInspector.ElementsPanel.DOMNodeRevealer", "contextTypes": ["WebInspector.DOMNode", "WebInspector.DeferredDOMNode"], "type": "@WebInspector.Revealer" }, {"className": "WebInspector.ElementsPanel.NodeRemoteObjectRevealer", "contextTypes": ["WebInspector.RemoteObject"], "type": "@WebInspector.Revealer"}, { "className": "WebInspector.ElementsPanel.NodeRemoteObjectInspector", "contextTypes": ["WebInspector.RemoteObject"], "type": "@WebInspector.NodeRemoteObjectInspector" }, { "title": "Color format:", "section": "Elements", "settingName": "colorFormat", "settingType": "select", "type": "ui-setting", "options": [["As authored", "original"], ["HEX: #DAC0DE", "hex", true], ["RGB: rgb(128, 255, 255)", "rgb", true], ["HSL: hsl(300, 80%, 90%)", "hsl", true]] }, {"section": "Elements", "settingType": "checkbox", "type": "ui-setting", "settingName": "showUserAgentStyles", "title": "Show user agent styles"}, { "section": "Elements", "settingType": "checkbox", "type": "ui-setting", "settingName": "showUAShadowDOM", "title": "Show user agent shadow DOM" }, {"section": "Elements", "settingType": "checkbox", "type": "ui-setting", "settingName": "domWordWrap", "title": "Word wrap"}, { "section": "Elements", "settingType": "checkbox", "type": "ui-setting", "settingName": "showMetricsRulers", "title": "Show rulers" }], "name": "elements", "scripts": [] }, {"dependencies": ["sources"], "extensions": [{"className": "WebInspector.ExtensionServer", "type": "@WebInspector.ExtensionServerAPI"}], "name": "extensions", "scripts": []}, { "dependencies": ["timeline"], "extensions": [{"className": "WebInspector.LayersPanel", "order": 7, "type": "@WebInspector.Panel", "name": "layers", "title": "Layers"}, { "className": "WebInspector.LayersPanel.LayerTreeRevealer", "contextTypes": ["WebInspector.DeferredLayerTree"], "type": "@WebInspector.Revealer" }], "name": "layers", "scripts": [] }, { "extensions": [{ "className": "WebInspector.HandlerRegistry.ContextMenuProvider", "contextTypes": ["WebInspector.UISourceCode", "WebInspector.Resource", "WebInspector.NetworkRequest", "Node"], "type": "@WebInspector.ContextMenu.Provider" }, { "className": "WebInspector.Main.ReloadActionDelegate", "bindings": [{"platform": "windows,linux", "shortcut": "F5 Ctrl+R"}, {"platform": "mac", "shortcut": "Meta+R"}], "type": "@WebInspector.ActionDelegate", "actionId": "main.reload" }, { "className": "WebInspector.Main.HardReloadActionDelegate", "bindings": [{"platform": "windows,linux", "shortcut": "Shift+F5 Ctrl+F5 Ctrl+Shift+F5 Shift+Ctrl+R"}, {"platform": "mac", "shortcut": "Shift+Meta+R"}], "type": "@WebInspector.ActionDelegate", "actionId": "main.hard-reload" }, { "className": "WebInspector.InspectorView.DrawerToggleActionDelegate", "bindings": [{"shortcut": "Esc"}], "type": "@WebInspector.ActionDelegate", "actionId": "main.toggle-drawer" }, { "className": "WebInspector.Main.DebugReloadActionDelegate", "bindings": [{"shortcut": "Alt+R"}], "type": "@WebInspector.ActionDelegate", "actionId": "main.debug-reload" }, { "className": "WebInspector.InspectElementModeController.ToggleSearchActionDelegate", "bindings": [{"platform": "windows,linux", "shortcut": "Ctrl+Shift+C"}, {"platform": "mac", "shortcut": "Meta+Shift+C"}], "type": "@WebInspector.ActionDelegate", "actionId": "main.toggle-element-search" }, { "className": "WebInspector.Main.ZoomInActionDelegate", "bindings": [{"platform": "windows,linux", "shortcut": "Ctrl+Plus Ctrl+Shift+Plus Ctrl+NumpadPlus Ctrl+Shift+NumpadPlus"}, {"platform": "mac", "shortcut": "Meta+Plus Meta+Shift+Plus Meta+NumpadPlus Meta+Shift+NumpadPlus"}], "type": "@WebInspector.ActionDelegate", "actionId": "main.zoom-in" }, { "className": "WebInspector.Main.ZoomOutActionDelegate", "bindings": [{"platform": "windows,linux", "shortcut": "Ctrl+Minus Ctrl+Shift+Minus Ctrl+NumpadMinus Ctrl+Shift+NumpadMinus"}, {"platform": "mac", "shortcut": "Meta+Minus Meta+Shift+Minus Meta+NumpadMinus Meta+Shift+NumpadMinus"}], "type": "@WebInspector.ActionDelegate", "actionId": "main.zoom-out" }, { "className": "WebInspector.Main.ZoomResetActionDelegate", "bindings": [{"platform": "windows,linux", "shortcut": "Ctrl+0 Ctrl+Numpad0"}, {"platform": "mac", "shortcut": "Meta+0 Meta+Numpad0"}], "type": "@WebInspector.ActionDelegate", "actionId": "main.zoom-reset" }, { "className": "WebInspector.AdvancedApp.ToggleDeviceModeActionDelegate", "bindings": [{"platform": "windows,linux", "shortcut": "Shift+Ctrl+M"}, {"platform": "mac", "shortcut": "Shift+Meta+M"}], "type": "@WebInspector.ActionDelegate", "actionId": "main.toggle-device-mode" }, {"className": "WebInspector.OverridesView", "order": "10", "type": "drawer-view", "name": "emulation", "title": "Emulation"}, { "className": "WebInspector.RenderingOptions.View", "order": "11", "type": "drawer-view", "name": "rendering", "title": "Rendering" }, {"className": "WebInspector.OverridesView.Revealer", "contextTypes": ["WebInspector.OverridesSupport"], "type": "@WebInspector.Revealer"}, { "className": "WebInspector.InspectElementModeController.ToggleButtonProvider", "actionId": "main.toggle-element-search", "type": "@WebInspector.StatusBarItem.Provider", "location": "toolbar-left", "order": 0 }, {"className": "WebInspector.AdvancedApp.EmulationButtonProvider", "type": "@WebInspector.StatusBarItem.Provider", "order": 1, "location": "toolbar-left"}, { "className": "WebInspector.AdvancedApp.DeviceCounter", "type": "@WebInspector.StatusBarItem.Provider", "order": 0, "location": "toolbar-right" }, {"className": "WebInspector.Main.WarningErrorCounter", "type": "@WebInspector.StatusBarItem.Provider", "order": 1, "location": "toolbar-right"}, { "className": "WebInspector.InspectorView.ToggleDrawerButtonProvider", "type": "@WebInspect