diff options
author | dubroy@chromium.org <dubroy@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-11-12 16:24:24 +0000 |
---|---|---|
committer | dubroy@chromium.org <dubroy@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-11-12 16:24:24 +0000 |
commit | 1e282861b2061d3c4c14de3d85bff45a136ea962 (patch) | |
tree | a39d9665fbee87ac8b855084b2ea4afcb76472d8 | |
parent | 14b67a51d1c7760e73e7fd4c2503f752d13e1e98 (diff) | |
download | chromium_src-1e282861b2061d3c4c14de3d85bff45a136ea962.zip chromium_src-1e282861b2061d3c4c14de3d85bff45a136ea962.tar.gz chromium_src-1e282861b2061d3c4c14de3d85bff45a136ea962.tar.bz2 |
History: Remove some more dead code and add extra checks to test.
- Remove long-dead updateAnchorWidth function
- Remove some if statements that never fail
- Add a check for the correct day headers to the browser test.
BUG=None
Review URL: https://chromiumcodereview.appspot.com/11234027
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@167187 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r-- | chrome/browser/resources/history/history.js | 59 | ||||
-rw-r--r-- | chrome/test/data/webui/history_browsertest.js | 10 |
2 files changed, 16 insertions, 53 deletions
diff --git a/chrome/browser/resources/history/history.js b/chrome/browser/resources/history/history.js index 059ca84..33fbfaf 100644 --- a/chrome/browser/resources/history/history.js +++ b/chrome/browser/resources/history/history.js @@ -526,9 +526,6 @@ function HistoryView(model) { this.currentVisits_ = []; var self = this; - window.onresize = function() { - self.updateEntryAnchorWidth_(); - }; $('clear-browsing-data').addEventListener('click', openClearBrowsingData); $('remove-selected').addEventListener('click', removeItems); @@ -670,10 +667,10 @@ HistoryView.prototype.displayResults_ = function() { if (visit.isRendered) continue; - // Break across day boundaries and insert gaps for browsing pauses. - // Create a dayResults element to contain results for each day var thisTime = visit.time.getTime(); + // Break across day boundaries and insert gaps for browsing pauses. + // Create a dayResults element to contain results for each day. if ((i == 0 && visit.continued) || !visit.continued) { // It's the first visit of the day, or the day is continued from // the previous page. Create a header for the day on the current page. @@ -684,31 +681,21 @@ HistoryView.prototype.displayResults_ = function() { loadTimeData.getString('cont'))); } - // If there is an existing dayResults element, append it. - if (dayResults) - resultsFragment.appendChild(dayResults); resultsFragment.appendChild(day); dayResults = createElementWithClassName('ol', 'day-results'); - } else if (lastTime - thisTime > BROWSING_GAP_TIME) { - if (dayResults) - dayResults.appendChild(createElementWithClassName('li', 'gap')); + resultsFragment.appendChild(dayResults); + } else if (dayResults && lastTime - thisTime > BROWSING_GAP_TIME) { + dayResults.appendChild(createElementWithClassName('li', 'gap')); } lastTime = thisTime; // Add the entry to the appropriate day. - if (dayResults) { - dayResults.appendChild(visit.getResultDOM(false)); - this.setVisitRendered_(visit); - } + dayResults.appendChild(visit.getResultDOM(false)); + this.setVisitRendered_(visit); } - // Add the final dayResults element to the page. - if (dayResults) - resultsFragment.appendChild(dayResults); - this.resultDiv_.appendChild(resultsFragment); } this.updateNavBar_(); - this.updateEntryAnchorWidth_(); }; /** @@ -721,38 +708,6 @@ HistoryView.prototype.updateNavBar_ = function() { $('older-button').hidden = !this.model_.hasMoreResults(); }; -/** - * Updates the CSS rule for the entry anchor. - * @private - */ -HistoryView.prototype.updateEntryAnchorWidth_ = function() { - // We need to have at least on .title div to be able to calculate the - // desired width of the anchor. - var titleElement = document.querySelector('.entry .title'); - if (!titleElement) - return; - - // Create new CSS rules and add them last to the last stylesheet. - // TODO(jochen): The following code does not work due to WebKit bug #32309 - // if (!this.entryAnchorRule_) { - // var styleSheets = document.styleSheets; - // var styleSheet = styleSheets[styleSheets.length - 1]; - // var rules = styleSheet.cssRules; - // var createRule = function(selector) { - // styleSheet.insertRule(selector + '{}', rules.length); - // return rules[rules.length - 1]; - // }; - // this.entryAnchorRule_ = createRule('.entry .title > a'); - // // The following rule needs to be more specific to have higher priority. - // this.entryAnchorStarredRule_ = createRule('.entry .title.starred > a'); - // } - // - // var anchorMaxWith = titleElement.offsetWidth; - // this.entryAnchorRule_.style.maxWidth = anchorMaxWith + 'px'; - // // Adjust by the width of star plus its margin. - // this.entryAnchorStarredRule_.style.maxWidth = anchorMaxWith - 23 + 'px'; -}; - /////////////////////////////////////////////////////////////////////////////// // State object: /** diff --git a/chrome/test/data/webui/history_browsertest.js b/chrome/test/data/webui/history_browsertest.js index 1ee7529..7d6bf74 100644 --- a/chrome/test/data/webui/history_browsertest.js +++ b/chrome/test/data/webui/history_browsertest.js @@ -83,7 +83,7 @@ TEST_F('HistoryWebUITest', 'basicTest', function() { // Check that there are two days of entries. var dayHeaders = document.querySelectorAll('.day'); - expectEquals(2, dayHeaders.length); + assertEquals(2, dayHeaders.length); expectNotEquals(dayHeaders[0].textContent, dayHeaders[1].textContent); // Check that the entries in each day are time-ordered, and that no @@ -134,6 +134,14 @@ TEST_F('HistoryWebUITest', 'basicTest', function() { // Check that the two pages include all of the entries. expectEquals(TOTAL_RESULT_COUNT, resultCount); + // Check that the day header was properly continued -- the header for the + // last day on the first page should be a substring of the header on the + // second page. E.g. "Wed, Oct 8, 2008" and "Web, Oct 8, 2008 - cont'd". + var newDayHeaders = document.querySelectorAll('.day'); + expectEquals(1, newDayHeaders.length); + expectEquals(0, + newDayHeaders[0].textContent.indexOf(dayHeaders[1].textContent)); + // Check that the "Newest" and "Newer" links are now visible, but the "Older" // link is hidden. expectEquals(3, document.querySelectorAll('.link-button').length) |