Eine aufbereitete Darstellung der Quelle

 
     
 
 
Anforderungen  |   Konzepte  |   Entwurf  |   Entwicklung  |   Qualitätssicherung  |   Lebenszyklus  |   Steuerung
 
 
 
 

Benutzer

Quelle  test_serial_security.html

  Sprache: HTML
 

 products/Sources/formale Sprachen/C/Firefox/dom/webserial/tests/mochitest/test_serial_security.html


<!DOCTYPE HTML>
<html>
<head>
  <meta charset="utf-8">
  <title>Test Web Serial API - IPC Security Hardening</title>
  <script src="/tests/SimpleTest/SimpleTest.js"></script>
  <script src="serial_test_utils.js"></script>
  <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
</head>
<body>
<script>

"use strict";

SimpleTest.waitForExplicitFinish();

SimpleTest.registerCleanupFunction(async () => {
  await navigator.serial.resetToDefaultMockDevices();
  await cleanupSerialPorts();
});

// Test that opening a port whose device has been disconnected fails.
// This exercises the parent-side enumeration check in OpenRunnable that
// validates the portId against the currently-enumerated device list.
add_task(async function testOpenAfterDeviceRemoved() {
  await navigator.serial.removeAllMockDevices();
  await simulateDeviceConnection(
    "security-test-device""/dev/ttySEC0"0x2345, 0xBCDE
  );

  SpecialPowers.wrap(document).notifyUserGestureActivation();
  const port = await navigator.serial.requestPort({ filters: [] });
  ok(port, "Should get a port");
  const info = port.getInfo();
  is(info.usbVendorId, 0x2345, "expected usbVendorId from port");
  is(info.usbProductId, 0xBCDE, "expected usbProductId from port");

  // Disconnect the device while we still hold the port reference.
  await navigator.serial.simulateDeviceDisconnection("security-test-device");

  // Opening should fail because the device is no longer enumerated.
  await Assert.rejects(
    port.open({ baudRate: 9600 }),
    /NetworkError/,
    "Opening a disconnected device should throw NetworkError"
  );

  await navigator.serial.resetToDefaultMockDevices();
});

// Test that re-adding a device after disconnect allows reopening.
add_task(async function testReconnectAfterDisconnect() {
  await navigator.serial.removeAllMockDevices();
  await simulateDeviceConnection(
    "reconnect-device""/dev/ttyRCN"0x1111, 0x2222
  );

  SpecialPowers.wrap(document).notifyUserGestureActivation();
  const port = await navigator.serial.requestPort({ filters: [] });

  // Disconnect and try to open - should fail.
  await navigator.serial.simulateDeviceDisconnection("reconnect-device");
  await Assert.rejects(
    port.open({ baudRate: 9600 }),
    /NetworkError/,
    "Should get NetworkError after disconnect"
  );

  // Re-add the same device and request a new port - should work.
  await simulateDeviceConnection(
    "reconnect-device""/dev/ttyRCN"0x1111, 0x2222
  );
  SpecialPowers.wrap(document).notifyUserGestureActivation();
  const port2 = await navigator.serial.requestPort({ filters: [] });
  await port2.open({ baudRate: 9600 });
  ok(true, "Should be able to open after device reconnects");
  await port2.close();

  await navigator.serial.resetToDefaultMockDevices();
});

</script>
</body>
</html>

Messung V0.5 in Prozent
C=81 H=98 G=89

¤ Dauer der Verarbeitung: 0.24 Sekunden  (vorverarbeitet am  2026-08-25) ¤

*© Formatika GbR, Deutschland






Wurzel

Suchen

PVS Prover

Isabelle Prover

NIST Cobol Testsuite

Cephes Mathematical Library

Vienna Development Method

Haftungshinweis

Die Informationen auf dieser Webseite wurden nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit, noch Qualität der bereit gestellten Informationen zugesichert.

Bemerkung:

Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.






                                                                                                                                                                                                                                                                                                                                                                                                     


Neuigkeiten

     Aktuelles
     Motto des Tages

Open Source Software

     Quellcodebibliothek
     Eigene Quellcodes
     Fremde Quellcodes
     Suchen

Jenseits des Üblichen ....
    

Besucherstatistik

Besucherstatistik

Statistik
#Sources=277311
#Domains=752002