Changeset 147457 in webkit


Ignore:
Timestamp:
Apr 2, 2013 10:59:14 AM (11 years ago)
Author:
jparent@chromium.org
Message:

Dashboard refactor: Move dashboard specific history related features to History.
https://bugs.webkit.org/show_bug.cgi?id=113717

Reviewed by Ojan Vafai.

Each dashboard now creates its own History object, with a custom
configuration. This changes from just overriding global functions
to passing in callbacks for generatePage, handleValidHashParameter,
and handleQueryParameterChange. Same with passing in defaultStateValues
and DB_SPECIFIC_INVALIDATING_PARAMS, rather than overriding the global
variables.

All functions related to these features are now (mostly) private
function on History.

Loader no longer needs a loadingComplete callback, since it can just
initialize the history object itself.

  • TestResultServer/static-dashboards/aggregate_results.js:

(handleValidHashParameter):

  • TestResultServer/static-dashboards/dashboard_base.js:
  • TestResultServer/static-dashboards/flakiness_dashboard.js:

(generatePage):
(.switch.return):
(handleQueryParameterChange):

  • TestResultServer/static-dashboards/flakiness_dashboard_unittests.js:

(resetGlobals):

  • TestResultServer/static-dashboards/history.js:

(.):

  • TestResultServer/static-dashboards/loader.js:

(.):

  • TestResultServer/static-dashboards/loader_unittests.js:
  • TestResultServer/static-dashboards/timeline_explorer.js:

(generatePage):
(initCurrentBuilderTestResults):

  • TestResultServer/static-dashboards/treemap.js:

(generatePage):
(.switch.return):
(handleQueryParameterChange):

Location:
trunk/Tools
Files:
10 edited

Legend:

