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

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

Issue 2255033002: [MD History] Copy stats from the old history page. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@sidebar_stats
Patch Set: add_stats Created 4 years, 4 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 3d8ea2e36ce67ee07eda6b5b8ad8e4ef7d5f096e..7e4f6777154442503aa3fecade97f888d1249790 100644
--- a/chrome/test/data/webui/md_history/test_util.js
+++ b/chrome/test/data/webui/md_history/test_util.js
@@ -37,6 +37,8 @@ function replaceBody(element) {
function replaceApp() {
var app = document.createElement('history-app');
app.id = 'history-app';
+ // Disable querying for tests by default.
+ app.queryState_.queryingDisabled = true;
replaceBody(app);
return app;
}
@@ -155,3 +157,51 @@ function shiftClick(element) {
element.dispatchEvent(new MouseEvent('mouseup', props));
element.dispatchEvent(new MouseEvent('click', props));
}
+
+function disableLinkClicks() {
+ document.addEventListener('click', function(e) {
+ if (e.defaultPrevented)
+ return;
+
+ var eventPath = e.path;
+ var anchor = null;
+ if (eventPath) {
+ for (var i = 0; i < eventPath.length; i++) {
+ var element = eventPath[i];
+ if (element.tagName === 'A' && element.href) {
+ anchor = element;
+ break;
+ }
+ }
+ }
+
+ if (!anchor)
+ return;
+
+ e.preventDefault();
+ });
+}
+
+function createSession(name, windows) {
+ return {
+ collapsed: false,
+ deviceType: '',
+ name: name,
+ modifiedTime: '2 seconds ago',
+ tag: name,
+ timestamp: 0,
+ windows: windows
+ };
+}
+
+function createWindow(tabUrls) {
+ var tabs = tabUrls.map(function(tabUrl) {
+ return {sessionId: 456, timestamp: 0, title: tabUrl, url: tabUrl};
+ });
+
+ return {
+ tabs: tabs,
+ sessionId: '123',
+ userVisibleTimestamp: "A while ago"
+ };
+}

Powered by Google App Engine
This is Rietveld 408576698