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

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: Fix up some tests Created 4 years, 6 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
1 <!DOCTYPE html> 1 <!DOCTYPE html>
2 <html> 2 <html>
3 <script src="../../../resources/js-test.js"></script> 3 <script src="../../../resources/js-test.js"></script>
4 <label for="submit">Label for Submit</label> 4 <label inert for="submit">Label for Submit</label>
5 <dialog> 5 <input id="text" type="text">
6 <input id="text" type="text"> 6 <input id="submit" type="submit">
7 <input id="submit" type="submit">
8 </dialog>
9 <script> 7 <script>
10 function clickOn(element) { 8 function clickOn(element) {
11 if (!window.eventSender) 9 if (!window.eventSender)
12 return; 10 return;
13 11
14 var absoluteTop = 0; 12 var absoluteTop = 0;
15 var absoluteLeft = 0; 13 var absoluteLeft = 0;
16 for (var parentNode = element; parentNode; parentNode = parentNode.offsetPar ent) { 14 for (var parentNode = element; parentNode; parentNode = parentNode.offsetPar ent) {
17 absoluteLeft += parentNode.offsetLeft; 15 absoluteLeft += parentNode.offsetLeft;
18 absoluteTop += parentNode.offsetTop; 16 absoluteTop += parentNode.offsetTop;
19 } 17 }
20 18
21 var x = absoluteLeft + element.offsetWidth / 2; 19 var x = absoluteLeft + element.offsetWidth / 2;
22 var y = absoluteTop + element.offsetHeight / 2; 20 var y = absoluteTop + element.offsetHeight / 2;
23 eventSender.mouseMoveTo(x, y); 21 eventSender.mouseMoveTo(x, y);
24 eventSender.mouseDown(); 22 eventSender.mouseDown();
25 eventSender.mouseUp(); 23 eventSender.mouseUp();
26 eventSender.mouseMoveTo(0, 0); 24 eventSender.mouseMoveTo(0, 0);
27 } 25 }
28 26
29 description('Tests focusing of an inert label for a non-inert target. label.focu s() should send focus ' + 27 description('Tests focusing of an inert label for a non-inert target. label.focu s() should send focus ' +
30 'to the target, but clicking the label should be the same as clickin g on the document body.'); 28 'to the target, but clicking the label should be the same as clickin g on the document body.');
31 29
32 document.querySelector('dialog').showModal();
33 document.querySelector('#text').focus(); 30 document.querySelector('#text').focus();
34 31
35 debug('Testing that calling focus() on label sends focus to its target.'); 32 debug('Testing that calling focus() on label sends focus to its target.');
36 label = document.querySelector('label'); 33 label = document.querySelector('label');
37 label.focus(); 34 label.focus();
38 shouldBe('document.activeElement', "document.querySelector('#submit')"); 35 shouldBe('document.activeElement', "document.querySelector('#submit')");
39 36
40 debug('Testing that clicking on the label sends focus to document.body.'); 37 debug('Testing that clicking on the label sends focus to document.body.');
41 clickOn(label); 38 clickOn(label);
42 shouldBe('document.activeElement', 'document.body'); 39 shouldBe('document.activeElement', 'document.body');
43 </script> 40 </script>
44 </html> 41 </html>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698