From 37859d334ae99af5e989924c70d3aefe0543f893 Mon Sep 17 00:00:00 2001
From: David Fugate <dfugate@microsoft.com>
Date: Mon, 17 Jan 2011 15:01:19 -0800
Subject: [PATCH] - default.html still had a reference to reports.js.  Removed.
  Also, removed test\harness\reports.js - test\harness\sth.js:  fixed a bug
 spotted by Mark Miller.  In short, we were allowing   a test case return
 value of 'undefined' to be successful WRT IE Test Center tests because  
 Sputnik tests normally return undefined (successful or not).  We now
 differentiate between   Sputnik/IE Test Center when evaluating return values

---
 test/harness/reports.js                 | 157 ------------------------
 test/harness/sth.js                     |  12 +-
 website/default.html                    |   1 -
 website/resources/scripts/global/sth.js |   5 +-
 4 files changed, 6 insertions(+), 169 deletions(-)
 delete mode 100644 test/harness/reports.js

diff --git a/test/harness/reports.js b/test/harness/reports.js
deleted file mode 100644
index c4ba06dda7..0000000000
--- a/test/harness/reports.js
+++ /dev/null
@@ -1,157 +0,0 @@
-
-var TEST_RESULT_PATH = "enginereports/testresults/";
-var TEST_REPORT_PATH = "enginereports/testreport.xml";
-var TESTS_REPORT_TABLE_XSL = "enginereports/testsreporttable.xsl";
-var TEST_REPORT_DETAILS_TABLE_XSL = "enginereports/testsreportdetailstable.xsl";
-var TEST_REPORT_INDIV_TESTS_TABLE_XSL="enginereports/testsreportindividualtestdetailstable.xsl";
-var bigFile = null;
-var xslReportSummary = loadXMLDoc(TESTS_REPORT_TABLE_XSL);
-var fileList = [];
-var xslReportDetails = loadXMLDoc(TEST_REPORT_DETAILS_TABLE_XSL);
-var xslTestList = loadXMLDoc(TEST_REPORT_INDIV_TESTS_TABLE_XSL);
-
-// Populate fileList array by reading all xml files in "/enginereports/testresults" directory on server
-function loadTestResultList() {
-    if (fileList.length === 0) {
-        var tempList = ["chrome.xml", "firefox.xml", "ie.xml", "safari.xml"];
-        for (var i = 0; i < tempList.length; i++) {
-            fileList.push(TEST_RESULT_PATH + tempList[i]);
-        }
-    }
-    /*TODO - fix this once we have nginx.conf setup properly for TEST_RESULT_PATH listings
-    on the deployment server
-    
-    if (fileList.length === 0) {
-        var httpRequest = new XMLHttpRequest();
-        httpRequest.open("GET", TEST_RESULT_PATH, false);
-        httpRequest.send();
-
-        // Insert temp elemnt into document with result from directory listing result
-        var tempDiv = document.createElement('tempDiv');
-        tempDiv.innerHTML = httpRequest.responseText;
-
-        // Get all hyperlinks from directory listing result
-        var linkElements = tempDiv.getElementsByTagName("a");
-        for (var i = 0; i < linkElements.length; i++) {
-            if (linkElements[i].pathname.match(".xml$")) {
-                fileList.push(TEST_RESULT_PATH + linkElements[i].innerText);
-            }
-        }
-    }
-    */
-}
-
-function createTestReportFile(fileList) {
-    var testReport = loadXMLDoc(TEST_REPORT_PATH);
-    for (var i = 0; i < fileList.length; i++) {
-        xml = loadXMLDoc(fileList[i]);
-        if (window.ActiveXObject) {
-            testReport.documentElement.appendChild(xml.documentElement);
-        } else {
-            var newNode = testReport.importNode(xml.documentElement, true);
-            testReport.firstChild.appendChild(newNode);
-        }
-    }
-    return testReport;
-}
-
-function loadXMLDoc(dname, type) {
-    xhttp = new XMLHttpRequest();
-    xhttp.open("GET", dname, false);
-    xhttp.send("");
-    if (type === "text") {
-        return xhttp.responseText;
-    } else {
-        return xhttp.responseXML;
-    }
-}
-
-function hideAll() {
-    var reportElement = document.getElementById("report");
-    for (var i = 0; i < reportElement.childNodes.length; i++) {
-        if (reportElement.childNodes[i].id !== undefined) {
-            $('#' + reportElement.childNodes[i].id).hide();
-        }
-    }
-}
-
-function createTestListTable(section) {
-    $("body").addClass("busy");
-    setTimeout(function() {
-        $('#backBrowserReportDiv').show();
-        $('#backBrowserReportDiv').attr('href', 'javascript:createDetailsTable(' + section.split(".")[0] + ');');
-        $('#SummaryTable').hide();
-        hideAll();
-        var normSection = section.replace(/\./g, "_");
-        if ($('#TestList_' + normSection).length > 0) {
-            $('#TestList_' + normSection).show();
-        } else {            
-            if (window.ActiveXObject) {
-                var xslParam = xslTestList.selectSingleNode("//xsl:param[@name='sectionID']");
-                xslParam.setAttribute("select", "'" + section + "'");
-
-                var ex = bigFile.transformNode(xslTestList);
-                document.getElementById("report").innerHTML += ex;
-            } else {
-                xslTestList.getElementsByName("sectionID")[0].attributes["select"].value = "'" + section + "'";
-                xsltProcessor = new XSLTProcessor();
-                xsltProcessor.importStylesheet(xslTestList);
-                resultDocument = xsltProcessor.transformToFragment(bigFile, bigFile);
-                document.getElementById("report").appendChild(resultDocument);
-            }
-        }
-        $("body").removeClass("busy");
-    }, 500);
-}
-
-function createDetailsTable(section) {
-    $("body").addClass("busy");    
-    setTimeout(function() {        
-        $('#backBrowserReportDiv').show();
-        $('#backBrowserReportDiv').attr('href', 'javascript:buildTable();');
-        hideAll();
-        if ($('#section-' + section).length > 0) {
-            $('#section-' + section).show();
-        } else {            
-            if (window.ActiveXObject) {
-                var xslParam = xslReportDetails.selectSingleNode("//xsl:param[@name='sectionID']");
-                xslParam.setAttribute("select", "'" + section + "'");
-                var ex = bigFile.transformNode(xslReportDetails);
-                document.getElementById("report").innerHTML += ex;
-            } else {
-                xslReportDetails.getElementsByName("sectionID")[0].attributes["select"].value = "'" + section + "'";
-                xsltProcessor = new XSLTProcessor();
-                xsltProcessor.importStylesheet(xslReportDetails);
-                resultDocument = xsltProcessor.transformToFragment(bigFile, bigFile);
-                document.getElementById("report").appendChild(resultDocument);
-            }
-        }
-        $("body").removeClass("busy");
-    }, 500);
-    
-}
-
-function buildTable() {
-    // Populate fileList array    
-    loadTestResultList();
-    $('#backBrowserReportDiv').hide();
-    hideAll();
-    if ($('#SummaryTable').length > 0)
-        $('#SummaryTable').show();
-    if (bigFile === null) {
-        var reportElement = document.getElementById("report");
-        bigFile = createTestReportFile(fileList);
-        if (window.ActiveXObject) {
-            testReportSummaryTable = bigFile.transformNode(xslReportSummary);
-            reportElement.innerHTML += testReportSummaryTable;
-        } else {
-            xsltProcessor = new XSLTProcessor();
-            xsltProcessor.importStylesheet(xslReportSummary);
-            testReportSummaryTable = xsltProcessor.transformToFragment(bigFile, bigFile);
-            reportElement.appendChild(testReportSummaryTable);
-        }
-    } else {
-        $('#SummaryTable').show();
-    }
-    $('body').removeClass('busy');
-}
diff --git a/test/harness/sth.js b/test/harness/sth.js
index cb8702b760..ffef339df5 100644
--- a/test/harness/sth.js
+++ b/test/harness/sth.js
@@ -130,10 +130,11 @@ function BrowserRunner() {
                     "ES5Harness.registerTest = function(test) {" +
                     "  var error;" +
                     "  if(test.precondition && !test.precondition()) {" +
-                    "    testRun(test.id, test.path, test.description, test.test.toString(),typeof test.precondition !== 'undefined' ? test.precondition.toString() : undefined, 'fail', 'Precondition Failed');" +
+                    "    testRun(test.id, test.path, test.description, test.test.toString(),typeof test.precondition !== 'undefined' ? test.precondition.toString() : '', 'fail', 'Precondition Failed');" +
                     "  } else {" +
                     "    try { var res = test.test.call(window); } catch(e) { res = 'fail'; error = e; }" +
-                    "    testRun(test.id, test.path, test.description, test.test.toString(), typeof test.precondition !== 'undefined' ? test.precondition.toString() : undefined, res === true || typeof res === 'undefined' ? 'pass' : 'fail', error);" +
+                    "    var retVal = /^s/i.test(test.id) ? (res === true || typeof res === 'undefined' ? 'pass' : 'fail') : (res === true ? 'pass' : 'fail');" +
+                    "    testRun(test.id, test.path, test.description, test.test.toString(), typeof test.precondition !== 'undefined' ? test.precondition.toString() : '', retVal, error);" +
                     "  }" +
                     "}</script>" +
                     "<script type='text/javascript'>" + code + "</script>" +
@@ -444,13 +445,6 @@ $(function () {
             if ($(target).hasClass('content-results')) {
                 presenter.refresh();
             }
-            //If clicked tab is Browsers Report, it shows the reports
-            if (target === '.content-browsers') {
-                $("body").addClass("busy");
-                setTimeout(function () {
-                    buildTable();
-                }, 500);
-            }
         });
     });
 
