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

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: Revert histograms.xml Created 3 years, 7 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..199e32e49177a903e129d54f0d9e1c05d1a2e11e
--- /dev/null
+++ b/third_party/WebKit/LayoutTests/fast/dom/inert/inert-label-focus.html
@@ -0,0 +1,50 @@
+<!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) {
+ return new Promise(function(resolve, reject) {
+ if (!window.eventSender)
+ reject();
+
+ 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;
+ var pointerActions = [{
+ source: "mouse",
+ actions: [
+ { name: "pointerMove", x: x, y: y },
+ { name: "pointerDown", x: x, y: x },
+ { name: "pointerUp" },
+ { name: "pointerMove", x: 0, y: 0}
+ ]
+ }];
+ chrome.gpuBenchmarking.pointerActionSequence(pointerActions, resolve);
+ });
+}
+
+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).then(() => {
+ 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