OLD | NEW |
(Empty) | |
| 1 <!DOCTYPE html> |
| 2 <script src='../resources/testharness.js'></script> |
| 3 <script src='../resources/testharnessreport.js'></script> |
| 4 <script src='resources/shadow-dom.js'></script> |
| 5 |
| 6 <div id='host'> |
| 7 <template data-mode='open'> |
| 8 <slot></slot> |
| 9 </template> |
| 10 <div id='host2'> |
| 11 <template data-mode='open'> |
| 12 <div id='host3'> |
| 13 <template data-mode='open'> |
| 14 <canvas></canvas> |
| 15 <div id='host4'> |
| 16 <template data-mode='open'> |
| 17 <div></div> |
| 18 </template> |
| 19 </div> |
| 20 </template> |
| 21 </div> |
| 22 <div id='host5'> |
| 23 <template data-mode='open'> |
| 24 <div></div> |
| 25 </template> |
| 26 </div> |
| 27 </template> |
| 28 </div> |
| 29 </div> |
| 30 |
| 31 <script> |
| 32 async_test((test) => { |
| 33 document.onpointerlockerror = () => { |
| 34 assert_true(false, 'onpointerlockerror is not expected.'); |
| 35 test.done(); |
| 36 }; |
| 37 |
| 38 document.onpointerlockchange = () => { |
| 39 // Not interested in handling before or after exitPointerLock. |
| 40 if (document.pointerLockElement === null) |
| 41 return; |
| 42 |
| 43 assert_equals(document.pointerLockElement, host2, 'document.pointerLockE
lement should be shadow host2.'); |
| 44 assert_equals(host.shadowRoot.pointerLockElement, null, 'host\'s shadowR
oot.pointerLockElement should be null.'); |
| 45 assert_equals(host2.shadowRoot.pointerLockElement, host3, 'host2\'s shad
owRoot.pointerLockElement should be host3.'); |
| 46 assert_equals(host3.shadowRoot.pointerLockElement, canvas, 'host3\'s sha
dowRoot.pointerLockElement should be canvas element.'); |
| 47 assert_equals(host4.shadowRoot.pointerLockElement, null, 'host4\'s shado
wRoot.pointerLockElement should be null.'); |
| 48 assert_equals(host5.shadowRoot.pointerLockElement, null, 'host5\'s shado
wRoot.pointerLockElement should be null.'); |
| 49 |
| 50 document.exitPointerLock(); |
| 51 test.done(); |
| 52 }; |
| 53 |
| 54 convertTemplatesToShadowRootsWithin(host); |
| 55 var host3 = host2.shadowRoot.querySelector('#host3'); |
| 56 var host4 = host3.shadowRoot.querySelector('#host4'); |
| 57 var host5 = host2.shadowRoot.querySelector('#host5'); |
| 58 |
| 59 // All pointerLockElement should default to null. |
| 60 assert_equals(document.pointerLockElement, null); |
| 61 assert_equals(host.shadowRoot.pointerLockElement, null); |
| 62 assert_equals(host2.shadowRoot.pointerLockElement, null); |
| 63 assert_equals(host3.shadowRoot.pointerLockElement, null); |
| 64 assert_equals(host4.shadowRoot.pointerLockElement, null); |
| 65 assert_equals(host5.shadowRoot.pointerLockElement, null); |
| 66 |
| 67 var canvas = host3.shadowRoot.querySelector('canvas'); |
| 68 canvas.requestPointerLock(); |
| 69 }, 'Test for pointerLockElement adjustment for Shadow DOM.'); |
| 70 </script> |
OLD | NEW |