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 </template> |
| 16 </div> |
| 17 </template> |
| 18 </div> |
| 19 </div> |
| 20 |
| 21 <script> |
| 22 async_test((test) => { |
| 23 document.onpointerlockerror = () => { |
| 24 assert_true(false, 'onpointerlockerror is not expected.'); |
| 25 test.done(); |
| 26 }; |
| 27 |
| 28 document.onpointerlockchange = () => { |
| 29 // Not interested in handling before or after exitPointerLock. |
| 30 if (document.pointerLockElement === null) |
| 31 return; |
| 32 |
| 33 assert_equals(document.pointerLockElement, host2, 'document.pointerLockE
lement should be shadow host2.'); |
| 34 assert_equals(host.shadowRoot.pointerLockElement, null, 'host\'s shadowR
oot.pointerLockElement should be null.'); |
| 35 assert_equals(host2.shadowRoot.pointerLockElement, host3, 'host2\'s shad
owRoot.pointerLockElement should be host3.'); |
| 36 assert_equals(host3.shadowRoot.pointerLockElement, canvas, 'host3\'s sha
dowRoot.pointerLockElement should be canvas element.'); |
| 37 |
| 38 document.exitPointerLock(); |
| 39 test.done(); |
| 40 }; |
| 41 |
| 42 convertTemplatesToShadowRootsWithin(host); |
| 43 var host3 = host2.shadowRoot.querySelector('#host3'); |
| 44 |
| 45 assert_equals(document.pointerLockElement, null, 'document.pointerLockElemen
t should default to null.'); |
| 46 assert_equals(host.shadowRoot.pointerLockElement, null, 'ShadowRoot.pointerL
ockElement should default to null.'); |
| 47 assert_equals(host2.shadowRoot.pointerLockElement, null, 'ShadowRoot.pointer
LockElement should default to null.'); |
| 48 assert_equals(host3.shadowRoot.pointerLockElement, null, 'ShadowRoot.pointer
LockElement should default to null.'); |
| 49 |
| 50 var canvas = host3.shadowRoot.querySelector('canvas'); |
| 51 canvas.requestPointerLock(); |
| 52 }, 'Test for pointerLockElement adjustment for Shadow DOM.'); |
| 53 </script> |
OLD | NEW |