📄 resource.js
字号:
return; this._type = x; switch (x) { case WebInspector.Resource.Type.Document: this.category = WebInspector.resourceCategories.documents; break; case WebInspector.Resource.Type.Stylesheet: this.category = WebInspector.resourceCategories.stylesheets; break; case WebInspector.Resource.Type.Script: this.category = WebInspector.resourceCategories.scripts; break; case WebInspector.Resource.Type.Image: this.category = WebInspector.resourceCategories.images; break; case WebInspector.Resource.Type.Font: this.category = WebInspector.resourceCategories.fonts; break; case WebInspector.Resource.Type.XHR: this.category = WebInspector.resourceCategories.xhr; break; case WebInspector.Resource.Type.Other: default: this.category = WebInspector.resourceCategories.other; break; } }, get documentNode() { if ("identifier" in this) return InspectorController.getResourceDocumentNode(this.identifier); return null; }, get requestHeaders() { if (this._requestHeaders === undefined) this._requestHeaders = {}; return this._requestHeaders; }, set requestHeaders(x) { if (this._requestHeaders === x) return; this._requestHeaders = x; delete this._sortedRequestHeaders; this.dispatchEventToListeners("requestHeaders changed"); }, get sortedRequestHeaders() { if (this._sortedRequestHeaders !== undefined) return this._sortedRequestHeaders; this._sortedRequestHeaders = []; for (var key in this.requestHeaders) this._sortedRequestHeaders.push({header: key, value: this.requestHeaders[key]}); this._sortedRequestHeaders.sort(function(a,b) { return a.header.localeCompare(b.header) }); return this._sortedRequestHeaders; }, get responseHeaders() { if (this._responseHeaders === undefined) this._responseHeaders = {}; return this._responseHeaders; }, set responseHeaders(x) { if (this._responseHeaders === x) return; this._responseHeaders = x; delete this._sortedResponseHeaders; this.dispatchEventToListeners("responseHeaders changed"); }, get sortedResponseHeaders() { if (this._sortedResponseHeaders !== undefined) return this._sortedResponseHeaders; this._sortedResponseHeaders = []; for (var key in this.responseHeaders) this._sortedResponseHeaders.push({header: key, value: this.responseHeaders[key]}); this._sortedResponseHeaders.sort(function(a,b) { return a.header.localeCompare(b.header) }); return this._sortedResponseHeaders; }, get scripts() { if (!("_scripts" in this)) this._scripts = []; return this._scripts; }, addScript: function(script) { if (!script) return; this.scripts.unshift(script); script.resource = this; }, removeAllScripts: function() { if (!this._scripts) return; for (var i = 0; i < this._scripts.length; ++i) { if (this._scripts[i].resource === this) delete this._scripts[i].resource; } delete this._scripts; }, removeScript: function(script) { if (!script) return; if (script.resource === this) delete script.resource; if (!this._scripts) return; this._scripts.remove(script); }, get errors() { return this._errors || 0; }, set errors(x) { this._errors = x; }, get warnings() { return this._warnings || 0; }, set warnings(x) { this._warnings = x; }, get tips() { if (!("_tips" in this)) this._tips = {}; return this._tips; }, _addTip: function(tip) { if (tip.id in this.tips) return; this.tips[tip.id] = tip; // FIXME: Re-enable this code once we have a scope bar in the Console. // Otherwise, we flood the Console with too many tips. /* var msg = new WebInspector.ConsoleMessage(WebInspector.ConsoleMessage.MessageSource.Other, WebInspector.ConsoleMessage.MessageLevel.Tip, -1, this.url, null, 1, tip.message); WebInspector.console.addMessage(msg); */ }, _checkTips: function() { for (var tip in WebInspector.Tips) this._checkTip(WebInspector.Tips[tip]); }, _checkTip: function(tip) { var addTip = false; switch (tip.id) { case WebInspector.Tips.ResourceNotCompressed.id: addTip = this._shouldCompress(); break; } if (addTip) this._addTip(tip); }, _shouldCompress: function() { return WebInspector.Resource.Type.isTextType(this.type) && this.domain && !("Content-Encoding" in this.responseHeaders) && this.contentLength !== undefined && this.contentLength >= 512; }, _mimeTypeIsConsistentWithType: function() { if (typeof this.type === "undefined" || this.type === WebInspector.Resource.Type.Other || this.type === WebInspector.Resource.Type.XHR) return true; if (this.mimeType in WebInspector.MIMETypes) return this.type in WebInspector.MIMETypes[this.mimeType]; return true; }, _checkWarnings: function() { for (var warning in WebInspector.Warnings) this._checkWarning(WebInspector.Warnings[warning]); }, _checkWarning: function(warning) { var addWarning = false; var msg; switch (warning.id) { case WebInspector.Warnings.IncorrectMIMEType.id: if (!this._mimeTypeIsConsistentWithType()) msg = new WebInspector.ConsoleMessage(WebInspector.ConsoleMessage.MessageSource.Other, WebInspector.ConsoleMessage.MessageLevel.Warning, -1, this.url, null, 1, String.sprintf(WebInspector.Warnings.IncorrectMIMEType.message, WebInspector.Resource.Type.toString(this.type), this.mimeType)); break; } if (msg) WebInspector.console.addMessage(msg); }}WebInspector.Resource.prototype.__proto__ = WebInspector.Object.prototype;WebInspector.Resource.CompareByStartTime = function(a, b){ if (a.startTime < b.startTime) return -1; if (a.startTime > b.startTime) return 1; return 0;}WebInspector.Resource.CompareByResponseReceivedTime = function(a, b){ if (a.responseReceivedTime === -1 && b.responseReceivedTime !== -1) return 1; if (a.responseReceivedTime !== -1 && b.responseReceivedTime === -1) return -1; if (a.responseReceivedTime < b.responseReceivedTime) return -1; if (a.responseReceivedTime > b.responseReceivedTime) return 1; return 0;}WebInspector.Resource.CompareByEndTime = function(a, b){ if (a.endTime === -1 && b.endTime !== -1) return 1; if (a.endTime !== -1 && b.endTime === -1) return -1; if (a.endTime < b.endTime) return -1; if (a.endTime > b.endTime) return 1; return 0;}WebInspector.Resource.CompareByDuration = function(a, b){ if (a.duration < b.duration) return -1; if (a.duration > b.duration) return 1; return 0;}WebInspector.Resource.CompareByLatency = function(a, b){ if (a.latency < b.latency) return -1; if (a.latency > b.latency) return 1; return 0;}WebInspector.Resource.CompareBySize = function(a, b){ if (a.contentLength < b.contentLength) return -1; if (a.contentLength > b.contentLength) return 1; return 0;}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -