Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 <!DOCTYPE html> | |
| 2 <script src="../resources/testharness.js"></script> | |
| 3 <script src="../resources/testharnessreport.js"></script> | |
| 4 <script src="../fast/dom/shadow/resources/shadow-dom.js"></script> | |
| 5 | |
| 6 <div id="log"></div> | |
| 7 <div id="sandbox"> | |
| 8 <div id = "host"> | |
| 9 <template> | |
| 10 <input id="target1"></input> | |
| 11 <input id="target2"></input> | |
| 12 <input id="target3"></input> | |
| 13 <input id="target4"></input> | |
| 14 </template> | |
| 15 </div> | |
| 16 </div> | |
| 17 | |
| 18 <script> | |
| 19 | |
| 20 function moveMouseOver(element) | |
| 21 { | |
| 22 if (!window.eventSender || !window.internals) | |
| 23 return; | |
| 24 | |
| 25 var defaultPaddingSize = 20; | |
| 26 var x = element.offsetLeft + element.offsetWidth / 2; | |
| 27 var y; | |
| 28 if (element.hasChildNodes() || window.internals.shadowRoot(element)) | |
| 29 y = element.offsetTop + defaultPaddingSize; | |
| 30 else | |
| 31 y = element.offsetTop + element.offsetHeight / 2; | |
| 32 eventSender.mouseMoveTo(x, y); | |
| 33 } | |
| 34 | |
| 35 var sandbox = document.getElementById('sandbox'); | |
| 36 convertTemplatesToShadowRootsWithin(sandbox); | |
| 37 var target1 = getNodeInComposedTree('host/target1'); | |
| 38 var target2 = getNodeInComposedTree('host/target2'); | |
| 39 var target3 = getNodeInComposedTree('host/target3'); | |
| 40 var target4 = getNodeInComposedTree('host/target4'); | |
| 41 | |
| 42 async_test(function(t) { | |
| 43 target1.onfocus = function(e) { | |
| 44 t.step(function() { | |
| 45 assert_equals(e.relatedTarget, null); | |
| 46 assert_false(e.relatedTargetScoped); | |
| 47 t.done(); | |
| 48 }); | |
| 49 }; | |
| 50 target1.focus(); | |
| 51 }, 'Trusted events should have relatedTargetScoped set to false by default.'); | |
| 52 | |
| 53 async_test(function(t) { | |
|
hayato
2016/03/18 06:26:52
It looks that this test is assuming that target1 i
yuzuchan
2016/03/18 07:20:15
Thanks for the comment, done.
| |
| 54 target2.onfocus = function(e) { | |
| 55 t.step(function() { | |
| 56 assert_equals(e.relatedTarget, target1); | |
| 57 assert_true(e.relatedTargetScoped); | |
| 58 t.done(); | |
| 59 }); | |
| 60 }; | |
| 61 target2.focus(); | |
| 62 }, 'Trusted focus events with a related target should have relatedTargetScoped t rue.'); | |
| 63 | |
| 64 async_test(function(t) { | |
| 65 target1.onmouseenter = function(e) { | |
| 66 t.step(function() { | |
| 67 assert_equals(e.relatedTarget, null); | |
| 68 assert_false(e.relatedTargetScoped); | |
| 69 t.done(); | |
| 70 }); | |
| 71 }; | |
| 72 moveMouseOver(target1); | |
| 73 }, 'Trusted mouse events without a related target should have relatedTargetScope d set to false.'); | |
| 74 | |
| 75 async_test(function(t) { | |
| 76 target2.onmouseenter = function(e) { | |
| 77 t.step(function() { | |
| 78 assert_equals(e.relatedTarget, target1); | |
| 79 assert_true(e.relatedTargetScoped); | |
| 80 t.done(); | |
| 81 }); | |
| 82 }; | |
| 83 moveMouseOver(target2); | |
| 84 }, 'Trusted mouse events with a related target should have relatedTargetScoped t rue.'); | |
| 85 | |
| 86 async_test(function(t) { | |
| 87 var userFocus1 = new FocusEvent('focus', { relatedTarget: target4 }); | |
| 88 target3.onfocus = function(e) { | |
| 89 t.step(function() { | |
| 90 assert_equals(e.relatedTarget, target4); | |
| 91 assert_false(e.relatedTargetScoped); | |
| 92 t.done(); | |
| 93 }); | |
| 94 }; | |
| 95 target3.dispatchEvent(userFocus1); | |
| 96 }, 'Untrusted events should have relatedTargetScoped set to false by default.'); | |
| 97 | |
| 98 async_test(function(t) { | |
| 99 var userFocus2 = new FocusEvent('focus', { relatedTarget: target3, relatedTa rgetScoped: true }); | |
| 100 target4.onfocus = function(e) { | |
| 101 t.step(function() { | |
| 102 assert_equals(e.relatedTarget, target3); | |
| 103 assert_true(e.relatedTargetScoped); | |
| 104 t.done(); | |
| 105 }); | |
| 106 }; | |
| 107 target4.dispatchEvent(userFocus2); | |
| 108 }, 'Trusted focus events with a related target should have relatedTargetScoped t rue.'); | |
| 109 | |
| 110 </script> | |
| OLD | NEW |