Unmodified
Added
Removed
  • trunk/Tools/ChangeLog

    r147416 r147457  
     12013-04-02  Julie Parent  <jparent@chromium.org>
     2
     3        Dashboard refactor: Move dashboard specific history related features to History.
     4        https://bugs.webkit.org/show_bug.cgi?id=113717
     5
     6        Reviewed by Ojan Vafai.
     7       
     8        Each dashboard now creates its own History object, with a custom
     9        configuration. This changes from just overriding global functions
     10        to passing in callbacks for generatePage, handleValidHashParameter,
     11        and handleQueryParameterChange. Same with passing in defaultStateValues
     12        and DB_SPECIFIC_INVALIDATING_PARAMS, rather than overriding the global
     13        variables.
     14       
     15        All functions related to these features are now (mostly) private
     16        function on History.
     17       
     18        Loader no longer needs a loadingComplete callback, since it can just
     19        initialize the history object itself.
     20
     21        * TestResultServer/static-dashboards/aggregate_results.js:
     22        (handleValidHashParameter):
     23        * TestResultServer/static-dashboards/dashboard_base.js:
     24        * TestResultServer/static-dashboards/flakiness_dashboard.js:
     25        (generatePage):
     26        (.switch.return):
     27        (handleQueryParameterChange):
     28        * TestResultServer/static-dashboards/flakiness_dashboard_unittests.js:
     29        (resetGlobals):
     30        * TestResultServer/static-dashboards/history.js:
     31        (.):
     32        * TestResultServer/static-dashboards/loader.js:
     33        (.):
     34        * TestResultServer/static-dashboards/loader_unittests.js:
     35        * TestResultServer/static-dashboards/timeline_explorer.js:
     36        (generatePage):
     37        (initCurrentBuilderTestResults):
     38        * TestResultServer/static-dashboards/treemap.js:
     39        (generatePage):
     40        (.switch.return):
     41        (handleQueryParameterChange):
     42
    1432013-04-02  Sheriff Bot  <webkit.review.bot@gmail.com>
    244
  • trunk/Tools/TestResultServer/static-dashboards/aggregate_results.js

    r146797 r147457  
    3535//     -add the builder name to the list of builders in dashboard_base.js.
    3636
    37 //////////////////////////////////////////////////////////////////////////////
    38 // Methods and objects from dashboard_base.js to override.
    39 //////////////////////////////////////////////////////////////////////////////
    40 function generatePage()
     37function generatePage(historyInstance)
    4138{
    4239    var html = ui.html.testTypeSwitcher(true) + '<br>';
     
    4643}
    4744
    48 function handleValidHashParameter(key, value)
     45function handleValidHashParameter(historyInstance, key, value)
    4946{
    5047    switch(key) {
    5148    case 'rawValues':
    52         g_history.dashboardSpecificState[key] = value == 'true';
     49        historyInstance.dashboardSpecificState[key] = value == 'true';
    5350        return true;
    5451
     
    5855}
    5956
    60 g_defaultDashboardSpecificStateValues = {
     57var defaultDashboardSpecificStateValues = {
    6158    rawValues: false
    6259};
     60
     61
     62var aggregateResultsConfig = {
     63    defaultStateValues: defaultDashboardSpecificStateValues,
     64    generatePage: generatePage,
     65    handleValidHashParameter: handleValidHashParameter,
     66};
     67
     68// FIXME(jparent): Eventually remove all usage of global history object.
     69var g_history = new history.History(aggregateResultsConfig);
     70g_history.parseCrossDashboardParameters();
    6371
    6472function htmlForBuilder(builder)
     
    268276
    269277window.addEventListener('load', function() {
    270     var resourceLoader = new loader.Loader(intializeHistory);
     278    var resourceLoader = new loader.Loader();
    271279    resourceLoader.load();
    272280}, false);
  • trunk/Tools/TestResultServer/static-dashboards/dashboard_base.js

    r146797 r147457  
    3030// from the testing bots. This deals with generic utility functions, visible
    3131// history, popups and appending the script elements for the JSON files.
    32 //
    33 // The calling page is expected to implement the following "abstract"
    34 // functions/objects:
    35 
    36 // Generates the contents of the dashboard. The page should override this with
    37 // a function that generates the page assuming all resources have loaded.
    38 function generatePage() {}
    39 
    40 // Takes a key and a value and sets the g_history.dashboardSpecificState[key] = value iff key is
    41 // a valid hash parameter and the value is a valid value for that key.
    42 //
    43 // @return {boolean} Whether the key what inserted into the g_history.dashboardSpecificState.
    44 function handleValidHashParameter(key, value)
    45 {
    46     return false;
    47 }
    48 
    49 // Default hash parameters for the page. The page should override this to create
    50 // default states.
    51 var g_defaultDashboardSpecificStateValues = {};
    52 
    53 
    54 // The page should override this to modify page state due to
    55 // changing query parameters.
    56 // @param {Object} params New or modified query params as key: value.
    57 // @return {boolean} Whether changing this parameter should cause generatePage to be called.
    58 function handleQueryParameterChange(params)
    59 {
    60     return true;
    61 }
     32
    6233
    6334//////////////////////////////////////////////////////////////////////////////
     
    8556};
    8657
    87 // Map of parameter to other parameter it invalidates.
    88 var CROSS_DB_INVALIDATING_PARAMETERS = {
    89     'testType': 'group'
    90 };
    91 var DB_SPECIFIC_INVALIDATING_PARAMETERS;
    9258
    9359// Keys in the JSON files.
     
    168134}
    169135
    170 function parseDashboardSpecificParameters()
    171 {
    172     g_history.dashboardSpecificState = {};
    173     var parameters = history.queryHashAsMap();
    174     for (parameterName in g_defaultDashboardSpecificStateValues)
    175         g_history.parseParameter(parameters, parameterName);
    176 }
    177 
    178 function defaultValue(key)
    179 {
    180     if (key in g_defaultDashboardSpecificStateValues)
    181         return g_defaultDashboardSpecificStateValues[key];
    182     return history.DEFAULT_CROSS_DASHBOARD_STATE_VALUES[key];
    183 }
    184 
    185 // TODO(jparent): Each db should create their own history obj, not global.
    186 var g_history = new history.History();
    187 g_history.parseCrossDashboardParameters();
    188 
    189136function currentBuilderGroupCategory()
    190137{
     
    237184}
    238185
    239 function handleLocationChange()
    240 {
    241     if (g_history.parseParameters())
    242         generatePage();
    243 }
    244 
    245 // TODO(jparent): Move this to upcoming History object.
    246 function intializeHistory() {
    247     window.onhashchange = handleLocationChange;
    248     handleLocationChange();
    249 }
    250 
    251186// Create a new function with some of its arguements
    252187// pre-filled.
  • trunk/Tools/TestResultServer/static-dashboards/flakiness_dashboard.js

    r146926 r147457  
    137137var resourceLoader;
    138138
    139 //////////////////////////////////////////////////////////////////////////////
    140 // Methods and objects from dashboard_base.js to override.
    141 //////////////////////////////////////////////////////////////////////////////
    142 function generatePage()
    143 {
    144     if (g_history.crossDashboardState.useTestData)
     139function generatePage(historyInstance)
     140{
     141    if (historyInstance.crossDashboardState.useTestData)
    145142        return;
    146143
     
    150147    // tests expands to all tests that match the CSV list.
    151148    // result expands to all tests that ever have the given result
    152     if (g_history.dashboardSpecificState.tests || g_history.dashboardSpecificState.result)
     149    if (historyInstance.dashboardSpecificState.tests || historyInstance.dashboardSpecificState.result)
    153150        generatePageForIndividualTests(individualTests());
    154     else if (g_history.dashboardSpecificState.expectationsUpdate)
     151    else if (historyInstance.dashboardSpecificState.expectationsUpdate)
    155152        generatePageForExpectationsUpdate();
    156153    else
    157         generatePageForBuilder(g_history.dashboardSpecificState.builder || currentBuilderGroup().defaultBuilder());
     154        generatePageForBuilder(historyInstance.dashboardSpecificState.builder || currentBuilderGroup().defaultBuilder());
    158155
    159156    for (var builder in currentBuilders())
     
    163160}
    164161
    165 function handleValidHashParameter(key, value)
     162function handleValidHashParameter(historyInstance, key, value)
    166163{
    167164    switch(key) {
    168165    case 'tests':
    169         history.validateParameter(g_history.dashboardSpecificState, key, value,
     166        history.validateParameter(historyInstance.dashboardSpecificState, key, value,
    170167            function() {
    171168                return string.isValidName(value);
     
    175172    case 'result':
    176173        value = value.toUpperCase();
    177         history.validateParameter(g_history.dashboardSpecificState, key, value,
     174        history.validateParameter(historyInstance.dashboardSpecificState, key, value,
    178175            function() {
    179176                for (var result in LAYOUT_TEST_EXPECTATIONS_MAP_) {
     
    186183
    187184    case 'builder':
    188         history.validateParameter(g_history.dashboardSpecificState, key, value,
     185        history.validateParameter(historyInstance.dashboardSpecificState, key, value,
    189186            function() {
    190187                return value in currentBuilders();
     
    194191
    195192    case 'sortColumn':
    196         history.validateParameter(g_history.dashboardSpecificState, key, value,
     193        history.validateParameter(historyInstance.dashboardSpecificState, key, value,
    197194            function() {
    198195                // Get all possible headers since the actual used set of headers
    199                 // depends on the values in g_history.dashboardSpecificState, which are currently being set.
     196                // depends on the values in historyInstance.dashboardSpecificState, which are currently being set.
    200197                var headers = tableHeaders(true);
    201198                for (var i = 0; i < headers.length; i++) {
     
    208205
    209206    case 'sortOrder':
    210         history.validateParameter(g_history.dashboardSpecificState, key, value,
     207        history.validateParameter(historyInstance.dashboardSpecificState, key, value,
    211208            function() {
    212209                return value == FORWARD || value == BACKWARD;
     
    217214    case 'updateIndex':
    218215    case 'revision':
    219         history.validateParameter(g_history.dashboardSpecificState, key, Number(value),
     216        history.validateParameter(historyInstance.dashboardSpecificState, key, Number(value),
    220217            function() {
    221218                return value.match(/^\d+$/);
     
    235232    case 'showWontFixSkip':
    236233    case 'expectationsUpdate':
    237         g_history.dashboardSpecificState[key] = value == 'true';
     234        historyInstance.dashboardSpecificState[key] = value == 'true';
    238235        return true;
    239236
     
    243240}
    244241
    245 g_defaultDashboardSpecificStateValues = {
     242// @param {Object} params New or modified query parameters as key: value.
     243function handleQueryParameterChange(historyInstance, params)
     244{
     245    for (key in params) {
     246        if (key == 'tests') {
     247            // Entering cross-builder view, only keep valid keys for that view.
     248            for (var currentKey in historyInstance.dashboardSpecificState) {
     249              if (isInvalidKeyForCrossBuilderView(currentKey)) {
     250                delete historyInstance.dashboardSpecificState[currentKey];
     251              }
     252            }
     253        } else if (isInvalidKeyForCrossBuilderView(key)) {
     254            delete historyInstance.dashboardSpecificState.tests;
     255            delete historyInstance.dashboardSpecificState.result;
     256        }
     257    }
     258
     259    return true;
     260}
     261
     262var defaultDashboardSpecificStateValues = {
    246263    sortOrder: BACKWARD,
    247264    sortColumn: 'flakiness',
     
    266283};
    267284
    268 DB_SPECIFIC_INVALIDATING_PARAMETERS = {
     285var DB_SPECIFIC_INVALIDATING_PARAMETERS = {
    269286    'tests' : 'builder',
    270287    'testType': 'builder',
    271288    'group': 'builder'
    272289};
     290
     291
     292var flakinessConfig = {
     293    defaultStateValues: defaultDashboardSpecificStateValues,
     294    generatePage: generatePage,
     295    handleValidHashParameter: handleValidHashParameter,
     296    handleQueryParameterChange: handleQueryParameterChange,
     297    invalidatingHashParameters: DB_SPECIFIC_INVALIDATING_PARAMETERS
     298};
     299
     300// FIXME(jparent): Eventually remove all usage of global history object.
     301var g_history = new history.History(flakinessConfig);
     302g_history.parseCrossDashboardParameters();
    273303
    274304//////////////////////////////////////////////////////////////////////////////
     
    24932523}
    24942524
    2495 // Sets the page state to regenerate the page.
    2496 // @param {Object} params New or modified query parameters as key: value.
    2497 function handleQueryParameterChange(params)
    2498 {
    2499     for (key in params) {
    2500         if (key == 'tests') {
    2501             // Entering cross-builder view, only keep valid keys for that view.
    2502             for (var currentKey in g_history.dashboardSpecificState) {
    2503               if (isInvalidKeyForCrossBuilderView(currentKey)) {
    2504                 delete g_history.dashboardSpecificState[currentKey];
    2505               }
    2506             }
    2507         } else if (isInvalidKeyForCrossBuilderView(key)) {
    2508             delete g_history.dashboardSpecificState.tests;
    2509             delete g_history.dashboardSpecificState.result;
    2510         }
    2511     }
    2512 
    2513     return true;
    2514 }
    2515 
    25162525function hideLegend()
    25172526{
     
    26072616
    26082617window.addEventListener('load', function() {
    2609     resourceLoader = new loader.Loader(intializeHistory);
     2618    resourceLoader = new loader.Loader();
    26102619    resourceLoader.load();
    26112620}, false);
  • trunk/Tools/TestResultServer/static-dashboards/flakiness_dashboard_unittests.js

    r146926 r147457  
    3636    g_allExpectations = null;
    3737    g_allTestsTrie = null;
    38     var historyInstance = new history.History();
     38    var historyInstance = new history.History(flakinessConfig);
    3939    // FIXME(jparent): Remove this once global isn't used.
    4040    g_history = historyInstance;
     
    146146
    147147test('platformAndBuildType', 78, function() {
    148     var historyInstance = new history.History();
     148    var historyInstance = new history.History(flakinessConfig);
    149149    // FIXME(jparent): Change to use the flakiness_db's history object
    150150    // once it exists, rather than tracking global.
     
    313313
    314314test('substringList', 2, function() {
    315     var historyInstance = new history.History();
     315    var historyInstance = new history.History(flakinessConfig);
    316316    // FIXME(jparent): Remove this once global isn't used.
    317317    g_history = historyInstance;
     
    326326
    327327test('htmlForTestsWithExpectationsButNoFailures', 4, function() {
    328     var historyInstance = new history.History();
     328    var historyInstance = new history.History(defaultDashboardSpecificStateValues, generatePage, handleValidHashParameter);
    329329    // FIXME(jparent): Remove this once global isn't used.
    330330    g_history = historyInstance;
     
    362362
    363363test('htmlForTestTypeSwitcherGroup', 6, function() {
    364     var historyInstance = new history.History();
     364    var historyInstance = new history.History(flakinessConfig);
    365365    // FIXME(jparent): Remove this once global isn't used.
    366366    g_history = historyInstance;
     
    702702
    703703test('shouldHideTest', 10, function() {
    704     var historyInstance = new history.History();
     704    var historyInstance = new history.History(flakinessConfig);
    705705    historyInstance.parseParameters();
    706706    // FIXME(jparent): Change to use the flakiness_dashboard's history object
  • trunk/Tools/TestResultServer/static-dashboards/history.js

    r146797 r147457  
    107107}
    108108
    109 history.History = function()
    110 {
    111   this.crossDashboardState = {};
    112   this.dashboardSpecificState = {};
     109history.History = function(configuration)
     110{
     111    this.crossDashboardState = {};
     112    this.dashboardSpecificState = {};
     113
     114    if (configuration) {
     115        this._defaultDashboardSpecificStateValues = configuration.defaultStateValues;
     116        this._handleValidHashParameter = configuration.handleValidHashParameter;
     117        this._handleQueryParameterChange = configuration.handleQueryParameterChange || function(historyInstance, params) { return true; };
     118        this._dashboardSpecificInvalidatingParameters = configuration.invalidatingHashParameters;
     119        this._generatePage = configuration.generatePage;
     120    }
    113121}
    114122
    115123var RELOAD_REQUIRING_PARAMETERS = ['showAllRuns', 'group', 'testType'];
    116124
     125var CROSS_DB_INVALIDATING_PARAMETERS = {
     126    'testType': 'group'
     127};
     128
    117129history.History.prototype = {
     130    initialize: function()
     131    {
     132        window.onhashchange = this._handleLocationChange.bind(this);
     133        this._handleLocationChange();
     134    },
    118135    isLayoutTestResults: function()
    119136    {
     
    132149
    133150        history._fillMissingValues(this.crossDashboardState, history.DEFAULT_CROSS_DASHBOARD_STATE_VALUES);
     151    },
     152    _parseDashboardSpecificParameters: function()
     153    {
     154        this.dashboardSpecificState = {};
     155        var parameters = history.queryHashAsMap();
     156        for (parameterName in this._defaultDashboardSpecificStateValues)
     157            this.parseParameter(parameters, parameterName);
    134158    },
    135159    // TODO(jparent): Make private once callers move here.
     
    151175        }
    152176
    153         parseDashboardSpecificParameters();
     177        this._parseDashboardSpecificParameters();
    154178        var dashboardSpecificDiffState = history._diffStates(oldDashboardSpecificState, this.dashboardSpecificState);
    155179
    156         history._fillMissingValues(this.dashboardSpecificState, g_defaultDashboardSpecificStateValues);
     180        history._fillMissingValues(this.dashboardSpecificState, this._defaultDashboardSpecificStateValues);
    157181
    158182        // FIXME: dashboard_base shouldn't know anything about specific dashboard specific keys.
     
    164188        var shouldGeneratePage = true;
    165189        if (Object.keys(dashboardSpecificDiffState).length)
    166             shouldGeneratePage = handleQueryParameterChange(dashboardSpecificDiffState);
     190            shouldGeneratePage = this._handleQueryParameterChange(this, dashboardSpecificDiffState);
    167191        return shouldGeneratePage;
    168192    },
     
    206230
    207231        default:
    208             return handleValidHashParameter(key, value);
     232            return this._handleValidHashParameter(this, key, value);
    209233        }
    210234    },
     
    244268            if (key in CROSS_DB_INVALIDATING_PARAMETERS)
    245269                delete this.crossDashboardState[CROSS_DB_INVALIDATING_PARAMETERS[key]];
    246             if (DB_SPECIFIC_INVALIDATING_PARAMETERS && key in DB_SPECIFIC_INVALIDATING_PARAMETERS)
    247                 delete this.dashboardSpecificState[DB_SPECIFIC_INVALIDATING_PARAMETERS[key]];
     270            if (this._dashboardSpecificInvalidatingParameters && key in this._dashboardSpecificInvalidatingParameters)
     271                delete this.dashboardSpecificState[this._dashboardSpecificInvalidatingParameters[key]];
    248272        }
    249273    },
     
    253277        for (var key in stateObject) {
    254278            var value = stateObject[key];
    255             if (value != defaultValue(key))
     279            if (value != this._defaultValue(key))
    256280                state.push(key + '=' + encodeURIComponent(value));
    257281        }
     
    269293            combinedState[key] = this.crossDashboardState[key];
    270294        return combinedState;   
    271     }
     295    },
     296    _defaultValue: function(key)
     297    {
     298        if (key in this._defaultDashboardSpecificStateValues)
     299            return this._defaultDashboardSpecificStateValues[key];
     300        return history.DEFAULT_CROSS_DASHBOARD_STATE_VALUES[key];
     301    },
     302    _handleLocationChange: function()
     303    {
     304        if (this.parseParameters())
     305            this._generatePage(this);
     306    }
     307
    272308}
    273309
  • trunk/Tools/TestResultServer/static-dashboards/loader.js

    r146797 r147457  
    5858}
    5959
    60 loader.Loader = function(opt_onLoadingComplete)
     60loader.Loader = function()
    6161{
    6262    this._loadingSteps = [
     
    6969    this._staleBuilders = [];
    7070    this._errors = new ui.Errors();
    71     this._onLoadingComplete = opt_onLoadingComplete || function() {};
    7271    // TODO(jparent): Pass in the appropriate history obj per db.
    7372    this._history = g_history;
     
    108107        if (!loadingStep) {
    109108            this._addErrors();
    110             this._onLoadingComplete();
     109            this._history.initialize();
    111110            return;
    112111        }
  • trunk/Tools/TestResultServer/static-dashboards/loader_unittests.js

    r146797 r147457  
    3232    resetGlobals();
    3333    var loadedSteps = [];
    34     var loadingCompleteCallback = handleLocationChange;
    35     handleLocationChange = function() {
     34    g_history._handleLocationChange = function() {
    3635        deepEqual(loadedSteps, ['step 1', 'step 2']);
    3736    }
    38     var resourceLoader = new loader.Loader(handleLocationChange);
     37    var resourceLoader = new loader.Loader();
    3938    function loadingStep1() {
    4039        loadedSteps.push('step 1');
     
    4948        resourceLoader._loadingSteps = [loadingStep1, loadingStep2];
    5049        resourceLoader.load();
    51     } finally {
    52         handleLocationChange = loadingCompleteCallback;
    53     }
     50    }
    5451});
    5552
  • trunk/Tools/TestResultServer/static-dashboards/timeline_explorer.js

    r146797 r147457  
    3333var g_currentBuilderTestResults;
    3434
    35 //////////////////////////////////////////////////////////////////////////////
    36 // Methods and objects from dashboard_base.js to override.
    37 //////////////////////////////////////////////////////////////////////////////
    38 function generatePage()
     35var defaultDashboardSpecificStateValues = {
     36    builder: null,
     37    buildTimestamp: -1,
     38    ignoreFlakyTests: true
     39};
     40
     41var DB_SPECIFIC_INVALIDATING_PARAMETERS = {
     42    'testType': 'builder',
     43    'group': 'builder'
     44};
     45
     46function generatePage(historyInstance)
    3947{
    4048    g_buildIndicesByTimestamp = {};
    41     var results = g_resultsByBuilder[g_history.dashboardSpecificState.builder || currentBuilderGroup().defaultBuilder()];
     49    var results = g_resultsByBuilder[historyInstance.dashboardSpecificState.builder || currentBuilderGroup().defaultBuilder()];
    4250
    4351    for (var i = 0; i < results[FIXABLE_COUNTS_KEY].length; i++) {
     
    4654    }
    4755
    48     if (g_history.dashboardSpecificState.buildTimestamp != -1 && g_history.dashboardSpecificState.buildTimestamp in g_buildIndicesByTimestamp) {
    49         var newBuildIndex = g_buildIndicesByTimestamp[g_history.dashboardSpecificState.buildTimestamp];
     56    if (historyInstance.dashboardSpecificState.buildTimestamp != -1 && historyInstance.dashboardSpecificState.buildTimestamp in g_buildIndicesByTimestamp) {
     57        var newBuildIndex = g_buildIndicesByTimestamp[historyInstance.dashboardSpecificState.buildTimestamp];
    5058
    5159        if (newBuildIndex == g_currentBuildIndex) {
     
    6270
    6371    $('test-type-switcher').innerHTML = ui.html.testTypeSwitcher( false,
    64         ui.html.checkbox('ignoreFlakyTests', 'Ignore flaky tests', g_history.dashboardSpecificState.ignoreFlakyTests, 'g_currentBuildIndex = -1')
     72        ui.html.checkbox('ignoreFlakyTests', 'Ignore flaky tests', historyInstance.dashboardSpecificState.ignoreFlakyTests, 'g_currentBuildIndex = -1')
    6573    );
    6674
    6775    updateTimelineForBuilder();
    6876}
     77
     78function handleValidHashParameter(historyInstance, key, value)
     79{
     80    switch(key) {
     81    case 'builder':
     82        history.validateParameter(historyInstance.dashboardSpecificState, key, value,
     83            function() { return value in currentBuilders(); });
     84        return true;
     85    case 'buildTimestamp':
     86        historyInstance.dashboardSpecificState.buildTimestamp = parseInt(value, 10);
     87        return true;
     88    case 'ignoreFlakyTests':
     89        historyInstance.dashboardSpecificState.ignoreFlakyTests = value == 'true';
     90        return true;
     91    default:
     92        return false;
     93    }
     94}
     95
     96var timelineConfig = {
     97    defaultStateValues: defaultDashboardSpecificStateValues,
     98    generatePage: generatePage,
     99    handleValidHashParameter: handleValidHashParameter,
     100    invalidatingHashParameters: DB_SPECIFIC_INVALIDATING_PARAMETERS
     101};
     102
     103// FIXME(jparent): Eventually remove all usage of global history object.
     104var g_history = new history.History(timelineConfig);
     105g_history.parseCrossDashboardParameters();
    69106
    70107function initCurrentBuilderTestResults()
     
    74111    console.log( 'Time to get test results by build: ' + (Date.now() - startTime));
    75112}
    76 
    77 function handleValidHashParameter(key, value)
    78 {
    79     switch(key) {
    80     case 'builder':
    81         history.validateParameter(g_history.dashboardSpecificState, key, value,
    82             function() { return value in currentBuilders(); });
    83         return true;
    84     case 'buildTimestamp':
    85         g_history.dashboardSpecificState.buildTimestamp = parseInt(value, 10);
    86         return true;
    87     case 'ignoreFlakyTests':
    88         g_history.dashboardSpecificState.ignoreFlakyTests = value == 'true';
    89         return true;
    90     default:
    91         return false;
    92     }
    93 }
    94 
    95 g_defaultDashboardSpecificStateValues = {
    96     builder: null,
    97     buildTimestamp: -1,
    98     ignoreFlakyTests: true
    99 };
    100 
    101 DB_SPECIFIC_INVALIDATING_PARAMETERS = {
    102     'testType': 'builder',
    103     'group': 'builder'
    104 };
    105113
    106114function shouldShowWebKitRevisionsOnly()
     
    489497
    490498window.addEventListener('load', function() {
    491     var resourceLoader = new loader.Loader(intializeHistory);
     499    var resourceLoader = new loader.Loader();
    492500    resourceLoader.load();
    493501}, false);
  • trunk/Tools/TestResultServer/static-dashboards/treemap.js

    r146797 r147457  
    2727// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
    2828
     29var defaultDashboardSpecificStateValues = {
     30    builder: null,
     31    treemapfocus: '',
     32};
     33
     34var DB_SPECIFIC_INVALIDATING_PARAMETERS = {
     35    'testType': 'builder',
     36    'group': 'builder'
     37};
     38
     39function generatePage(historyInstance)
     40{
     41    $('header-container').innerHTML = ui.html.testTypeSwitcher();
     42
     43    g_isGeneratingPage = true;
     44
     45    var rawTree = g_resultsByBuilder[historyInstance.dashboardSpecificState.builder || currentBuilderGroup().defaultBuilder()];
     46    g_webTree = convertToWebTreemapFormat('LayoutTests', rawTree);
     47    appendTreemap($('map'), g_webTree);
     48
     49    if (historyInstance.dashboardSpecificState.treemapfocus)
     50        focusPath(g_webTree, historyInstance.dashboardSpecificState.treemapfocus)
     51
     52    g_isGeneratingPage = false;
     53}
     54
     55function handleValidHashParameter(historyInstance, key, value)
     56{
     57    switch(key) {
     58    case 'builder':
     59        history.validateParameter(historyInstance.dashboardSpecificState, key, value,
     60            function() { return value in currentBuilders(); });
     61        return true;
     62
     63    case 'treemapfocus':
     64        history.validateParameter(historyInstance.dashboardSpecificState, key, value,
     65            function() {
     66                // FIXME: There's probably a simpler regexp here. Just trying to match ascii + forward-slash.
     67                // e.g. LayoutTests/foo/bar.html
     68                return (value.match(/^(\w+\/\w*)*$/));
     69            });
     70        return true;
     71
     72    default:
     73        return false;
     74    }
     75}
     76
     77function handleQueryParameterChange(historyInstance, params)
     78{
     79    for (var param in params) {
     80        if (param != 'treemapfocus') {
     81            $('map').innerHTML = 'Loading...';
     82            return true;
     83        }
     84    }
     85    return false;
     86}
     87
     88var treemapConfig = {
     89    defaultStateValues: defaultDashboardSpecificStateValues,
     90    generatePage: generatePage,
     91    handleValidHashParameter: handleValidHashParameter,
     92    handleQueryParameterChange: handleQueryParameterChange,
     93    invalidatingHashParameters: DB_SPECIFIC_INVALIDATING_PARAMETERS
     94};
     95
     96// FIXME(jparent): Eventually remove all usage of global history object.
     97var g_history = new history.History(treemapConfig);
     98g_history.parseCrossDashboardParameters();
     99
    29100var TEST_URL_BASE_PATH = "http://svn.webkit.org/repository/webkit/trunk/";
    30101
     
    137208var g_webTree;
    138209
    139 function generatePage()
    140 {
    141     $('header-container').innerHTML = ui.html.testTypeSwitcher();
    142 
    143     g_isGeneratingPage = true;
    144 
    145     var rawTree = g_resultsByBuilder[g_history.dashboardSpecificState.builder || currentBuilderGroup().defaultBuilder()];
    146     g_webTree = convertToWebTreemapFormat('LayoutTests', rawTree);
    147     appendTreemap($('map'), g_webTree);
    148 
    149     if (g_history.dashboardSpecificState.treemapfocus)
    150         focusPath(g_webTree, g_history.dashboardSpecificState.treemapfocus)
    151 
    152     g_isGeneratingPage = false;
    153 }
    154 
    155210function focusPath(tree, path)
    156211{
     
    177232    }
    178233
    179 }
    180 
    181 function handleValidHashParameter(key, value)
    182 {
    183     switch(key) {
    184     case 'builder':
    185         history.validateParameter(g_history.dashboardSpecificState, key, value,
    186             function() { return value in currentBuilders(); });
    187         return true;
    188 
    189     case 'treemapfocus':
    190         history.validateParameter(g_history.dashboardSpecificState, key, value,
    191             function() {
    192                 // FIXME: There's probably a simpler regexp here. Just trying to match ascii + forward-slash.
    193                 // e.g. LayoutTests/foo/bar.html
    194                 return (value.match(/^(\w+\/\w*)*$/));
    195             });
    196         return true;
    197 
    198     default:
    199         return false;
    200     }
    201 }
    202 
    203 g_defaultDashboardSpecificStateValues = {
    204     builder: null,
    205     treemapfocus: '',
    206 };
    207 
    208 DB_SPECIFIC_INVALIDATING_PARAMETERS = {
    209     'testType': 'builder',
    210     'group': 'builder'
    211 };
    212 
    213 function handleQueryParameterChange(params)
    214 {
    215     for (var param in params) {
    216         if (param != 'treemapfocus') {
    217             $('map').innerHTML = 'Loading...';
    218             return true;
    219         }
    220     }
    221     return false;
    222234}
    223235
     
    271283
    272284window.addEventListener('load', function() {
    273     var resourceLoader = new loader.Loader(intializeHistory);
     285    var resourceLoader = new loader.Loader();
    274286    resourceLoader.load();
    275287}, false);
Note: See TracChangeset for help on using the changeset viewer.