tor-browser

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

test_legacy_touch_api.html (2256B)


      1 <!DOCTYPE HTML>
      2 <html>
      3 <!--
      4 https://bugzilla.mozilla.org/show_bug.cgi?id=1412485
      5 -->
      6 <head>
      7  <meta charset="utf-8">
      8  <title>Test for Bug 1412485</title>
      9  <script src="/tests/SimpleTest/SimpleTest.js"></script>
     10  <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
     11  <script type="application/javascript">
     12 
     13  /** Test for Bug 1412485 */
     14  SimpleTest.waitForExplicitFinish();
     15 
     16  function testExistenceOfLegacyTouchAPIs(win, enabled) {
     17    try {
     18      var event = document.createEvent("TouchEvent");
     19      ok(event instanceof TouchEvent, "Should be able to create TouchEvent using createEvent.");
     20    } catch(ex) {
     21      ok(true, "Shouldn't be able create TouchEvent using createEvent.");
     22    }
     23 
     24    var targets = [win, win.document, win.document.body];
     25    for (target of targets) {
     26      is("ontouchstart" in target, enabled, `ontouchstart on target [${enabled}].`);
     27      is("ontouchend" in target, enabled, `ontouchend on target [${enabled}].`);
     28      is("ontouchmove" in target, enabled, `ontouchmove on target [${enabled}].`);
     29      is("ontouchcancel" in target, enabled, `ontouchcancel on target [${enabled}].`);
     30    }
     31 
     32    is("createTouch" in win.document, enabled, `createTouch on Document [${enabled}].`);
     33    is("createTouchList" in win.document, enabled, `createTouchList on Document [${enabled}].`);
     34  }
     35 
     36  function test() {
     37    // Test the defaults.
     38    testExistenceOfLegacyTouchAPIs(window,
     39                                   navigator.userAgent.includes("Android"));
     40 
     41    // Test explicitly enabling touch APIs.
     42    SpecialPowers.pushPrefEnv({"set": [["dom.w3c_touch_events.enabled", 1],
     43                                       ["dom.w3c_touch_events.legacy_apis.enabled", true]]},
     44      function() {
     45        var iframe = document.createElement("iframe");
     46        iframe.onload = function() {
     47          testExistenceOfLegacyTouchAPIs(iframe.contentWindow, true);
     48          SimpleTest.finish();
     49        }
     50        document.body.appendChild(iframe);
     51      });
     52  }
     53 
     54  </script>
     55 </head>
     56 <body onload="test()">
     57 <a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=1412485">Mozilla Bug 1412485</a>
     58 <p id="display"></p>
     59 <div id="content" style="display: none">
     60 
     61 </div>
     62 <pre id="test">
     63 </pre>
     64 </body>
     65 </html>