Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / third_party / WebKit / LayoutTests / fast / dom / HTMLDialogElement / inert-node-is-uneditable.html
blob72561141896ced902cfa85187b9e5b18cfdb17c6
1 <!DOCTYPE html>
2 <html>
3 <head>
4 <script src="../../../resources/js-test.js"></script>
5 </head>
6 <body>
7 <span id="not-editable" contenteditable>I'm not editable.</span>
8 <dialog>
9 <span id="editable" contenteditable>I'm editable.</span>
10 </dialog>
11 <script>
12 function clickOn(element)
14 if (!window.eventSender)
15 return;
17 var absoluteTop = 0;
18 var absoluteLeft = 0;
19 for (var parentNode = element; parentNode; parentNode = parentNode.offsetParent) {
20 absoluteLeft += parentNode.offsetLeft;
21 absoluteTop += parentNode.offsetTop;
24 var x = absoluteLeft + element.offsetWidth / 2;
25 var y = absoluteTop + element.offsetHeight / 2;
26 eventSender.mouseMoveTo(x, y);
27 eventSender.mouseDown();
28 eventSender.mouseUp();
29 eventSender.mouseMoveTo(0, 0);
32 function test()
34 description('Test that inert nodes cannot be edited. The test passes if the only text you can edit is in the dialog.');
36 dialog = document.querySelector('dialog');
37 dialog.showModal();
38 notEditable = document.querySelector('#not-editable');
39 editable = document.querySelector('#editable');
41 if (!window.eventSender)
42 return;
43 clickOn(notEditable);
44 oldValue = notEditable.textContent;
45 eventSender.keyDown('a');
46 shouldBe('notEditable.textContent', 'oldValue');
48 clickOn(editable);
49 oldValue = editable.textContent;
50 eventSender.keyDown('a');
51 shouldNotBe('editable.textContent', 'oldValue');
53 notEditable.remove();
54 editable.remove();
57 test();
58 </script>
59 </body>
60 </html>