// Using Logger.js - for logging results of Client Tests // Using BrowserDetect.js - for detecting clients browser, browser version, and operating system // Using FlashDetect.js - for detecting clients flash and version // Using PopupBlockerDetect.js - for detecting pop-up blockers // Using ConnectionSpeedTester.js - for detecting clients connection speed var applicationPath = ""; var absoluteDomainName = ""; function RunTests(absDomain, appPath, runBrowserTest, supportedBrowsers, runActiveXTest, runFlashTest, supportedFlashVersion, runCodeInitiatedPopupBlockerTest, runTroughputTest, runJavaTest, supportedJavaVersions, runScreenResolutionTest, minimumScreenResolution, sendTestResults, runAjaxTest, runXmlParserTest, runTutorProTest, supportedTutorProVersions) { logger.EraseLog('AutomatedTests', false); ClearTestResults(); SetMaxTestTimes((runTroughputTest ? 2 : 1) + (runCodeInitiatedPopupBlockerTest ? 1 : 0)); SetCallbackURL(appPath); applicationPath = appPath; absoluteDomainName = absDomain; if (runBrowserTest) { TestBrowser(supportedBrowsers); } if (runActiveXTest) { TestActiveX(); } if (runTroughputTest) { InitializeTestConnectionSpeed(); } if (runJavaTest) { TestJava(supportedJavaVersions); } var isiPad = navigator.userAgent.match(/iPad/i) != null; if (runCodeInitiatedPopupBlockerTest && !isiPad) { var popupBlockerInterval = window.setInterval( function() { window.clearInterval(popupBlockerInterval); TestForPopupBlocker(true); }, 100 ); } if (runFlashTest) { TestFlash(supportedFlashVersion); } if (runScreenResolutionTest) { TestScreenResolution(minimumScreenResolution); } var testAjaxAndXml = true; if (runAjaxTest) { testAjaxAndXml = TestAjax(); } if (runXmlParserTest) { testAjaxAndXml &= TestXmlParser(); } if (runAjaxTest || runXmlParserTest) { if (testAjaxAndXml) { logger.Debug('AutomatedTests', 'AJAX support - Passed', "#AjaxDesc"); } else { logger.Error('AutomatedTests', 'AJAX support - Failed', "#AjaxDesc"); } } if (runTutorProTest) { TestTutorProActiveX(supportedTutorProVersions); } if (typeof (sendTestResults) == "undefined") { return; } if (sendTestResults) { SendTestsResults(); } } function RunManualTests(runUserInitiatedPopupBlockerTest) { logger.EraseLog('ManualTests', false); if (runUserInitiatedPopupBlockerTest) { TestForPopupBlocker(false, function(popupBlockerDetected) { if (popupBlockerDetected) { logger.Error('ManualTests', 'Pop-Up Blocker Detected For A User Initiated Pop-Up - Failed', "#PopupDesc"); } else { logger.Debug('ManualTests', 'No Pop-Up Blockers Were Detected For A User Initiated Pop-Up - Passed', "#PopupDesc"); } } ); } } // ---------------------------------------------------------------------------------------------------------------------------- // Test Browser and OS // ---------------------------------------------------------------------------------------------------------------------------- var browser = new BrowserDetect(); function TestBrowser(supportedBrowsers) { var requiredBrowserVersion = ""; var browserVendor = ""; if (browser.isIE) { requiredBrowserVersion = GetRequiredVersion(supportedBrowsers, "IE"); browserVendor = "Internet Explorer"; } else if (browser.isNS) { requiredBrowserVersion = GetRequiredVersion(supportedBrowsers, "Netscape"); browserVendor = "Netscape"; } else if (browser.isFirefox) { requiredBrowserVersion = GetRequiredVersion(supportedBrowsers, "Firefox"); browserVendor = "Firefox"; } else if (browser.isMozilla) { requiredBrowserVersion = GetRequiredVersion(supportedBrowsers, "Mozilla"); browserVendor = "Mozilla"; } else if (browser.isOpera) { requiredBrowserVersion = GetRequiredVersion(supportedBrowsers, "Opera"); browserVendor = "Opera"; } else if (browser.isChrome) { requiredBrowserVersion = GetRequiredVersion(supportedBrowsers, "Chrome"); browserVendor = "Chrome"; } else if (browser.isSafari) { requiredBrowserVersion = GetRequiredVersion(supportedBrowsers, "Safari"); browserVendor = "Safari"; } if (browserVendor != "") { PrintDetection(browserVendor, "" + browser.versionMinor, requiredBrowserVersion, "#BrowserDesc"); var xml = GetResultsXML(); AddTestResults(xml, "testBrowser", new Array( MakeTestResultItem_Result(xml, CompareVersions("" + browser.versionMinor, requiredBrowserVersion) && requiredBrowserVersion != ""), MakeTestResultItem(xml, "vendor", browserVendor), MakeTestResultItem(xml, "version", browser.versionMinor), MakeTestResultItem(xml, "requiredVersion", requiredBrowserVersion) ) ); } else { var xml = GetResultsXML(); AddTestResults(xml, "testBrowser", new Array( MakeTestResultItem_Result(xml, false), MakeTestResultItem(xml, "vendor", browserVendor), MakeTestResultItem(xml, "version", browser.versionMinor), MakeTestResultItem(xml, "requiredVersion", requiredBrowserVersion) ) ); logger.Error('AutomatedTests', 'Was not able to detect Browser and Version - Failed', "#BrowserDesc"); } } // ---------------------------------------------------------------------------------------------------------------------------- // Test ActiveX // ---------------------------------------------------------------------------------------------------------------------------- function TestActiveX() { if (browser.isIE5up) { // alert(window.ActiveXObject); if (window.ActiveXObject || "ActiveXObject" in window) { try { if (new ActiveXObject("Msxml2.XMLHTTP")) { logger.Debug('AutomatedTests', 'ActiveX Detected - Passed', "#ActiveXDesc"); var xml = GetResultsXML(); AddTestResults(xml, "activeX", new Array( MakeTestResultItem_Result(xml, true), MakeTestResultItem(xml, "mode", "Msxml2.XMLHTTP") ) ); } else if (new ActiveXObject("Microsoft.XMLHTTP")) { logger.Debug('AutomatedTests', 'ActiveX Detected - Passed', "#ActiveXDesc"); var xml = GetResultsXML(); AddTestResults(xml, "activeX", new Array( MakeTestResultItem_Result(xml, true), MakeTestResultItem(xml, "mode", "Microsoft.XMLHTTP") ) ); } } catch (e) { logger.Error('AutomatedTests', 'ActiveX Not Detected - Failed', "#ActiveXDesc"); var xml = GetResultsXML(); AddTestResults(xml, "activeX", new Array( MakeTestResultItem_Result(xml, false) ) ); } } else { logger.Error('AutomatedTests', 'ActiveX Not Detected - Failed', "#ActiveXDesc"); var xml = GetResultsXML(); AddTestResults(xml, "activeX", new Array( MakeTestResultItem_Result(xml, false) ) ); } } } // ---------------------------------------------------------------------------------------------------------------------------- // Test Flash // ---------------------------------------------------------------------------------------------------------------------------- function TestFlash(supportedFlashVersion) { var version = com.deconcept.FlashObjectUtil.getPlayerVersion(); if (version) { var flashVersion = version['major'] + "." + version['minor'] + "." + version['rev']; if (flashVersion == "0.0.0") { logger.Error('AutomatedTests', 'Flash Was Not Detected - Failed', "#FlashDesc"); var xml = GetResultsXML(); AddTestResults(xml, "flash", new Array( MakeTestResultItem_Result(xml, false) ) ); } else { PrintDetection("Flash", flashVersion, supportedFlashVersion, "#FlashDesc"); var xml = GetResultsXML(); AddTestResults(xml, "flash", new Array( MakeTestResultItem_Result(xml, CompareVersions(flashVersion, supportedFlashVersion)), MakeTestResultItem(xml, "flashVersion", flashVersion), MakeTestResultItem(xml, "supportedFlashVersion", supportedFlashVersion) ) ); } } } // ---------------------------------------------------------------------------------------------------------------------------- // Test for Popup Blocker // ---------------------------------------------------------------------------------------------------------------------------- function TestForPopupBlocker(autoPopped, callback) { var left = Math.floor((screen.width - 300) / 2); var top = Math.floor((screen.height - 10) / 2); var winParams = "width=300,height=10,toolbar=no,status=no,resizable=no,scrollbars=no,left=" + left + ",top=" + top; // Open New Window var url = absoluteDomainName + applicationPath + '/Modules/ClientEnvironmentTester/Resources/NewWindow.aspx'; var NewWindow = window.open(url, 'NewWindow', winParams); // Make New Window go behind // Check if opened CheckForNewWindow( { popup: NewWindow, callback: function(popupBlockerDetected) { TestForPopupBlockerCallback(popupBlockerDetected, autoPopped); if (typeof callback == "function") callback(popupBlockerDetected); } }); } function TestForPopupBlockerCallback(popupBlockerDetected, autoPopped) { if (!popupBlockerDetected) { if (autoPopped) { logger.Debug('AutomatedTests', 'No Pop-Up Blockers Were Detected For A Code Initiated Pop-Up - Passed', "#PopupDesc"); var xml = GetResultsXML(); AddTestResults(xml, "popups", new Array( MakeTestResultItem_Result(xml, true) ) ); } else return false; } else { if (autoPopped) { logger.Error('AutomatedTests', 'Pop-Up Blocker Detected For A Code Initiated Pop-Up - Failed', "#PopupDesc"); var xml = GetResultsXML(); AddTestResults(xml, "popups", new Array( MakeTestResultItem_Result(xml, false) ) ); } else return true; } SendTestsResults(); } // ---------------------------------------------------------------------------------------------------------------------------- // Test Connection Speed // ---------------------------------------------------------------------------------------------------------------------------- // Start test function InitializeTestConnectionSpeed() { var garbageFileUrl = absoluteDomainName + applicationPath + '/Modules/ClientEnvironmentTester/Resources/XmlGarbageFile.xml'; TestConnectionSpeed(garbageFileUrl); } // Callback Function, TestConnectionSpeed will set this function as the callback function ConnectionSpeedCallback(result, startTime) { if (result.status == Http.Status.OK) { // kbps var throughput = CalculateThroughput(startTime); var connectionType = DetermineConnectionType(throughput); if (throughput >= 54) { logger.Debug('AutomatedTests', connectionType + " " + throughput + ' kbps Detected - Passed', "#ThroughputDesc"); var xml = GetResultsXML(); AddTestResults(xml, "connectionSpeed", new Array( MakeTestResultItem_Result(xml, true), MakeTestResultItem(xml, "connectionType", connectionType), MakeTestResultItem(xml, "speed", throughput) ) ); } else { Warn('AutomatedTests', connectionType + " " + throughput + ' kbps Detected you could experience problems due to latency on your connection - Warning', "#ThroughputDesc"); var xml = GetResultsXML(); AddTestResults(xml, "connectionSpeed", new Array( MakeTestResultItem_Result(xml, false), MakeTestResultItem(xml, "connectionType", connectionType), MakeTestResultItem(xml, "speed", throughput) ) ); } SendTestsResults(); } } // ---------------------------------------------------------------------------------------------------------------------------- // Test Java // ---------------------------------------------------------------------------------------------------------------------------- function TestJava(supportedJavaVersions) { var requiredJavaVersion = ""; var javaVendor = DetectJavaVendor(browser); var javaVersion = DetectJavaVersion(browser); if (javaVendor != "" && javaVersion != "") { if (javaVendor == "Sun Microsystems Inc." || javaVendor == "Oracle Corporation") { requiredJavaVersion = GetRequiredVersion(supportedJavaVersions, "JRE"); PrintDetection(javaVendor, javaVersion, requiredJavaVersion, "#JavaDesc", "Java Plugin: "); var xml = GetResultsXML(); AddTestResults(xml, "java", new Array( MakeTestResultItem_Result(xml, CompareVersions(javaVersion, requiredJavaVersion)), MakeTestResultItem(xml, "javaVendor", javaVendor), MakeTestResultItem(xml, "javaVersion", javaVersion), MakeTestResultItem(xml, "requiredJavaVersion", requiredJavaVersion) ) ); } else if (javaVendor == "Microsoft Corp.") { requiredJavaVersion = GetRequiredVersion(supportedJavaVersions, "JVM"); PrintDetection(javaVendor, javaVersion, requiredJavaVersion, "#JavaDesc", "Java Plugin: "); var xml = GetResultsXML(); AddTestResults(xml, "java", new Array( MakeTestResultItem_Result(xml, CompareVersions(javaVersion, requiredJavaVersion)), MakeTestResultItem(xml, "javaVendor", javaVendor), MakeTestResultItem(xml, "javaVersion", javaVersion), MakeTestResultItem(xml, "requiredJavaVersion", requiredJavaVersion) ) ); } else { logger.Error('AutomatedTests', "Java Plugin: " + javaVendor + " Java " + javaVersion + " Detected. " + javaVendor + " " + requiredJavaVersion + " is not supported. - Failed", "#JavaDesc"); var xml = GetResultsXML(); AddTestResults(xml, "java", new Array( MakeTestResultItem_Result(xml, false), MakeTestResultItem(xml, "javaVendor", javaVendor), MakeTestResultItem(xml, "javaVersion", javaVersion), MakeTestResultItem(xml, "requiredJavaVersion", requiredJavaVersion) ) ); } } else { logger.Error('AutomatedTests', 'Java Was Not Detected - Failed', "#JavaDesc"); var xml = GetResultsXML(); AddTestResults(xml, "java", new Array( MakeTestResultItem_Result(xml, false) ) ); } } // ---------------------------------------------------------------------------------------------------------------------------- // Test Screen Resolution // ---------------------------------------------------------------------------------------------------------------------------- function TestScreenResolution(minimumScreenResolution) { var minScreenResolutionArray = minimumScreenResolution.split('x'); var minWidth = parseInt(minScreenResolutionArray[0]); var minHeight = parseInt(minScreenResolutionArray[1]); if ((screen.width >= minWidth) && (screen.height >= minHeight)) { logger.Debug('AutomatedTests', 'Screen Resolution ' + screen.width + "x" + screen.height + ' Detected - Passed', "#ScreenResolutionDesc"); var xml = GetResultsXML(); AddTestResults(xml, "screen", new Array( MakeTestResultItem_Result(xml, true), MakeTestResultItem(xml, "width", screen.width), MakeTestResultItem(xml, "height", screen.height) ) ); } else { logger.Error('AutomatedTests', 'Screen Resolution ' + screen.width + "x" + screen.height + ' Detected - Failed', "#ScreenResolutionDesc"); var xml = GetResultsXML(); AddTestResults(xml, "screen", new Array( MakeTestResultItem_Result(xml, false), MakeTestResultItem(xml, "width", screen.width), MakeTestResultItem(xml, "height", screen.height) ) ); } } // ---------------------------------------------------------------------------------------------------------------------------- // Test Ajax // ---------------------------------------------------------------------------------------------------------------------------- function TestAjax() { try { var ajaxObjSoftXML = null; if (window.XMLHttpRequest) { ajaxObj = new XMLHttpRequest(); } else { ajaxObj = new ActiveXObject("Microsoft.XMLHTTP"); } if (ajaxObj != null) { var xml = GetResultsXML(); AddTestResults(xml, "ajax", new Array( MakeTestResultItem_Result(xml, true) ) ); return true; } else { var xml = GetResultsXML(); AddTestResults(xml, "ajax", new Array( MakeTestResultItem_Result(xml, false) ) ); } } catch (e) { var xml = GetResultsXML(); AddTestResults(xml, "ajax", new Array( MakeTestResultItem_Result(xml, false) ) ); } return false; } // ---------------------------------------------------------------------------------------------------------------------------- // Test Xml Parser // ---------------------------------------------------------------------------------------------------------------------------- function TestXmlParser() { var xml = null; try { if (window.ActiveXObject) { xml = new ActiveXObject("Microsoft.XMLDOM"); } else if (document.implementation && document.implementation.createDocument) { xml = document.implementation.createDocument("", "root", null); } if (xml != null) { var xml = GetResultsXML(); AddTestResults(xml, "xmlParser", new Array( MakeTestResultItem_Result(xml, true) ) ); return true; } else { var xml = GetResultsXML(); AddTestResults(xml, "xmlParser", new Array( MakeTestResultItem_Result(xml, false) ) ); } } catch (e) { var xml = GetResultsXML(); AddTestResults(xml, "xmlParser", new Array( MakeTestResultItem_Result(xml, false) ) ); } return false; } // ---------------------------------------------------------------------------------------------------------------------------- // Test TurboPro ActiveX // ---------------------------------------------------------------------------------------------------------------------------- function TestTutorProActiveX(supportedTutorProVersions) { var e; var ctlCBTobj; var cbtVersion = ""; var requiredTutorProVersion = ""; var detected = false; try { requiredTutorProVersion = GetRequiredVersion(supportedTutorProVersions, "TutorPro"); ctlCBTobj = new ActiveXObject("TutorProCBTObject.TPCBTObject"); if (ctlCBTobj) { cbtVersion = ctlCBTobj.VersionNumber; PrintDetection("TutorPro ActiveX", cbtVersion, requiredTutorProVersion, "#TutorProDesc"); detected = true; } } catch (e) { } finally { ctlCBTobj = null; } if (!detected) { logger.Error('AutomatedTests', "Translate(TutorProDetectionFailed)", "#TutorProDesc"); } var xml = GetResultsXML(); AddTestResults(xml, "tutorPro", new Array( MakeTestResultItem_Result(xml, detected), MakeTestResultItem(xml, "tutorProVersion", cbtVersion), MakeTestResultItem(xml, "requiredTutorProVersion", requiredTutorProVersion) ) ); } // ---------------------------------------------------------------------------------------------------------------------------- // Utility Functions // ---------------------------------------------------------------------------------------------------------------------------- function PrintDetection(vendor, version, requiredVersion, pageAnchor, prefix) { if (prefix == null) { prefix = ""; } if (requiredVersion != "") { if (CompareVersions(version, requiredVersion)) { logger.Debug('AutomatedTests', prefix + vendor + " " + version + ' Detected - Passed', pageAnchor); } else { logger.Error('AutomatedTests', prefix + vendor + " " + version + ' Detected. ' + vendor + " " + requiredVersion + ' is required. - Failed ', pageAnchor); } } else { logger.Error('AutomatedTests', prefix + vendor + " " + version + ' Detected. ' + vendor + " " + requiredVersion + 'is not supported. - Failed', pageAnchor); } } function GetRequiredVersion(supportedTypes, detectedType) { var version = ""; var supportedTypesArray = supportedTypes.split(','); for (i = 0; i < supportedTypesArray.length; i++) { var typeVersionArray = supportedTypesArray[i].split('='); if (typeVersionArray[0].replace(/^\s+|\s+$/g, "") == detectedType) { version = typeVersionArray[1].replace(/^\s+|\s+$/g, ""); break; } } return version; } function CompareVersions(detectedVersion, requiredVersion) { // A version has 3 parts normally. // Major // Minor // Revision // Example: 3.1.5 // Need to take in account only // a major or only major and minor also var detectedMajor = 0; var detectedMinor = 0; var detectedRevision = 0; var requiredMajor = 0; var requiredMinor = 0; var requiredRevision = 0; var detectedVersionArray = detectedVersion.split("."); var requiredVersionArray = requiredVersion.split("."); detectedMajor = parseInt(detectedVersionArray[0]) || 0; detectedMinor = parseInt(detectedVersionArray[1]) || 0; detectedRevision = parseInt(detectedVersionArray[2]) || 0; requiredMajor = parseInt(requiredVersionArray[0]) || 0; requiredMinor = parseInt(requiredVersionArray[1]) || 0; requiredRevision = parseInt(requiredVersionArray[2]) || 0; if (detectedMajor < requiredMajor) return false; if (detectedMajor > requiredMajor) return true; if (detectedMinor < requiredMinor) return false; if (detectedMinor > requiredMinor) return true; if (detectedRevision < requiredRevision) return false; return true; }