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

Side by Side 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: dmazzoni comments Created 3 years, 11 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 unified diff | Download patch
OLDNEW
(Empty)
1 <!DOCTYPE html>
2 <html>
3 <script src="../../../resources/testharness.js"></script>
4 <script src="../../../resources/testharnessreport.js"></script>
5 <label inert for="submit">Label for Submit</label>
6 <input id="text" type="text">
7 <input id="submit" type="submit">
8 <script>
9 function clickOn(element) {
10 if (!window.eventSender)
11 return;
12
13 var absoluteTop = 0;
14 var absoluteLeft = 0;
15 for (var parentNode = element; parentNode; parentNode = parentNode.offsetPar ent) {
16 absoluteLeft += parentNode.offsetLeft;
17 absoluteTop += parentNode.offsetTop;
18 }
19
20 var x = absoluteLeft + element.offsetWidth / 2;
21 var y = absoluteTop + element.offsetHeight / 2;
22 eventSender.mouseMoveTo(x, y);
23 eventSender.mouseDown();
24 eventSender.mouseUp();
25 eventSender.mouseMoveTo(0, 0);
26 }
27
28 document.querySelector('#text').focus();
29
30 test(function() {
31 label = document.querySelector('label');
32 label.focus();
33 assert_equals(document.activeElement, document.querySelector('#submit'));
34 }, 'Calling focus() on an inert label should still send focus to its target.');
35
36 test(function() {
37 clickOn(label);
38 assert_equals(document.activeElement, document.body);
39 }, 'Clicking on an inert label should send focus to document.body.');
40 </script>
41 </html>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698