dom/events/test/test_unbound_before_in_active_chain.html
author Emilio Cobos Álvarez <emilio@crisal.io>
Tue, 11 Sep 2018 21:18:04 +0200
changeset 436028 b28cb41dd456532982ca7a2d579908b95f4ac17c
permissions -rw-r--r--
Bug 1489139 - Ensure unbound generated content doesn't remain in the active chain. r=smaug This reuses the same code path that was added in bug 1461299 for NAC, but for generated content as well. DestroyAnonymousContent notifies to the ESM. Also, remove the NativeAnonymousContentRemoved bit about <svg:use> since it's no longer NAC. Differential Revision: https://phabricator.services.mozilla.com/D5575

<!doctype html>
<title>Test for bug 1489139: Unbound generated content in the active chain</title>
<script src="/tests/SimpleTest/EventUtils.js"></script>
<script src="/tests/SimpleTest/SimpleTest.js"></script>
<style>
#target, #target::before {
  width: 200px;
  height: 200px;
}

#target::before {
  content: " ";
  display: block;
  background: green;
}

#target:active::before {
  content: "";
  background: red;
}
</style>
Should see a green square after clicking.
<div id="target"></div>
<script>
SimpleTest.waitForExplicitFinish();
onload = function() {
  let target = document.getElementById("target");
  requestAnimationFrame(() => {
    synthesizeMouseAtPoint(100, 100, { type: "mousedown" })
    ok(target.matches(":active"), "Should have been clicked");
    requestAnimationFrame(() => {
      synthesizeMouseAtPoint(100, 100, { type: "mouseup" })
      ok(!target.matches(':active'), "Should stop matching :active afterwards");
      SimpleTest.finish();
    });
  });
}
</script>