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

Unified Diff: third_party/WebKit/LayoutTests/fast/dom/inert/inert-label-focus.html

Issue 2088453002: Implement the inert attribute (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Move flat tree checks up to the top of isInert Created 3 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: third_party/WebKit/LayoutTests/fast/dom/inert/inert-label-focus.html
diff --git a/third_party/WebKit/LayoutTests/fast/dom/inert/inert-label-focus.html b/third_party/WebKit/LayoutTests/fast/dom/inert/inert-label-focus.html
new file mode 100644
index 0000000000000000000000000000000000000000..5b01dd7ba7f85ca925929cbc60dafaa33756d59d
--- /dev/null
+++ b/third_party/WebKit/LayoutTests/fast/dom/inert/inert-label-focus.html
@@ -0,0 +1,41 @@
+<!DOCTYPE html>
+<html>
+<script src="../../../resources/testharness.js"></script>
+<script src="../../../resources/testharnessreport.js"></script>
+<label inert for="submit">Label for Submit</label>
+<input id="text" type="text">
+<input id="submit" type="submit">
+<script>
+function clickOn(element) {
+ if (!window.eventSender)
+ return;
+
+ var absoluteTop = 0;
+ var absoluteLeft = 0;
+ for (var parentNode = element; parentNode; parentNode = parentNode.offsetParent) {
+ absoluteLeft += parentNode.offsetLeft;
+ absoluteTop += parentNode.offsetTop;
+ }
+
+ var x = absoluteLeft + element.offsetWidth / 2;
+ var y = absoluteTop + element.offsetHeight / 2;
+ eventSender.mouseMoveTo(x, y);
+ eventSender.mouseDown();
+ eventSender.mouseUp();
+ eventSender.mouseMoveTo(0, 0);
+}
+
+document.querySelector('#text').focus();
+
+test(function() {
+ label = document.querySelector('label');
+ label.focus();
+ assert_equals(document.activeElement, document.querySelector('#submit'));
+}, 'Calling focus() on an inert label should still send focus to its target.');
+
+test(function() {
+ clickOn(label);
+ assert_equals(document.activeElement, document.body);
+}, 'Clicking on an inert label should send focus to document.body.');
+</script>
+</html>

Powered by Google App Engine
This is Rietveld 408576698