Add a chromeless view to the individual tests view
authorojan@chromium.org <ojan@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 10 Apr 2012 22:59:52 +0000 (22:59 +0000)
committerojan@chromium.org <ojan@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 10 Apr 2012 22:59:52 +0000 (22:59 +0000)
https://bugs.webkit.org/show_bug.cgi?id=83541

Reviewed by Daniel Bates.

This is the view suitable to inlining in other contexts (e.g. garden-o-matic).

* TestResultServer/static-dashboards/flakiness_dashboard.html:
* TestResultServer/static-dashboards/flakiness_dashboard_tests.js:
(testHtmlForIndividualTestOnAllBuilders):
(testHtmlForIndividualTestOnAllBuildersWithChromeNonexistant):
(testHtmlForIndividualTestOnAllBuildersWithChrome):
(testHtmlForIndividualTestOnAllBuildersWithChromeWebkitMaster):
(testHtmlForIndividualTests):
(htmlEscape):
(runTests):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@113787 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Tools/ChangeLog
Tools/TestResultServer/static-dashboards/flakiness_dashboard.html
Tools/TestResultServer/static-dashboards/flakiness_dashboard_tests.js

index 4446323..6ab733c 100644 (file)
@@ -1,3 +1,22 @@
+2012-04-10  Ojan Vafai  <ojan@chromium.org>
+
+        Add a chromeless view to the individual tests view
+        https://bugs.webkit.org/show_bug.cgi?id=83541
+
+        Reviewed by Daniel Bates.
+
+        This is the view suitable to inlining in other contexts (e.g. garden-o-matic).
+
+        * TestResultServer/static-dashboards/flakiness_dashboard.html:
+        * TestResultServer/static-dashboards/flakiness_dashboard_tests.js:
+        (testHtmlForIndividualTestOnAllBuilders):
+        (testHtmlForIndividualTestOnAllBuildersWithChromeNonexistant):
+        (testHtmlForIndividualTestOnAllBuildersWithChrome):
+        (testHtmlForIndividualTestOnAllBuildersWithChromeWebkitMaster):
+        (testHtmlForIndividualTests):
+        (htmlEscape):
+        (runTests):
+
 2012-04-10  Dirk Pranke  <dpranke@chromium.org>
 
         remove 'win' from chromium-win, chromium-linux fallback paths
index 62e9837..e022d53 100644 (file)
@@ -433,6 +433,7 @@ function handleValidHashParameter(key, value)
             });
         return true;
 
+    case 'showChrome':
     case 'showCorrectExpectations':
     case 'showWrongExpectations':
     case 'showExpectations':
@@ -459,6 +460,7 @@ g_defaultDashboardSpecificStateValues = {
     showFlaky: true,
     showLargeExpectations: false,
     legacyExpectationsSemantics: true,
+    showChrome: true,
     showCorrectExpectations: !isLayoutTestResults(),
     showWrongExpectations: !isLayoutTestResults(),
     showWontFixSkip: !isLayoutTestResults(),
@@ -1737,7 +1739,7 @@ function showUpdateInfoForTest(testsNeedingUpdate, keys)
     document.body.appendChild(checkboxes);
 
     var div = document.createElement('div');
-    div.innerHTML = htmlForIndividulTestOnAllBuilders(test);
+    div.innerHTML = htmlForIndividualTestOnAllBuildersWithChrome(test);
     document.body.appendChild(div);
     appendExpectations();
 }
@@ -1807,24 +1809,13 @@ function setUpdateIndex(newIndex, testsNeedingUpdate, keys)
     showUpdateInfoForTest(testsNeedingUpdate, keys);
 }
 
