| <!DOCTYPE html> |
| <!-- |
| Test for: https://bugs.webkit.org/show_bug.cgi?id=80382 |
| (Selection Background Color Error) |
| |
| This bug is caused when the selection background is inverted if it |
| is the same as the text color. However, it should compare against |
| the selected text color instead of the non-selected text color. |
| |
| The alpha component must be non-opaque for the bug to get triggered. |
| This is because when the selection background is opaque, it will be |
| blended with white, which prevents the inversion. |
| --> |
| <html> |
| <head> |
| <style> |
| #A::selection { |
| background: rgba(0,0,0,0.85); |
| color: white; |
| } |
| |
| #B::selection { |
| background: rgba(0,255,0,0.85); |
| color: blue; |
| } |
| </style> |
| </head> |
| <body> |
| <div id="A">Test passes if the selection background is black</div> |
| <div id="B">Test passes if the selection background is green</div> |
| </body> |
| <script> |
| var body = document.getElementsByTagName("body")[0]; |
| window.getSelection().selectAllChildren(body); |
| </script> |
| </html> |