tor-browser

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

serialPort_loopback_flowControl-manual.https.html (1758B)


      1 <!DOCTYPE html>
      2 <html>
      3  <head>
      4    <meta charset="utf-8">
      5    <title></title>
      6    <script src="/resources/testharness.js"></script>
      7    <script src="/resources/testharnessreport.js"></script>
      8    <script src="resources/common.js"></script>
      9    <script src="resources/manual.js"></script>
     10  </head>
     11  <body>
     12    <p>
     13      These tests require a connected serial device configured to act as a
     14      "loopback" device, with the TX and RX pins and RTS and CTS pins wired
     15      together.
     16    </p>
     17    <script>
     18      manual_serial_test(async (t, port) => {
     19        await port.open({
     20            baudRate: 115200,
     21            bufferSize: 255,
     22            flowControl: 'none'
     23        });
     24        t.add_cleanup(async () => {
     25          await port.close();
     26        });
     27 
     28        await port.setSignals({ requestToSend: true });
     29        let signals = await port.getSignals();
     30        assert_true(signals.clearToSend);
     31 
     32        await port.setSignals({ requestToSend: false });
     33        signals = await port.getSignals();
     34        assert_false(signals.clearToSend);
     35      }, 'Manual RTS control works with no flow control enabled');
     36 
     37      manual_serial_test(async (t, port) => {
     38        await port.open({
     39            baudRate: 115200,
     40            bufferSize: 255,
     41            flowControl: 'hardware'
     42        });
     43 
     44        const writer = port.writable.getWriter();
     45        t.add_cleanup(async () => {
     46          writer.releaseLock();
     47          await port.close();
     48        });
     49 
     50        assert_true((await port.getSignals()).clearToSend);
     51 
     52        const buffer = new Uint8Array(1);
     53        while ((await port.getSignals()).clearToSend) {
     54          await writer.write(buffer);
     55        }
     56      }, 'Hardware flow control automatically sets RTS pin');
     57    </script>
     58  </body>
     59 </html>