WebInspector.AuditsPanel=function() {WebInspector.PanelWithSidebar.call(this,"audits");this.registerRequiredCSS("ui/panelEnablerView.css");this.registerRequiredCSS("audits/auditsPanel.css");var sidebarTree=new TreeOutline();sidebarTree.element.classList.add("sidebar-tree");this.panelSidebarElement().appendChild(sidebarTree.element);this.setDefaultFocusedElement(sidebarTree.element);this.auditsTreeElement=new WebInspector.SidebarSectionTreeElement("");sidebarTree.appendChild(this.auditsTreeElement);this.auditsTreeElement.listItemElement.classList.add("hidden");this.auditsItemTreeElement=new WebInspector.AuditsSidebarTreeElement(this);this.auditsTreeElement.appendChild(this.auditsItemTreeElement);this.auditResultsTreeElement=new WebInspector.SidebarSectionTreeElement(WebInspector.UIString("RESULTS"));sidebarTree.appendChild(this.auditResultsTreeElement);this.auditResultsTreeElement.expand();this._constructCategories();this._auditController=new WebInspector.AuditController(this);this._launcherView=new WebInspector.AuditLauncherView(this._auditController);for(var id in this.categoriesById) this._launcherView.addCategory(this.categoriesById[id]);var extensionCategories=WebInspector.extensionServer.auditCategories();for(var i=0;i150;},__proto__:WebInspector.AuditRule.prototype} WebInspector.AuditRules.CombineExternalResourcesRule=function(id,name,type,resourceTypeName,allowedPerDomain) {WebInspector.AuditRule.call(this,id,name);this._type=type;this._resourceTypeName=resourceTypeName;this._allowedPerDomain=allowedPerDomain;} WebInspector.AuditRules.CombineExternalResourcesRule.prototype={doRun:function(target,requests,result,callback,progress) {var domainToResourcesMap=WebInspector.AuditRules.getDomainToResourcesMap(requests,[this._type],false);var penalizedResourceCount=0;var summary=result.addChild("",true);for(var domain in domainToResourcesMap){var domainResources=domainToResourcesMap[domain];var extraResourceCount=domainResources.length-this._allowedPerDomain;if(extraResourceCount<=0) continue;penalizedResourceCount+=extraResourceCount-1;summary.addChild(WebInspector.UIString("%d %s resources served from %s.",domainResources.length,this._resourceTypeName,WebInspector.AuditRuleResult.resourceDomain(domain)));result.violationCount+=domainResources.length;} if(!penalizedResourceCount){callback(null);return;} summary.value=WebInspector.UIString("There are multiple resources served from same domain. Consider combining them into as few files as possible.");callback(result);},__proto__:WebInspector.AuditRule.prototype} WebInspector.AuditRules.CombineJsResourcesRule=function(allowedPerDomain){WebInspector.AuditRules.CombineExternalResourcesRule.call(this,"page-externaljs",WebInspector.UIString("Combine external JavaScript"),WebInspector.resourceTypes.Script,"JavaScript",allowedPerDomain);} WebInspector.AuditRules.CombineJsResourcesRule.prototype={__proto__:WebInspector.AuditRules.CombineExternalResourcesRule.prototype} WebInspector.AuditRules.CombineCssResourcesRule=function(allowedPerDomain){WebInspector.AuditRules.CombineExternalResourcesRule.call(this,"page-externalcss",WebInspector.UIString("Combine external CSS"),WebInspector.resourceTypes.Stylesheet,"CSS",allowedPerDomain);} WebInspector.AuditRules.CombineCssResourcesRule.prototype={__proto__:WebInspector.AuditRules.CombineExternalResourcesRule.prototype} WebInspector.AuditRules.MinimizeDnsLookupsRule=function(hostCountThreshold){WebInspector.AuditRule.call(this,"network-minimizelookups",WebInspector.UIString("Minimize DNS lookups"));this._hostCountThreshold=hostCountThreshold;} WebInspector.AuditRules.MinimizeDnsLookupsRule.prototype={doRun:function(target,requests,result,callback,progress) {var summary=result.addChild("");var domainToResourcesMap=WebInspector.AuditRules.getDomainToResourcesMap(requests,null,false);for(var domain in domainToResourcesMap){if(domainToResourcesMap[domain].length>1) continue;var parsedURL=domain.asParsedURL();if(!parsedURL) continue;if(!parsedURL.host.search(WebInspector.AuditRules.IPAddressRegexp)) continue;summary.addSnippet(domain);result.violationCount++;} if(!summary.children||summary.children.length<=this._hostCountThreshold){callback(null);return;} summary.value=WebInspector.UIString("The following domains only serve one resource each. If possible, avoid the extra DNS lookups by serving these resources from existing domains.");callback(result);},__proto__:WebInspector.AuditRule.prototype} WebInspector.AuditRules.ParallelizeDownloadRule=function(optimalHostnameCount,minRequestThreshold,minBalanceThreshold) {WebInspector.AuditRule.call(this,"network-parallelizehosts",WebInspector.UIString("Parallelize downloads across hostnames"));this._optimalHostnameCount=optimalHostnameCount;this._minRequestThreshold=minRequestThreshold;this._minBalanceThreshold=minBalanceThreshold;} WebInspector.AuditRules.ParallelizeDownloadRule.prototype={doRun:function(target,requests,result,callback,progress) {function hostSorter(a,b) {var aCount=domainToResourcesMap[a].length;var bCount=domainToResourcesMap[b].length;return(aCountoptimalHostnameCount) hosts.splice(optimalHostnameCount);var busiestHostResourceCount=domainToResourcesMap[hosts[0]].length;var requestCountAboveThreshold=busiestHostResourceCount-this._minRequestThreshold;if(requestCountAboveThreshold<=0){callback(null);return;} var avgResourcesPerHost=0;for(var i=0,size=hosts.length;itimeMs;},responseHeader:function(request,header) {return request.responseHeaderValue(header);},hasResponseHeader:function(request,header) {return request.responseHeaderValue(header)!==undefined;},isCompressible:function(request) {return request.resourceType().isTextType();},isPubliclyCacheable:function(request) {if(this._isExplicitlyNonCacheable(request)) return false;if(this.responseHeaderMatch(request,"Cache-Control","public")) return true;return request.url.indexOf("?")===-1&&!this.responseHeaderMatch(request,"Cache-Control","private");},responseHeaderMatch:function(request,header,regexp) {return request.responseHeaderValue(header)?request.responseHeaderValue(header).match(new RegExp(regexp,"im")):null;},hasExplicitExpiration:function(request) {return this.hasResponseHeader(request,"Date")&&(this.hasResponseHeader(request,"Expires")||!!this.responseHeaderMatch(request,"Cache-Control","max-age"));},_isExplicitlyNonCacheable:function(request) {var hasExplicitExp=this.hasExplicitExpiration(request);return!!this.responseHeaderMatch(request,"Cache-Control","(no-cache|no-store|must-revalidate)")||!!this.responseHeaderMatch(request,"Pragma","no-cache")||(hasExplicitExp&&!this.freshnessLifetimeGreaterThan(request,0))||(!hasExplicitExp&&!!request.url&&request.url.indexOf("?")>=0)||(!hasExplicitExp&&!this.isCacheableResource(request));},isCacheableResource:function(request) {return request.statusCode!==undefined&&WebInspector.AuditRules.CacheableResponseCodes[request.statusCode];},__proto__:WebInspector.AuditRule.prototype} WebInspector.AuditRules.BrowserCacheControlRule=function() {WebInspector.AuditRules.CacheControlRule.call(this,"http-browsercache",WebInspector.UIString("Leverage browser caching"));} WebInspector.AuditRules.BrowserCacheControlRule.prototype={handleNonCacheableResources:function(requests,result) {if(requests.length){var entry=result.addChild(WebInspector.UIString("The following resources are explicitly non-cacheable. Consider making them cacheable if possible:"),true);result.violationCount+=requests.length;for(var i=0;i=0&&!this.hasResponseHeader(request,"Set-Cookie")&&this.isPubliclyCacheable(request);},_publicCachingCheck:function(request) {return this.isCacheableResource(request)&&!this.isCompressible(request)&&!this.responseHeaderMatch(request,"Cache-Control","public")&&!this.hasResponseHeader(request,"Set-Cookie");},_setCookieCacheableCheck:function(request) {return this.hasResponseHeader(request,"Set-Cookie")&&this.isPubliclyCacheable(request);},__proto__:WebInspector.AuditRules.CacheControlRule.prototype} WebInspector.AuditRules.ImageDimensionsRule=function() {WebInspector.AuditRule.call(this,"page-imagedims",WebInspector.UIString("Specify image dimensions"));} WebInspector.AuditRules.ImageDimensionsRule.prototype={doRun:function(target,requests,result,callback,progress) {var domModel=WebInspector.DOMModel.fromTarget(target);var cssModel=WebInspector.CSSStyleModel.fromTarget(target);if(!domModel||!cssModel){callback(null);return;} var urlToNoDimensionCount={};function doneCallback() {for(var url in urlToNoDimensionCount){var entry=entry||result.addChild(WebInspector.UIString("A width and height should be specified for all images in order to speed up page display. The following image(s) are missing a width and/or height:"),true);var format="%r";if(urlToNoDimensionCount[url]>1) format+=" (%d uses)";entry.addFormatted(format,url,urlToNoDimensionCount[url]);result.violationCount++;} callback(entry?result:null);} function imageStylesReady(imageId,styles) {if(progress.isCanceled()){callback(null);return;} const node=domModel.nodeForId(imageId);var src=node.getAttribute("src");if(!src.asParsedURL()){for(var frameOwnerCandidate=node;frameOwnerCandidate;frameOwnerCandidate=frameOwnerCandidate.parentNode){if(frameOwnerCandidate.baseURL){var completeSrc=WebInspector.ParsedURL.completeURL(frameOwnerCandidate.baseURL,src);break;}}} if(completeSrc) src=completeSrc;if(styles.computedStyle.getPropertyValue("position")==="absolute") return;if(styles.attributesStyle){var widthFound=!!styles.attributesStyle.getLiveProperty("width");var heightFound=!!styles.attributesStyle.getLiveProperty("height");} var inlineStyle=styles.inlineStyle;if(inlineStyle){if(inlineStyle.getPropertyValue("width")!=="") widthFound=true;if(inlineStyle.getPropertyValue("height")!=="") heightFound=true;} for(var i=styles.matchedCSSRules.length-1;i>=0&&!(widthFound&&heightFound);--i){var style=styles.matchedCSSRules[i].style;if(style.getPropertyValue("width")!=="") widthFound=true;if(style.getPropertyValue("height")!=="") heightFound=true;} if(!widthFound||!heightFound){if(src in urlToNoDimensionCount) ++urlToNoDimensionCount[src];else urlToNoDimensionCount[src]=1;}} function getStyles(nodeIds) {if(progress.isCanceled()){callback(null);return;} var targetResult={};function inlineCallback(inlineStyleResult) {if(!inlineStyleResult) return;targetResult.inlineStyle=inlineStyleResult.inlineStyle;targetResult.attributesStyle=inlineStyleResult.attributesStyle;} function matchedCallback(matchedStyleResult) {if(matchedStyleResult) targetResult.matchedCSSRules=matchedStyleResult.matchedCSSRules;} function computedCallback(computedStyle) {targetResult.computedStyle=computedStyle;} if(!nodeIds||!nodeIds.length) doneCallback();var nodePromises=[];for(var i=0;nodeIds&&i");} urlToViolationsArray[root.documentURL]=[inlineStyleNodeIds.length,externalStylesheetHrefs];result=urlToViolationsArray;} evalCallback(result);} function inlineStylesReceived(root,nodeIds) {if(progress.isCanceled()){callback(null);return;} if(!nodeIds) return;domModel.querySelectorAll(root.id,"body link[rel~='stylesheet'][href]",externalStylesheetsReceived.bind(null,root,nodeIds));} function onDocumentAvailable(root) {if(progress.isCanceled()){callback(null);return;} domModel.querySelectorAll(root.id,"body style",inlineStylesReceived.bind(null,root));} domModel.requestDocument(onDocumentAvailable);},__proto__:WebInspector.AuditRule.prototype} WebInspector.AuditRules.StylesScriptsOrderRule=function() {WebInspector.AuditRule.call(this,"page-stylescriptorder",WebInspector.UIString("Optimize the order of styles and scripts"));} WebInspector.AuditRules.StylesScriptsOrderRule.prototype={doRun:function(target,requests,result,callback,progress) {var domModel=WebInspector.DOMModel.fromTarget(target);if(!domModel){callback(null);return;} function evalCallback(resultValue) {if(progress.isCanceled()){callback(null);return;} if(!resultValue) return callback(null);var lateCssUrls=resultValue[0];var cssBeforeInlineCount=resultValue[1];if(lateCssUrls.length){var entry=result.addChild(WebInspector.UIString("The following external CSS files were included after an external JavaScript file in the document head. To ensure CSS files are downloaded in parallel, always include external CSS before external JavaScript."),true);entry.addURLs(lateCssUrls);result.violationCount+=lateCssUrls.length;} if(cssBeforeInlineCount){result.addChild(WebInspector.UIString(" %d inline script block%s found in the head between an external CSS file and another resource. To allow parallel downloading, move the inline script before the external CSS file, or after the next resource.",cssBeforeInlineCount,cssBeforeInlineCount>1?"s were":" was"));result.violationCount+=cssBeforeInlineCount;} callback(result);} function cssBeforeInlineReceived(lateStyleIds,nodeIds) {if(progress.isCanceled()){callback(null);return;} if(!nodeIds) return;var cssBeforeInlineCount=nodeIds.length;var result=null;if(lateStyleIds.length||cssBeforeInlineCount){var lateStyleUrls=[];for(var i=0;i");} result=[lateStyleUrls,cssBeforeInlineCount];} evalCallback(result);} function lateStylesReceived(root,nodeIds) {if(progress.isCanceled()){callback(null);return;} if(!nodeIds) return;domModel.querySelectorAll(root.id,"head link[rel~='stylesheet'][href] ~ script:not([src])",cssBeforeInlineReceived.bind(null,nodeIds));} function onDocumentAvailable(root) {if(progress.isCanceled()){callback(null);return;} domModel.querySelectorAll(root.id,"head script[src] ~ link[rel~='stylesheet'][href]",lateStylesReceived.bind(null,root));} domModel.requestDocument(onDocumentAvailable);},__proto__:WebInspector.AuditRule.prototype} WebInspector.AuditRules.CSSRuleBase=function(id,name) {WebInspector.AuditRule.call(this,id,name);} WebInspector.AuditRules.CSSRuleBase.prototype={doRun:function(target,requests,result,callback,progress) {var cssModel=WebInspector.CSSStyleModel.fromTarget(target);if(!cssModel){callback(null);return;} var headers=cssModel.allStyleSheets();if(!headers.length){callback(null);return;} var activeHeaders=[];for(var i=0;i"));if(!this._ruleResult){var anchor=WebInspector.linkifyURLAsNode(styleSheet.sourceURL,rule.selectorText);anchor.lineNumber=rule.lineNumber;this._ruleResult=this._styleSheetResult.addChild(anchor);} ++result.violationCount;this._ruleResult.addSnippet(WebInspector.UIString("\"%s%s\" is used, but \"%s\" is supported.",this._webkitPrefix,normalPropertyName,normalPropertyName));}},__proto__:WebInspector.AuditRules.CSSRuleBase.prototype} WebInspector.AuditRules.CookieRuleBase=function(id,name) {WebInspector.AuditRule.call(this,id,name);} WebInspector.AuditRules.CookieRuleBase.prototype={doRun:function(target,requests,result,callback,progress) {var self=this;function resultCallback(receivedCookies) {if(progress.isCanceled()){callback(result);return;} self.processCookies(receivedCookies,requests,result);callback(result);} WebInspector.Cookies.getCookiesAsync(resultCallback);},mapResourceCookies:function(requestsByDomain,allCookies,callback) {for(var i=0;ithis._maxBytesThreshold) hugeCookieDomains.push(WebInspector.AuditRuleResult.resourceDomain(sortedCookieSizes[i].domain)+": "+Number.bytesToString(maxCookieSize));} var bigAvgCookieDomains=[];sortedCookieSizes.sort(avgSizeSorter);for(var i=0,len=sortedCookieSizes.length;ithis._avgBytesThreshold&&avgCookieSize button {\n -webkit-align-self: flex-start;\n margin-right: 10px;\n margin-bottom: 5px;\n margin-top: 5px;\n}\n\n.audit-launcher-view fieldset.audit-categories-container {\n position: relative;\n top: 11px;\n left: 0;\n width: 100%;\n overflow-y: auto;\n border: 0 none;\n -webkit-flex: none;\n}\n\n.audit-launcher-view button {\n margin: 0 5px 0 0;\n}\n\n.panel-enabler-view.audit-launcher-view label {\n padding: 0 0 5px 0;\n margin: 0;\n display: flex;\n flex-shrink: 0;\n}\n\n.panel-enabler-view.audit-launcher-view label.disabled {\n color: rgb(130, 130, 130);\n}\n\n.audit-launcher-view input[type=\"checkbox\"] {\n margin-left: 0;\n height: 14px;\n width: 14px;\n}\n\n.audit-result-view {\n overflow: auto;\n display: block;\n flex: auto;\n}\n\n.audit-result-tree {\n margin: 0 0 3px;\n}\n\n.audit-launcher-view .progress-indicator {\n display: inline-block;\n}\n\n.resource-url {\n float: right;\n text-align: right;\n max-width: 100%;\n margin-left: 4px;\n}\n\n/*# sourceURL=audits/auditsPanel.css */";Runtime.cachedResources["audits/auditResultTree.css"]="/*\n * Copyright 2015 The Chromium Authors. All rights reserved.\n * Use of this source code is governed by a BSD-style license that can be\n * found in the LICENSE file.\n */\n\n.severity {\n background-image: url(Images/toolbarButtonGlyphs.png);\n background-size: 352px 144px;\n display: inline-block;\n width: 10px;\n height: 10px;\n position: relative;\n top: 1px;\n margin-right: 4px;\n}\n\nli {\n -webkit-user-select: text;\n}\n\n@media (-webkit-min-device-pixel-ratio: 1.5) {\n.severity {\n background-image: url(Images/toolbarButtonGlyphs_2x.png);\n}\n} /* media */\n\n.severity.severe {\n background-position: -224px -96px;\n}\n\n.severity.warning {\n background-position: -246px -96px;\n}\n\n.severity.info {\n background-position: -235px -96px;\n}\n.audit-result {\n font-weight: bold;\n}\n\n/*# sourceURL=audits/auditResultTree.css */";