Changeset 85654 in webkit


Ignore:
Timestamp:
May 3, 2011 1:51:46 PM (13 years ago)
Author:
ojan@chromium.org
Message:

2011-05-03 Ojan Vafai <ojan@chromium.org>

Reviewed by Tony Chang.

store results.html options in localstorage
https://bugs.webkit.org/show_bug.cgi?id=60048

This makes options persistent per-domain. It's not perfect,
but it should make it possible to have preferences for how
people would like the results.html page to render.

  • fast/harness/resources/results-test.js:
  • fast/harness/results.html:
Location:
trunk/LayoutTests
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r85648 r85654  
     12011-05-03  Ojan Vafai  <ojan@chromium.org>
     2
     3        Reviewed by Tony Chang.
     4
     5        store results.html options in localstorage
     6        https://bugs.webkit.org/show_bug.cgi?id=60048
     7
     8        This makes options persistent per-domain. It's not perfect,
     9        but it should make it possible to have preferences for how
     10        people would like the results.html page to render.
     11
     12        * fast/harness/resources/results-test.js:
     13        * fast/harness/results.html:
     14
    1152011-05-03  Igor Oliveira  <igor.oliveira@openbossa.org>
    216
  • trunk/LayoutTests/fast/harness/resources/results-test.js

    r85634 r85654  
    6363}
    6464
    65 function runTest(results, assertions)
     65function runTest(results, assertions, opt_localStorageValue)
    6666{
    6767    document.body.innerHTML = '';
    6868    g_testIndex++;
    6969    g_state = undefined;
     70    localStorage.setItem(OptionWriter._key, opt_localStorageValue || '');
    7071
    7172    try {
     
    390391        assertTrue(document.querySelector('tbody td:nth-child(3)').textContent == ' images   diff ');
    391392    });
     393   
     394    results = mockResults();
     395    results.tests['reading-options-from-localstorage.html'] = mockExpectation('IMAGE+TEXT', 'IMAGE+TEXT');
     396    runTest(results, function() {
     397        assertTrue(window.getComputedStyle(document.querySelector('tbody'), null)['display'] != 'none');
     398        assertTrue(document.querySelector('tbody td:nth-child(3)').textContent == 'expected actual  diff ');
     399    }, '{"toggle-images":false,"unexpected-results":false}');
    392400
    393401    document.body.innerHTML = '<pre>' + g_log.join('\n') + '</pre>';
  • trunk/LayoutTests/fast/harness/results.html

    r85638 r85654  
    757757function onlyShowUnexpectedFailures()
    758758{
    759     var checkBox = document.getElementById('unexpected-results');
    760     return !checkBox || checkBox.checked;
     759    return document.getElementById('unexpected-results').checked;
     760}
     761
     762function handleUnexpectedResultsChange()
     763{
     764    OptionWriter.save();
     765    updateExpectedFailures();
    761766}
    762767
     
    765770    document.getElementById('unexpected-style').innerText = onlyShowUnexpectedFailures() ?
    766771        '.expected { display: none; }' : '';
     772}
     773
     774var OptionWriter = {};
     775
     776OptionWriter._key = 'run-webkit-tests-options';
     777
     778OptionWriter.save = function()
     779{
     780    var options = document.querySelectorAll('label input');
     781    var data = {};
     782    for (var i = 0, len = options.length; i < len; i++) {
     783        var option = options[i];
     784        data[option.id] = option.checked;
     785    }
     786    localStorage.setItem(OptionWriter._key, JSON.stringify(data));
     787}
     788
     789OptionWriter.apply = function()
     790{
     791    var json = localStorage.getItem(OptionWriter._key);
     792    if (!json)
     793        return;
     794
     795    var data = JSON.parse(json);
     796    for (var id in data) {
     797        var input = document.getElementById(id);
     798        if (input) {
     799            input.checked = data[id];
     800            input.onchange();
     801        }
     802    }
     803}
     804
     805function handleToggleImagesChange()
     806{
     807    OptionWriter.save();
     808    updateTogglingImages();
    767809}
    768810
     
    787829}
    788830
    789 
    790831function getResultContainer(node)
    791832{
     
    833874        '<a href="javascript:void()" onclick="expandAllExpectations()">expand all</a> ' +
    834875        '<a href="javascript:void()" onclick="collapseAllExpectations()">collapse all</a> ' +
    835         '<a href="javascript:void()" id=options-link onclick="toggleOptionsMenu()">options</a><div id=options-menu class=hidden-menu>';
    836 
    837     // FIXME: store these as prefs in localstorage?
    838     if (globalState().results.uses_expectations_file)
    839         html += '<label><input id="unexpected-results" type=checkbox checked onchange="updateExpectedFailures()">Only show unexpected results</label>';
    840 
    841     html += '<label><input id="toggle-images" type=checkbox checked onchange="updateTogglingImages()">Toggle images</label>';
    842 
    843     html += '</div></div>';
     876        '<a href="javascript:void()" id=options-link onclick="toggleOptionsMenu()">options</a>' +
     877        '<div id=options-menu class=hidden-menu>' +
     878            '<label><input id="unexpected-results" type=checkbox checked onchange="handleUnexpectedResultsChange()">Only show unexpected results</label>' +
     879            '<label><input id="toggle-images" type=checkbox checked onchange="handleToggleImagesChange()">Toggle images</label>' +
     880        '</div></div>';
    844881
    845882    var tableRowsHtml = tableRows();
     
    875912    document.body.innerHTML = html;
    876913
     914    OptionWriter.apply();
     915
    877916    if (document.getElementById('results-table')) {
    878917        document.getElementById('results-table').addEventListener('click', TableSorter.handleClick, false);
    879918        TableSorter.sortColumn(0);
     919        if (!globalState().results.uses_expectations_file)
     920            parentOfType(document.getElementById('unexpected-results'), 'label').style.display = 'none';
    880921        if (!globalState().hasTextFailures)
    881922            document.getElementById('text-results-header').textContent = '';
     
    885926        }
    886927    }
    887    
    888     updateExpectedFailures();
    889928}
    890929</script>
Note: See TracChangeset for help on using the changeset viewer.