-function htmlForIndividulTestOnAllBuilders(test)
+function htmlForIndividualTestOnAllBuilders(test)
 {
     processTestRunsForAllBuilders();
 
     var testResults = g_testToResultsMap[test];
-    var master;
     var html = '';
-    if (isLayoutTestResults()) {
-        var suite = lookupVirtualTestSuite(test);
-        var base = suite ? baseTest(test, suite) : test;
-        var tracURL = TEST_URL_BASE_PATH_TRAC + base;
-        html += '<h2>' + linkHTMLToOpenWindow(tracURL, test) + '</h2>';
-    } else
-        html += '<h2>' + test + '</h2>';
-
-    if (testResults && testResults.length) {
-        master = builderMaster(testResults[0].builder);
-
+    if (testResults) {
         html +='<div><b>If a builder is not listed, that means the builder ' +
             'does not run that test (e.g. it is skipped) or all runs of the ' +
             'test passed.</b></div>';
@@ -1836,6 +1827,24 @@ function htmlForIndividulTestOnAllBuilders(test)
         html += '<div class="not-found">Test not found. Either it does ' +
             'not exist, is skipped or passes on all platforms.</div>';
     }
+    return html;
+}
+
+function htmlForIndividualTestOnAllBuildersWithChrome(test)
+{
+    processTestRunsForAllBuilders();
+
+    var testResults = g_testToResultsMap[test];
+    var html = '';
+    if (isLayoutTestResults()) {
+        var suite = lookupVirtualTestSuite(test);
+        var base = suite ? baseTest(test, suite) : test;
+        var tracURL = TEST_URL_BASE_PATH_TRAC + base;
+        html += '<h2>' + linkHTMLToOpenWindow(tracURL, test) + '</h2>';
+    } else
+        html += '<h2>' + test + '</h2>';
+
+    html += htmlForIndividualTestOnAllBuilders(test);
 
     html += '<div class=expectations test=' + test + '><div>' +
         linkHTMLToToggleState('showExpectations', 'results')
@@ -1843,7 +1852,7 @@ function htmlForIndividulTestOnAllBuilders(test)
     if (isLayoutTestResults() || isGPUTestResults()) {
         if (isLayoutTestResults())
             html += ' | ' + linkHTMLToToggleState('showLargeExpectations', 'large thumbnails');
-        if (master == WEBKIT_BUILDER_MASTER) {
+        if (testResults && builderMaster(testResults[0].builder) == WEBKIT_BUILDER_MASTER) {
             var revision = g_currentState.revision || '';
             html += '<form onsubmit="setQueryParameter(\'revision\', revision.value);' +
                 'return false;">Show results for WebKit revision: ' +
@@ -2362,11 +2371,13 @@ function hideLoadingUI()
 function generatePageForIndividualTests(tests)
 {
     console.log('Number of tests: ' + tests.length);
-    appendHTML(htmlForNavBar());
+    if (g_currentState.showChrome)
+        appendHTML(htmlForNavBar());
     performChunkedAction(tests, function(chunk) {
         appendHTML(htmlForIndividualTests(chunk));
     }, appendExpectations, 500);
-    $('tests-input').value = g_currentState.tests;
+    if (g_currentState.showChrome)
+        $('tests-input').value = g_currentState.tests;
 }
 
 function performChunkedAction(tests, handleChunk, onComplete, timeout, opt_index) {
@@ -2385,8 +2396,9 @@ function performChunkedAction(tests, handleChunk, onComplete, timeout, opt_index
 function htmlForIndividualTests(tests)
 {
     var testsHTML = [];
+    var htmlForTestFunction = g_currentState.showChrome ? htmlForIndividualTestOnAllBuildersWithChrome : htmlForIndividualTestOnAllBuilders;
     for (var i = 0; i < tests.length; i++)
-        testsHTML.push(htmlForIndividulTestOnAllBuilders(tests[i]));
+        testsHTML.push(htmlForTestFunction(tests[i]));
     return testsHTML.join('<hr>');
 }
 
@@ -2472,6 +2484,7 @@ function generatePageForBuilder(builderName)
 var VALID_KEYS_FOR_CROSS_BUILDER_VIEW = {
     tests: 1,
     result: 1,
+    showChrome: 1,
     showExpectations: 1,
     showLargeExpectations: 1,
     legacyExpectationsSemantics: 1,
@@ -2575,6 +2588,22 @@ function htmlForSlowTimes(minTime)
         minTime + ' seconds == SLOW</li></ul>';
 }
 
+window.addEventListener('message', function(event) {
+    try {
+        var parsedData = JSON.parse(event.data);
+    } catch (error) {
+        console.log('Could not parse postMessage as JSON: ' + event.data);
+        return;
+    }
+
+    if (parsedData.command == 'queryContentHeight') {
+        var response = {height: document.documentElement.offsetHeight};
+        event.source.postMessage(JSON.stringify(response), '*');
+        return;
+    }
+    console.log('Unknown postMessage query: ' + event.data);
+});
+
 document.addEventListener('keydown', function(e) {
     if (e.keyIdentifier == 'U+003F' || e.keyIdentifier == 'U+00BF') {
         // WebKit MAC retursn 3F. WebKit WIN returns BF. This is a bug!
index 8494701..3026525 100644 (file)
@@ -380,6 +380,95 @@ function testHtmlForTestTypeSwitcherGroup()
     assertEquals(group.children.length, 3);
 }
 
+function testHtmlForIndividualTestOnAllBuilders()
+{
+    assertEquals(htmlForIndividualTestOnAllBuilders('foo/nonexistant.html'), '<div class="not-found">Test not found. Either it does not exist, is skipped or passes on all platforms.</div>');
+}
+
+function testHtmlForIndividualTestOnAllBuildersWithChromeNonexistant()
+{
+    assertEquals(htmlForIndividualTestOnAllBuildersWithChrome('foo/nonexistant.html'),
+        '<h2><a href="http://trac.webkit.org/browser/trunk/LayoutTests/foo/nonexistant.html" target="_blank">foo/nonexistant.html</a></h2>' +
+        '<div class="not-found">Test not found. Either it does not exist, is skipped or passes on all platforms.</div>' +
+        '<div class=expectations test=foo/nonexistant.html>' +
+            '<div>' +
+                '<span class=link onclick="setQueryParameter(\'showExpectations\', true)">Show results</span> | ' +
+                '<span class=link onclick="setQueryParameter(\'showLargeExpectations\', true)">Show large thumbnails</span> | ' +
+                '<b>Only shows actual results/diffs from the most recent *failure* on each bot.</b>' +
+            '</div>' +
+        '</div>');
+}
+
+function testHtmlForIndividualTestOnAllBuildersWithChrome()
+{
+    var test = 'dummytest.html';
+    var builderName = 'dummyBuilder';
+    g_testToResultsMap[test] = [createResultsObjectForTest(test, builderName)];
+    assertEquals(htmlForIndividualTestOnAllBuildersWithChrome(test),
+        '<h2><a href="http://trac.webkit.org/browser/trunk/LayoutTests/dummytest.html" target="_blank">dummytest.html</a></h2>' +
+        '<table class=test-table><thead><tr>' +
+                '<th sortValue=test><div class=table-header-content><span></span><span class=header-text>test</span></div></th>' +
+                '<th sortValue=bugs><div class=table-header-content><span></span><span class=header-text>bugs</span></div></th>' +
+                '<th sortValue=modifiers><div class=table-header-content><span></span><span class=header-text>modifiers</span></div></th>' +
+                '<th sortValue=expectations><div class=table-header-content><span></span><span class=header-text>expectations</span></div></th>' +
+                '<th sortValue=slowest><div class=table-header-content><span></span><span class=header-text>slowest run</span></div></th>' +
+                '<th sortValue=%><div class=table-header-content><span></span><span class=header-text>% fail</span></div></th>' +
+                '<th sortValue=flakiness colspan=10000><div class=table-header-content><span></span><span class=header-text>flakiness (numbers are runtimes in seconds)</span></div></th>' +
+            '</tr></thead>' +
+            '<tbody>' +
+                '<div><b>If a builder is not listed, that means the builder does not run that test (e.g. it is skipped) or all runs of the test passed.</b></div>' +
+            '</tbody>' +
+        '</table>' +
+        '<div class=expectations test=dummytest.html>' +
+            '<div><span class=link onclick="setQueryParameter(\'showExpectations\', true)">Show results</span> | ' +
+            '<span class=link onclick="setQueryParameter(\'showLargeExpectations\', true)">Show large thumbnails</span> | ' +
+            '<b>Only shows actual results/diffs from the most recent *failure* on each bot.</b></div>' +
+        '</div>');
+}
+
+function testHtmlForIndividualTestOnAllBuildersWithChromeWebkitMaster()
+{
+    var test = 'dummytest.html';
+    var builderName = 'dummyBuilder';
+    BUILDER_TO_MASTER[builderName] = WEBKIT_BUILDER_MASTER;
+    g_testToResultsMap[test] = [createResultsObjectForTest(test, builderName)];
+    assertEquals(htmlForIndividualTestOnAllBuildersWithChrome(test),
+        '<h2><a href="http://trac.webkit.org/browser/trunk/LayoutTests/dummytest.html" target="_blank">dummytest.html</a></h2>' +
+            '<table class=test-table><thead><tr>' +
+                    '<th sortValue=test><div class=table-header-content><span></span><span class=header-text>test</span></div></th>' +
+                    '<th sortValue=bugs><div class=table-header-content><span></span><span class=header-text>bugs</span></div></th>' +
+                    '<th sortValue=modifiers><div class=table-header-content><span></span><span class=header-text>modifiers</span></div></th>' +
+                    '<th sortValue=expectations><div class=table-header-content><span></span><span class=header-text>expectations</span></div></th>' +
+                    '<th sortValue=slowest><div class=table-header-content><span></span><span class=header-text>slowest run</span></div></th>' +
+                    '<th sortValue=%><div class=table-header-content><span></span><span class=header-text>% fail</span></div></th>' +
+                    '<th sortValue=flakiness colspan=10000><div class=table-header-content><span></span><span class=header-text>flakiness (numbers are runtimes in seconds)</span></div></th>' +
+                '</tr></thead>' +
+                '<tbody>' +
+                    '<div><b>If a builder is not listed, that means the builder does not run that test (e.g. it is skipped) or all runs of the test passed.</b></div>' +
+                '</tbody>' +
+            '</table>' +
+            '<div class=expectations test=dummytest.html>' +
+                '<div><span class=link onclick="setQueryParameter(\'showExpectations\', true)">Show results</span> | ' +
+                '<span class=link onclick="setQueryParameter(\'showLargeExpectations\', true)">Show large thumbnails</span>' +
+                '<form onsubmit="setQueryParameter(\'revision\', revision.value);return false;">' +
+                    'Show results for WebKit revision: <input name=revision placeholder="e.g. 65540" value="" id=revision-input>' +
+                '</form></div>' +
+            '</div>');
+}
+
+function testHtmlForIndividualTests()
+{
+    g_currentState.showChrome = false;
+    var test1 = 'foo/nonexistant.html';
+    var test2 = 'bar/nonexistant.html';
+    var tests = [test1, test2];
+    assertEquals(htmlForIndividualTests(tests), htmlForIndividualTestOnAllBuilders(test1) + '<hr>' + htmlForIndividualTestOnAllBuilders(test2));
+
+    g_currentState.showChrome = true;
+    assertEquals(htmlForIndividualTests(tests), htmlForIndividualTestOnAllBuildersWithChrome(test1) + '<hr>' + htmlForIndividualTestOnAllBuildersWithChrome(test2));
+}
+
+
 function testLookupVirtualTestSuite()
 {
     assertEquals(lookupVirtualTestSuite('fast/canvas/foo.html'), '');
@@ -553,10 +642,16 @@ function testAddBuilderLoadErrors()
     g_buildersThatFailedToLoad = ['builder1', 'builder2'];
     g_staleBuilders = ['staleBuilder1'];
     addBuilderLoadErrors();
-    console.log(g_errorMessages);
     assertEquals(g_errorMessages, 'ERROR: Failed to get data from builder1,builder2.<br>ERROR: Data from staleBuilder1 is more than 1 day stale.<br>');
 }
 
+function htmlEscape(string)
+{
+    var div = document.createElement('div');
+    div.textContent = string;
+    return div.innerHTML;
+}
+
 function runTests()
 {
     document.body.innerHTML = '<pre id=unittest-results></pre>';
@@ -573,7 +668,8 @@ function runTests()
                 error = err;
             }
 
-            var result = error ? error.toString() : 'PASSED';
+            var result = error ? htmlEscape(error.toString()) : 'PASSED';
+
             $('unittest-results').insertAdjacentHTML("beforeEnd", name + ': ' + result + '\n');
         }
     }