agent/browser/ie/pagetest/PagetestReporting.cpp
/*-----------------------------------------------------------------------------
	Check to make sure CSS and JS files are combined (at least into top-level domain)
-----------------------------------------------------------------------------*/
Check to make sure CSS and JS files are combined (at least into top-level domain)
Check to make sure CSS and JS files are combined ( at least into top - level domain )
void CPagetestReporting::CheckCombine()
{
	combineScore = 100;	
	int count = 0;
	int total = 0;
	int jsCount = 0;
	int cssCount = 0;
	ATLTRACE(_T("[Pagetest] - CheckCombine\n"));
	POSITION pos = events.GetHeadPosition();
	while( pos )
	{
		CTrackedEvent * e = events.GetNext(pos);
		if( e && e->type == CTrackedEvent::etWinInetRequest && !e->ignore && e->start <= startRender )
		{
			CWinInetRequest * w = (CWinInetRequest *)e;
			CString mime = w->response.contentType;
			mime.MakeLower();
			CString exp = w->response.expires;
			exp.Trim();
			CString cache = w->response.cacheControl;
			cache.MakeLower();
			CString pragma = w->response.pragma;
			pragma.MakeLower();
			if( w->result == 200 &&
				w->fromNet &&
				exp != _T("0") && 
				exp != _T("-1") && 
				!(cache.Find(_T("no-store")) > -1) &&
				!(cache.Find(_T("no-cache")) > -1) &&
				!(pragma.Find(_T("no-cache")) > -1) &&
				(	mime.Find(_T("/css")) >= 0 || 
					mime.Find(_T("javascript")) >= 0 ) )
			{
				count++;
				w->combineScore = 0;
				if( mime.Find(_T("/css")) >= 0 )
					cssCount++;
				else
					jsCount++;
				int cnt = 0;
				POSITION pos2 = events.GetHeadPosition();
				while( pos2 )
				{
					CTrackedEvent * e2 = events.GetNext(pos2);
					if( e2 && e2->type == CTrackedEvent::etWinInetRequest && e2->start <= startRender )
					{
						CWinInetRequest * w2 = (CWinInetRequest *)e2;
						CString mime2 = w2->response.contentType;
						mime2.MakeLower();
						if( mime2 == mime )
						{
							exp = w2->response.expires;
							exp.Trim();
							cache = w2->response.cacheControl;
							cache.MakeLower();
							pragma = w2->response.pragma;
							pragma.MakeLower();
							if( exp != _T("0") && 
								exp != _T("-1") && 
								!(cache.Find(_T("no-store")) > -1) &&
								!(cache.Find(_T("no-cache")) > -1) &&
								!(pragma.Find(_T("no-cache")) > -1) )
							{
									cnt++;
							}
						}
					}
				}
				if( cnt <= 1 )
					w->combineScore = 100;
				if( !w->combineScore )
					w->warning = true;
				total += w->combineScore;
			}
		}
	}
	if( count )
		combineScore = max(100 - ((max(jsCount,1) - 1)*10) - ((max(cssCount,1) - 1)*5), 0);
}
void CPagetestReporting :: CheckCombine ( ) { combineScore = 100 ; int count = 0 ; int total = 0 ; int jsCount = 0 ; int cssCount = 0 ; ATLTRACE ( _T ( " \n " ) ) ; POSITION pos = events . GetHeadPosition ( ) ; while ( pos ) { CTrackedEvent * e = events . GetNext ( pos ) ; if ( e && e -> type == CTrackedEvent :: etWinInetRequest && ! e -> ignore && e -> start <= startRender ) { CWinInetRequest * w = ( CWinInetRequest * ) e ; CString mime = w -> response . contentType ; mime . MakeLower ( ) ; CString exp = w -> response . expires ; exp . Trim ( ) ; CString cache = w -> response . cacheControl ; cache . MakeLower ( ) ; CString pragma = w -> response . pragma ; pragma . MakeLower ( ) ; if ( w -> result == 200 && w -> fromNet && exp != _T ( " " ) && exp != _T ( " " ) && ! ( cache . Find ( _T ( " " ) ) > -1 ) && ! ( cache . Find ( _T ( " " ) ) > -1 ) && ! ( pragma . Find ( _T ( " " ) ) > -1 ) && ( mime . Find ( _T ( " " ) ) >= 0 || mime . Find ( _T ( " " ) ) >= 0 ) ) { count ++ ; w -> combineScore = 0 ; if ( mime . Find ( _T ( " " ) ) >= 0 ) cssCount ++ ; else jsCount ++ ; int cnt = 0 ; POSITION pos2 = events . GetHeadPosition ( ) ; while ( pos2 ) { CTrackedEvent * e2 = events . GetNext ( pos2 ) ; if ( e2 && e2 -> type == CTrackedEvent :: etWinInetRequest && e2 -> start <= startRender ) { CWinInetRequest * w2 = ( CWinInetRequest * ) e2 ; CString mime2 = w2 -> response . contentType ; mime2 . MakeLower ( ) ; if ( mime2 == mime ) { exp = w2 -> response . expires ; exp . Trim ( ) ; cache = w2 -> response . cacheControl ; cache . MakeLower ( ) ; pragma = w2 -> response . pragma ; pragma . MakeLower ( ) ; if ( exp != _T ( " " ) && exp != _T ( " " ) && ! ( cache . Find ( _T ( " " ) ) > -1 ) && ! ( cache . Find ( _T ( " " ) ) > -1 ) && ! ( pragma . Find ( _T ( " " ) ) > -1 ) ) { cnt ++ ; } } } } if ( cnt <= 1 ) w -> combineScore = 100 ; if ( ! w -> combineScore ) w -> warning = true ; total += w -> combineScore ; } } } if ( count ) combineScore = max ( 100 - ( ( max ( jsCount , 1 ) - 1 ) * 10 ) - ( ( max ( cssCount , 1 ) - 1 ) * 5 ) , 0 ) ; }
Check to make sure CSS and JS files are combined (at least into top-level domain)
Check to make sure CSS and JS files are combined ( at least into top - level domain )
// default to 100 as "no applicable objects" is a success
 // average the Combine scores of all of the objects for the page
