Changeset 112423 in webkit


Ignore:
Timestamp:
Mar 28, 2012 12:19:36 PM (12 years ago)
Author:
ojan@chromium.org
Message:

Add history navigation to garden-o-matic
https://bugs.webkit.org/show_bug.cgi?id=82495

Reviewed by Dimitri Glazkov.

Also, maintain scroll offsets when returning to a tab. This makes addressing
expected failures considerably easier when dealing with below-the-fold tests.

  • BuildSlaveSupport/build.webkit.org-config/public_html/TestFailures/scripts/ui.js:

-Store the scrollTop before switching to a new tab and restore the appropriate scrollTop after
switching.
-Modify window.location with the tabName in the hash. Can't use pushState because this is served
from a file URL and Chrome puts each different file URL in it's own origin.

  • BuildSlaveSupport/build.webkit.org-config/public_html/TestFailures/scripts/ui/results.js:

Remove the href so that clicking on the accordion item does not modify window.location.hash.

  • BuildSlaveSupport/build.webkit.org-config/public_html/TestFailures/scripts/ui_unittests.js:
  • BuildSlaveSupport/build.webkit.org-config/public_html/TestFailures/styles/results.css:
Location:
trunk/Tools
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/Tools/BuildSlaveSupport/build.webkit.org-config/public_html/TestFailures/scripts/ui.js

    r111796 r112423  
    7676            'results',
    7777        ]
     78        this._tabIndexToSavedScrollOffset = {};
    7879        this._tabs = $(this).tabs({
    7980            disabled: [2],
     81            show: function(event, ui) { this._restoreScrollOffset(ui.index); },
    8082        });
    8183    },
     84    _saveScrollOffset: function() {
     85        var tabIndex = this._tabs.tabs('option', 'selected');
     86        this._tabIndexToSavedScrollOffset[tabIndex] = document.body.scrollTop;
     87    },
     88    _restoreScrollOffset: function(tabIndex)
     89    {
     90        document.body.scrollTop = this._tabIndexToSavedScrollOffset[tabIndex] || 0;
     91    },
     92    _setupHistoryHandlers: function()
     93    {
     94        function currentHash() {
     95            var hash = window.location.hash;
     96            return (!hash || hash == '#') ? '#unexpected' : hash;
     97        }
     98
     99        var self = this;
     100        $('.ui-tabs-nav a').bind('mouseup', function(event) {
     101            var href = event.target.getAttribute('href');
     102            var hash = currentHash();
     103            if (href != hash) {
     104                self._saveScrollOffset();
     105                window.location = href
     106            }
     107        });
     108
     109        window.onhashchange = function(event) {
     110            var tabName = currentHash().substring(1);
     111            self._selectInternal(tabName);
     112        };
     113
     114        // When navigating from the browser chrome, we'll
     115        // scroll to the #tabname contents. popstate fires before
     116        // we scroll, so we can save the scroll offset first.
     117        window.onpopstate = function() {
     118            self._saveScrollOffset();
     119        };
     120    },
    82121    attach: function()
    83122    {
    84123        document.body.insertBefore(this, document.body.firstChild);
     124        this._setupHistoryHandlers();
    85125    },
    86126    tabNamed: function(tabName)
     
    109149        return this.tabNamed('results');
    110150    },
    111     select: function(tabName)
    112     {
     151    _selectInternal: function(tabName) {
    113152        var tabIndex = this._tabNames.indexOf(tabName);
    114153        this._tabs.tabs('enable', tabIndex);
    115154        this._tabs.tabs('select', tabIndex);
     155    },
     156    select: function(tabName)
     157    {
     158        this._saveScrollOffset();
     159        this._selectInternal(tabName);
     160        window.location = '#' + tabName;
    116161    }
    117162});
  • trunk/Tools/BuildSlaveSupport/build.webkit.org-config/public_html/TestFailures/scripts/ui/results.js

    r112149 r112423  
    191191            var nonLinkTitle = document.createElement('a');
    192192            $(nonLinkTitle).addClass('non-link-title');
    193             $(nonLinkTitle).attr('href', "#").text(testName);
     193            $(nonLinkTitle).text(testName);
    194194
    195195            var linkTitle = document.createElement('a');
  • trunk/Tools/BuildSlaveSupport/build.webkit.org-config/public_html/TestFailures/scripts/ui_unittests.js

    r111793 r112423  
    4747}
    4848
     49test("ui.onebar", 3, function() {
     50    if (window.location.hash) {
     51        window.location.hash = '';
     52    }
     53
     54    onebar = new ui.onebar();
     55    onebar.attach();
     56    equal(onebar.innerHTML,
     57        '<ul class="ui-tabs-nav ui-helper-reset ui-helper-clearfix ui-widget-header ui-corner-all">' +
     58            '<li class="ui-state-default ui-corner-top ui-tabs-selected ui-state-active"><a href="#unexpected">Unexpected Failures</a></li>' +
     59            '<li class="ui-state-default ui-corner-top"><a href="#expected">Expected Failures</a></li>' +
     60            '<li class="ui-state-default ui-corner-top ui-state-disabled"><a href="#results">Results</a></li>' +
     61        '</ul>' +
     62        '<div id="unexpected" class="ui-tabs-panel ui-widget-content ui-corner-bottom"></div>' +
     63        '<div id="expected" class="ui-tabs-panel ui-widget-content ui-corner-bottom ui-tabs-hide"></div>' +
     64        '<div id="results" class="ui-tabs-panel ui-widget-content ui-corner-bottom ui-tabs-hide"></div>');
     65
     66    onebar.select('expected');
     67    equal(window.location.hash, '#expected');
     68    onebar.select('unexpected');
     69    equal(window.location.hash, '#unexpected');
     70
     71    $(onebar).detach();
     72});
     73
    4974test("results.ResultsGrid", 1, function() {
    5075    var grid = new ui.results.ResultsGrid()
  • trunk/Tools/BuildSlaveSupport/build.webkit.org-config/public_html/TestFailures/styles/results.css

    r112149 r112423  
    9191    display: inline-block;
    9292}
    93 .ui-state-active .non-link-title, .ui-state-active .non-link-title:link, .ui-state-active .non-link-title:visited {
     93/* Stupid CSS specificity rules. We need the .ui-accordion-header to override the builtin jquery styling on anchor tags in accordion headers. */
     94.ui-state-active.ui-accordion-header .non-link-title, .ui-state-active .non-link-title:link, .ui-state-active .non-link-title:visited {
    9495    display: none;
    9596}
  • trunk/Tools/ChangeLog

    r112408 r112423  
     12012-03-28  Ojan Vafai  <ojan@chromium.org>
     2
     3        Add history navigation to garden-o-matic
     4        https://bugs.webkit.org/show_bug.cgi?id=82495
     5
     6        Reviewed by Dimitri Glazkov.
     7
     8        Also, maintain scroll offsets when returning to a tab. This makes addressing
     9        expected failures considerably easier when dealing with below-the-fold tests.
     10
     11        * BuildSlaveSupport/build.webkit.org-config/public_html/TestFailures/scripts/ui.js:
     12        -Store the scrollTop before switching to a new tab and restore the appropriate scrollTop after
     13        switching.
     14        -Modify window.location with the tabName in the hash. Can't use pushState because this is served
     15        from a file URL and Chrome puts each different file URL in it's own origin.
     16
     17        * BuildSlaveSupport/build.webkit.org-config/public_html/TestFailures/scripts/ui/results.js:
     18        Remove the href so that clicking on the accordion item does not modify window.location.hash.
     19
     20        * BuildSlaveSupport/build.webkit.org-config/public_html/TestFailures/scripts/ui_unittests.js:
     21        * BuildSlaveSupport/build.webkit.org-config/public_html/TestFailures/styles/results.css:
     22
    1232012-03-28  Philippe Normand  <pnormand@igalia.com>
    224
Note: See TracChangeset for help on using the changeset viewer.