Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(3427)

Unified Diff: chrome/test/data/webui/md_history/test_util.js

Issue 1648803003: MD History: Drop-down menu allows searching for history-items by domain name. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@search_functionality
Patch Set: Address reviewer comments and small fixes. Created 4 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/test/data/webui/md_history/test_util.js
diff --git a/chrome/test/data/webui/md_history/test_util.js b/chrome/test/data/webui/md_history/test_util.js
index acb77f4d03142d9242589f033837ae2174594dd1..a7a93fa951fe7c105f48b835822840d3694859b8 100644
--- a/chrome/test/data/webui/md_history/test_util.js
+++ b/chrome/test/data/webui/md_history/test_util.js
@@ -10,3 +10,26 @@ function flush(callback) {
Polymer.dom.flush();
window.setTimeout(callback, 0);
}
+
+/**
+ * Create a fake history result with the given timestamp.
+ * @param {Number} timestamp Timestamp of the entry, in ms since the epoch.
+ * @param {String} url The URL to set on this entry.
+ * @return {Object} An object representing a history entry.
+ */
+function createHistoryEntry(timestamp, url) {
tsergeant 2016/02/12 00:48:56 \ (•◡•) / This is much nicer, thanks for refactor
+ var d = new Date(timestamp);
+ // Extract domain from url.
+ var domainMatch = url.replace(/^.+?:\/\//, '').match(/[^/]+/);
+ var domain = domainMatch ? domainMatch[0] : '';
+ return {
+ allTimestamps: [timestamp],
+ dateRelativeDay: d.toDateString(),
+ dateTimeOfDay: d.getHours() + ':' + d.getMinutes(),
+ domain: domain,
+ starred: false,
+ time: timestamp,
+ title: url,
+ url: url
+ };
+}

Powered by Google App Engine
This is Rietveld 408576698