| <!DOCTYPE html> |
| <html> |
| <head> |
| <script src="../../../../resources/js-test.js"></script> |
| <style> |
| img { |
| width: 400px; |
| height: 400px; |
| } |
| |
| div[contenteditable] { |
| border: 1px solid tomato; |
| } |
| |
| a { |
| display: block; |
| position: absolute; |
| top: 0; |
| left: 0; |
| } |
| </style> |
| </head> |
| <body> |
| <a href="https://webkit.org"> |
| <img src="../../resources/green-400x400.png"></img> |
| </a> |
| <div contenteditable></div> |
| <script> |
| function getCopyContextMenuItem() |
| { |
| for (const item of eventSender.contextClick()) { |
| if (item.title === "Copy") |
| return item; |
| } |
| return null; |
| } |
| |
| addEventListener("load", () => { |
| let image = document.querySelector("img"); |
| internals.installImageOverlay(image, [ |
| { |
| topLeft : new DOMPointReadOnly(0, 0), |
| topRight : new DOMPointReadOnly(1, 0), |
| bottomRight : new DOMPointReadOnly(1, 0.5), |
| bottomLeft : new DOMPointReadOnly(0, 0.5), |
| children: [ |
| { |
| text : "foobar", |
| topLeft : new DOMPointReadOnly(0, 0), |
| topRight : new DOMPointReadOnly(1, 0), |
| bottomRight : new DOMPointReadOnly(1, 0.5), |
| bottomLeft : new DOMPointReadOnly(0, 0.5), |
| } |
| ] |
| } |
| ]); |
| |
| eventSender.mouseMoveTo(50, 150); |
| |
| shouldBeNull("getCopyContextMenuItem()"); |
| getSelection().selectAllChildren(internals.shadowRoot(image).getElementById("image-overlay")); |
| testPassed("Selected text in image"); |
| shouldBeNonNull("getCopyContextMenuItem()"); |
| }); |
| </script> |
| </body> |
| </html> |