<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
 <head>
  <title>:hover pseudo-class on links</title>
  <style type="text/css"><![CDATA[
p { color: navy; }

.a a:hover { background: green; color: white; }

.b a:hover { background: red; color: yellow; }
.b a:link { background: green; color: white; }

.c :link { background: green; color: white; }
.c :visited:hover { background: red; color: yellow; }
]]></style>
  <link rel="author" title="Ian Hickson" href="mailto:ian@hixie.ch"/>
  <link rel="help" href="https://www.w3.org/TR/css3-selectors/#selectors"/> <!-- bogus link to make sure it gets found -->
  <script src="/resources/testharness.js"></script>
  <script src="/resources/testharnessreport.js"></script>
  <script src="/resources/testdriver.js"></script>
  <script src="/resources/testdriver-vendor.js"></script>
  <script src="/resources/testdriver-actions.js"></script>
 </head>
 <body>
<p class="a">The background color of <a href="#foo" id="t1">this anchor (<strong>here</strong>)</a> should turn to green when the pointing device hovers over it.</p>
<p class="b">The background color of <a href="#foo" id="t2">this anchor (<strong>here</strong>)</a> should <strong>remain green when you hover it</strong>.</p>
<p class="c">The background color of <a href="http://link.example.com/" id="t3">this anchor (<strong>here</strong>)</a> should <strong>remain green when the pointing device hovers over it</strong> (do not follow that link).</p>
<script><![CDATA[
test(() => {
  assert_equals(getComputedStyle(document.getElementById('t2')).backgroundColor, 'rgb(0, 128, 0)', 't2 should be green initially');
  assert_equals(getComputedStyle(document.getElementById('t3')).backgroundColor, 'rgb(0, 128, 0)', 't3 should be green initially');
}, "Initial states");

promise_test(async () => {
  const t1 = document.getElementById('t1');
  await new test_driver.Actions()
    .pointerMove(0, 0, {origin: t1})
    .send();
  assert_equals(getComputedStyle(t1).backgroundColor, 'rgb(0, 128, 0)', 't1 should be green when hovered');
}, "t1 hover");

promise_test(async () => {
  const t2 = document.getElementById('t2');
  await new test_driver.Actions()
    .pointerMove(0, 0, {origin: t2})
    .send();
  assert_equals(getComputedStyle(t2).backgroundColor, 'rgb(0, 128, 0)', 't2 should remain green when hovered');
}, "t2 hover");

promise_test(async () => {
  const t3 = document.getElementById('t3');
  await new test_driver.Actions()
    .pointerMove(0, 0, {origin: t3})
    .send();
  assert_equals(getComputedStyle(t3).backgroundColor, 'rgb(0, 128, 0)', 't3 should remain green when hovered');
}, "t3 hover");
]]></script>
</body>
</html>