diff --git a/website/default.html b/website/default.html
index 52ecd142a3..b86b5fc544 100644
--- a/website/default.html
+++ b/website/default.html
@@ -8,7 +8,6 @@
 <script type="text/javascript" src="resources/scripts/global/jqueryprogressbar.js"></script>
 <script type="text/javascript" src="resources/scripts/global/helper.js"></script>
 <script type="text/javascript" src="resources/scripts/global/jquery.base64.js"></script>
-<script type="text/javascript" src="resources/scripts/global/reports.js"></script>
 <script type="text/javascript" src="resources/scripts/global/sputnikLib.js"></script>
 <script language="javascript" type="text/javascript">
     //To support all the browsers
diff --git a/website/resources/scripts/global/sth.js b/website/resources/scripts/global/sth.js
index fb7c24a883..ffef339df5 100644
--- a/website/resources/scripts/global/sth.js
+++ b/website/resources/scripts/global/sth.js
@@ -130,10 +130,11 @@ function BrowserRunner() {
                     "ES5Harness.registerTest = function(test) {" +
                     "  var error;" +
                     "  if(test.precondition && !test.precondition()) {" +
-                    "    testRun(test.id, test.path, test.description, test.test.toString(),typeof test.precondition !== 'undefined' ? test.precondition.toString() : undefined, 'fail', 'Precondition Failed');" +
+                    "    testRun(test.id, test.path, test.description, test.test.toString(),typeof test.precondition !== 'undefined' ? test.precondition.toString() : '', 'fail', 'Precondition Failed');" +
                     "  } else {" +
                     "    try { var res = test.test.call(window); } catch(e) { res = 'fail'; error = e; }" +
-                    "    testRun(test.id, test.path, test.description, test.test.toString(), typeof test.precondition !== 'undefined' ? test.precondition.toString() : undefined, res === true || typeof res === 'undefined' ? 'pass' : 'fail', error);" +
+                    "    var retVal = /^s/i.test(test.id) ? (res === true || typeof res === 'undefined' ? 'pass' : 'fail') : (res === true ? 'pass' : 'fail');" +
+                    "    testRun(test.id, test.path, test.description, test.test.toString(), typeof test.precondition !== 'undefined' ? test.precondition.toString() : '', retVal, error);" +
                     "  }" +
                     "}</script>" +
                     "<script type='text/javascript'>" + code + "</script>" +
-- 
GitLab