tor-browser

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

virtual-keyboard-show-hide-manual.html (4638B)


      1 <html>
      2 <head>
      3 <title>This tests the new virtualKeyboard show/hide APIs</title>
      4        <meta charset="utf-8">
      5        <meta name="viewport" content="width=device-width">
      6        <script src="/resources/testharness.js"></script>
      7        <script src="/resources/testharnessreport.js"></script>
      8        <script src="vk_support.js"></script>
      9        <script>
     10           setup({explicit_timeout: true, explicit_done: true})
     11        </script>
     12 </head>
     13 <body>
     14  <h1>VirtualKeyboard: Virtual Keyboard show/hide Fires Event</h1>
     15  <h4>
     16      Test Description: This test checks that a geometry change event is
     17      fired when show/hide APIs are called. VK is only displayed on a touch
     18      device with tablet mode on or a mobile device where VK is the default
     19      text input mechanism.
     20  </h4>
     21  <h2 style="color: red">THIS IS A MANUAL TEST</h2>
     22  <div id="div1" contenteditable="true" virtualKeyboardPolicy="auto">Auto policy tap here.</div>
     23  <div id="div2" contenteditable="true" virtualKeyboardPolicy="manual">Manual policy show here.</div>
     24  <div id="div3" contenteditable="true" virtualKeyboardPolicy="manual">Manual policy hide here.</div>
     25  <div id="div4" contenteditable="false">Read-only region tap here.</div>
     26  <p id="skip">
     27      <button id="skipbtn" onclick="skipManualTest();">Skip Test</button>
     28  </p>
     29  <p id="instruction"></p>
     30  <button id="continue">Start Test</button>
     31  <div id="log"></div>
     32  </body>
     33  <script>
     34      var continueBtn = document.getElementById("continue");
     35      var div1 = document.getElementById("div1");
     36      var div2 = document.getElementById("div2");
     37      var div3 = document.getElementById("div3");
     38 
     39      function continueTest() {
     40        nextStep(function(instructionText) {
     41          var instruction = document.getElementById("instruction");
     42          continueBtn.innerText = "Continue";
     43          instruction.innerText = instructionText;
     44        });
     45      }
     46 
     47      continueBtn.addEventListener('click', continueTest);
     48      div1.addEventListener('onfocusin', function(e) {
     49        navigator.virtualKeyboard.overlaysContent = true;
     50      });
     51      div2.addEventListener('onfocusin', function(e) {
     52        navigator.virtualKeyboard.overlaysContent = true;
     53        navigator.virtualKeyboard.show();
     54      });
     55      div3.addEventListener('onfocusin', function(e) {
     56        navigator.virtualKeyboard.overlaysContent = true;
     57        navigator.virtualKeyboard.hide();
     58      });
     59 
     60      var didFireGeometryChange;
     61      var cancelable;
     62      var bubbles;
     63 
     64      function resetValues() {
     65          navigator.virtualKeyboard.overlaysContent = false;
     66          didFireGeometryChange = false;
     67          cancelable = undefined;
     68          bubbles = undefined;
     69      }
     70 
     71      addManualTestStep(
     72          function() {
     73              resetValues();
     74              navigator.virtualKeyboard.addEventListener('geometrychange', function(e) {
     75                  didFireGeometryChange = true;
     76                  cancelable = e.cancelable;
     77                  bubbles = e.bubbles;
     78              });
     79          },
     80          null,
     81          '1. Tap on the Auto policy tap here. text');
     82 
     83      addManualTestStep(
     84          function() {
     85              assert_true(didFireGeometryChange);
     86              assert_false(cancelable);
     87              assert_false(bubbles);
     88              resetValues();
     89           },
     90          'Geometry change event fired at navigator.virtualKeyboard after VK is shown',
     91          '2. Hide the VK by tapping on Read-only region tap here. text');
     92 
     93      addManualTestStep(
     94          function() {
     95              assert_true(didFireGeometryChange);
     96              assert_false(cancelable);
     97              assert_false(bubbles);
     98              resetValues();
     99          },
    100          'Hiding the VK fires the geometry change event',
    101          '3. Tap on the Manual policy show here. text');
    102 
    103      addManualTestStep(
    104          function() {
    105              assert_true(didFireGeometryChange);
    106              assert_false(cancelable);
    107              assert_false(bubbles);
    108              resetValues();
    109          },
    110          'Calling show API displays the VK & fires the geometry change event',
    111          '4. Hide the VK by tapping on the Manual policy hide here. text');
    112 
    113      addManualTestStep(
    114          function() {
    115              assert_true(didFireGeometryChange);
    116              assert_false(cancelable);
    117              assert_false(bubbles);
    118              resetValues();
    119          },
    120          'Calling hide API hides the VK and fires the geometry change event',
    121          '');
    122 
    123      addManualTestStep(
    124          function() { continueBtn.remove(); },
    125          null,
    126          'Test Complete');
    127  </script>
    128 </html>