Index: third_party/WebKit/LayoutTests/shadow-dom/pointer-lock-in-shadow.html |
diff --git a/third_party/WebKit/LayoutTests/shadow-dom/pointer-lock-in-shadow.html b/third_party/WebKit/LayoutTests/shadow-dom/pointer-lock-in-shadow.html |
new file mode 100644 |
index 0000000000000000000000000000000000000000..5fa75bf0eac1446bf6f3b35d74a0a42ed14c2005 |
--- /dev/null |
+++ b/third_party/WebKit/LayoutTests/shadow-dom/pointer-lock-in-shadow.html |
@@ -0,0 +1,53 @@ |
+<!DOCTYPE html> |
+<script src='../resources/testharness.js'></script> |
+<script src='../resources/testharnessreport.js'></script> |
+<script src='resources/shadow-dom.js'></script> |
+ |
+<div id='host'> |
+ <template data-mode='open'> |
+ <slot></slot> |
+ </template> |
+ <div id='host2'> |
+ <template data-mode='open'> |
+ <div id='host3'> |
+ <template data-mode='open'> |
+ <canvas></canvas> |
+ </template> |
+ </div> |
+ </template> |
+ </div> |
+</div> |
+ |
+<script> |
+async_test((test) => { |
+ document.onpointerlockerror = () => { |
+ assert_true(false, 'onpointerlockerror is not expected.'); |
+ test.done(); |
+ }; |
+ |
+ document.onpointerlockchange = () => { |
+ // Not interested in handling before or after exitPointerLock. |
+ if (document.pointerLockElement === null) |
+ return; |
+ |
+ assert_equals(document.pointerLockElement, host2, 'document.pointerLockElement should be shadow host2.'); |
+ assert_equals(host.shadowRoot.pointerLockElement, null, 'host\'s shadowRoot.pointerLockElement should be null.'); |
+ assert_equals(host2.shadowRoot.pointerLockElement, host3, 'host2\'s shadowRoot.pointerLockElement should be host3.'); |
+ assert_equals(host3.shadowRoot.pointerLockElement, canvas, 'host3\'s shadowRoot.pointerLockElement should be canvas element.'); |
+ |
+ document.exitPointerLock(); |
+ test.done(); |
+ }; |
+ |
+ convertTemplatesToShadowRootsWithin(host); |
+ var host3 = host2.shadowRoot.querySelector('#host3'); |
+ |
+ assert_equals(document.pointerLockElement, null, 'document.pointerLockElement should default to null.'); |
+ assert_equals(host.shadowRoot.pointerLockElement, null, 'ShadowRoot.pointerLockElement should default to null.'); |
+ assert_equals(host2.shadowRoot.pointerLockElement, null, 'ShadowRoot.pointerLockElement should default to null.'); |
+ assert_equals(host3.shadowRoot.pointerLockElement, null, 'ShadowRoot.pointerLockElement should default to null.'); |
+ |
+ var canvas = host3.shadowRoot.querySelector('canvas'); |
+ canvas.requestPointerLock(); |
+}, 'Test for pointerLockElement adjustment for Shadow DOM.'); |
+</script> |