| <!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN"> |
| <html> |
| <head> |
| <script src="../resources/accessibility-helper.js"></script> |
| <script src="../resources/js-test.js"></script> |
| <style> |
| #shadow-host { |
| /* Use extremely big font-size to guarantee the hit test hits the text. */ |
| font-size: 728px; |
| } |
| </style> |
| </head> |
| <body> |
| |
| <div id="shadow-host"></div> |
| |
| <script> |
| var output = "This test ensures that hit testing into the shadow DOM returns the right object.\n\n"; |
| |
| if (window.accessibilityController) { |
| window.jsTestIsAsync = true; |
| |
| const shadowHost = document.getElementById("shadow-host"); |
| const shadowHostRect = shadowHost.getBoundingClientRect(); |
| const shadowRoot = shadowHost.attachShadow({ mode: "open" }); |
| |
| const paragraph = document.createElement("p"); |
| paragraph.textContent = "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat."; |
| shadowRoot.appendChild(paragraph); |
| |
| var text; |
| var axElement; |
| setTimeout(async function() { |
| await waitFor(() => { |
| axElement = accessibilityController.rootElement.elementAtPoint(shadowHostRect.x + 300, shadowHostRect.y + 300); |
| return axElement && axElement.role.toLowerCase().includes("text"); |
| }); |
| |
| output += expect("axElement.role.toLowerCase().includes('text')", "true"); |
| text = accessibilityController.platformName === "ios" ? axElement.description : axElement.stringValue; |
| output += `${text}\n`; |
| output += expect("text.includes('Lorem ipsum')", "true"); |
| |
| debug(output); |
| finishJSTest(); |
| }, 0); |
| } |
| </script> |
| </body> |
| </html> |
| |