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" |
+ }; |
+} |