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