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

Unified Diff: third_party/WebKit/LayoutTests/shadow-dom/resources/focus-utils.js

Issue 2430313003: Give better assertion fail message on focus move test (Closed)
Patch Set: Created 4 years, 2 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/LayoutTests/shadow-dom/resources/focus-utils.js
diff --git a/third_party/WebKit/LayoutTests/shadow-dom/resources/focus-utils.js b/third_party/WebKit/LayoutTests/shadow-dom/resources/focus-utils.js
index c35ed6034592272a057b9dd2be559cbc8308709a..8992ed23b165332f8b4a2ab3816971854bc372c4 100644
--- a/third_party/WebKit/LayoutTests/shadow-dom/resources/focus-utils.js
+++ b/third_party/WebKit/LayoutTests/shadow-dom/resources/focus-utils.js
@@ -42,7 +42,7 @@ function shouldNavigateFocus(from, to, direction)
else
navigateFocusBackward();
- return isInnermostActiveElement(to);
+ return true;
}
function navigateFocusForward()
@@ -57,16 +57,28 @@ function navigateFocusBackward()
eventSender.keyDown('\t', ['shiftKey']);
}
+function assert_focus_navigation(from, to, direction)
+{
+ const result = shouldNavigateFocus(from, to, direction);
+ assert_true(result, 'Failed to focus ' + from);
+ const message = 'Focus should move ' + direction +
+ ' from ' + from + ' to ' + to;
+ var toElement = getNodeInComposedTree(to);
+ assert_equals(innermostActiveElement(), toElement, message);
+}
+
function assert_focus_navigation_forward(elements)
{
+ assert_true(elements.length >= 2,
+ 'length of elements should be greater than or equal to 2.');
for (var i = 0; i + 1 < elements.length; ++i)
- assert_true(shouldNavigateFocus(elements[i], elements[i + 1], 'forward'),
- 'Focus should move from ' + elements[i] + ' to ' + elements[i + 1]);
+ assert_focus_navigation(elements[i], elements[i + 1], 'forward');
}
function assert_focus_navigation_backward(elements)
{
+ assert_true(elements.length >= 2,
+ 'length of elements should be greater than or equal to 2.');
for (var i = 0; i + 1 < elements.length; ++i)
- assert_true(shouldNavigateFocus(elements[i], elements[i + 1], 'backward'),
- 'Focus should move from ' + elements[i] + ' to ' + elements[i + 1]);
+ assert_focus_navigation(elements[i], elements[i + 1], 'backward');
}
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698