tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

test_click_on_restyled_element.html (1820B)


      1 <!DOCTYPE HTML>
      2 <html>
      3 <head>
      4  <meta charset="utf-8">
      5  <title>Test for clicking on an element which is restyled/reframed by mousedown event</title>
      6  <script src="/tests/SimpleTest/SimpleTest.js"></script>
      7  <script src="/tests/SimpleTest/EventUtils.js"></script>
      8  <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
      9  <style>
     10    .before-pseudo-element *:active::before {
     11      content: "";
     12      display: block;
     13      height: 2px;
     14      position: absolute;
     15      top: -2px;
     16      left: 0;
     17      width: 100%;
     18    }
     19    .position-relative *:active {
     20      position: relative;
     21      top: 1px;
     22    }
     23  </style>
     24 </head>
     25 <body>
     26 <section class="before-pseudo-element"><a href="about:blank">link</a></section><!-- bug 1398196 -->
     27 <section class="before-pseudo-element"><span>span</span></section>
     28 <section class="position-relative"><a href="about:blank">link</a></section><!-- bug 1506508 -->
     29 <section class="position-relative"><span>span</span></section>
     30 <script type="application/javascript">
     31 SimpleTest.waitForExplicitFinish();
     32 SimpleTest.waitForFocus(function doTest() {
     33  for (let sectionId of ["before-pseudo-element", "position-relative"]) {
     34    for (let element of ["a", "span"]) {
     35      let target = document.querySelector(`section.${sectionId} ${element}`);
     36      target.scrollIntoView(true);
     37      let clicked = false;
     38      target.addEventListener("click", (aEvent) => {
     39        is(aEvent.target, target, `click event is fired on the <${element}> element in ${sectionId} section as expected`);
     40        aEvent.preventDefault();
     41        clicked = true;
     42      }, {once: true});
     43      synthesizeMouseAtCenter(target, {});
     44      ok(clicked, `Click event should've been fired on the <${element}> element in ${sectionId} section`);
     45    }
     46  }
     47  SimpleTest.finish();
     48 });
     49 </script>
     50 </body>
     51 </html>