dashboard_base.js 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158
  1. // Copyright (C) 2012 Google Inc. All rights reserved.
  2. //
  3. // Redistribution and use in source and binary forms, with or without
  4. // modification, are permitted provided that the following conditions are
  5. // met:
  6. //
  7. // * Redistributions of source code must retain the above copyright
  8. // notice, this list of conditions and the following disclaimer.
  9. // * Redistributions in binary form must reproduce the above
  10. // copyright notice, this list of conditions and the following disclaimer
  11. // in the documentation and/or other materials provided with the
  12. // distribution.
  13. // * Neither the name of Google Inc. nor the names of its
  14. // contributors may be used to endorse or promote products derived from
  15. // this software without specific prior written permission.
  16. //
  17. // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  18. // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  19. // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
  20. // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
  21. // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  22. // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  23. // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
  24. // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  25. // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  26. // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
  27. // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  28. // @fileoverview Base JS file for pages that want to parse the results JSON
  29. // from the testing bots. This deals with generic utility functions, visible
  30. // history, popups and appending the script elements for the JSON files.
  31. //////////////////////////////////////////////////////////////////////////////
  32. // CONSTANTS
  33. //////////////////////////////////////////////////////////////////////////////
  34. var GTEST_EXPECTATIONS_MAP_ = {
  35. 'P': 'PASS',
  36. 'F': 'FAIL',
  37. 'N': 'NO DATA',
  38. 'X': 'SKIPPED'
  39. };
  40. var LAYOUT_TEST_EXPECTATIONS_MAP_ = {
  41. 'P': 'PASS',
  42. 'N': 'NO DATA',
  43. 'X': 'SKIP',
  44. 'T': 'TIMEOUT',
  45. 'F': 'TEXT',
  46. 'C': 'CRASH',
  47. 'I': 'IMAGE',
  48. 'Z': 'IMAGE+TEXT',
  49. // We used to glob a bunch of expectations into "O" as OTHER. Expectations
  50. // are more precise now though and it just means MISSING.
  51. 'O': 'MISSING'
  52. };
  53. // Keys in the JSON files.
  54. var WONTFIX_COUNTS_KEY = 'wontfixCounts';
  55. var FIXABLE_COUNTS_KEY = 'fixableCounts';
  56. var DEFERRED_COUNTS_KEY = 'deferredCounts';
  57. var WONTFIX_DESCRIPTION = 'Tests never to be fixed (WONTFIX)';
  58. var FIXABLE_DESCRIPTION = 'All tests for this release';
  59. var DEFERRED_DESCRIPTION = 'All deferred tests (DEFER)';
  60. var FIXABLE_COUNT_KEY = 'fixableCount';
  61. var ALL_FIXABLE_COUNT_KEY = 'allFixableCount';
  62. var CHROME_REVISIONS_KEY = 'chromeRevision';
  63. var WEBKIT_REVISIONS_KEY = 'webkitRevision';
  64. var TIMESTAMPS_KEY = 'secondsSinceEpoch';
  65. var BUILD_NUMBERS_KEY = 'buildNumbers';
  66. var TESTS_KEY = 'tests';
  67. var ONE_DAY_SECONDS = 60 * 60 * 24;
  68. var ONE_WEEK_SECONDS = ONE_DAY_SECONDS * 7;
  69. // These should match the testtype uploaded to webkit-test-results.appspot.com.
  70. // See http://webkit-test-results.appspot.com/testfile.
  71. var TEST_TYPES = [
  72. 'layout-tests'
  73. ];
  74. // Enum for indexing into the run-length encoded results in the JSON files.
  75. // 0 is where the count is length is stored. 1 is the value.
  76. var RLE = {
  77. LENGTH: 0,
  78. VALUE: 1
  79. }
  80. function isFailingResult(value)
  81. {
  82. return 'FSTOCIZ'.indexOf(value) != -1;
  83. }
  84. // Generic utility functions.
  85. function $(id)
  86. {
  87. return document.getElementById(id);
  88. }
  89. function currentBuilderGroupCategory()
  90. {
  91. return LAYOUT_TESTS_BUILDER_GROUPS;
  92. }
  93. function currentBuilderGroupName()
  94. {
  95. return g_history.crossDashboardState.group || Object.keys(currentBuilderGroupCategory())[0];
  96. }
  97. function currentBuilderGroup()
  98. {
  99. return currentBuilderGroupCategory()[currentBuilderGroupName()];
  100. }
  101. function currentBuilders()
  102. {
  103. return currentBuilderGroup().builders;
  104. }
  105. function isTipOfTreeWebKitBuilder()
  106. {
  107. return true;
  108. }
  109. var g_resultsByBuilder = {};
  110. var g_expectationsByPlatform = {};
  111. function isFlakinessDashboard()
  112. {
  113. return string.endsWith(window.location.pathname, 'flakiness_dashboard.html');
  114. }
  115. // Create a new function with some of its arguements
  116. // pre-filled.
  117. // Taken from goog.partial in the Closure library.
  118. // @param {Function} fn A function to partially apply.
  119. // @param {...*} var_args Additional arguments that are partially
  120. // applied to fn.
  121. // @return {!Function} A partially-applied form of the function bind() was
  122. // invoked as a method of.
  123. function partial(fn, var_args)
  124. {
  125. var args = Array.prototype.slice.call(arguments, 1);
  126. return function() {
  127. // Prepend the bound arguments to the current arguments.
  128. var newArgs = Array.prototype.slice.call(arguments);
  129. newArgs.unshift.apply(newArgs, args);
  130. return fn.apply(this, newArgs);
  131. };
  132. };
  133. // Returns the appropriate expectations map for the current testType.
  134. function expectationsMap()
  135. {
  136. return g_history.isLayoutTestResults() ? LAYOUT_TEST_EXPECTATIONS_MAP_ : GTEST_EXPECTATIONS_MAP_;
  137. }