test(Array.isArray(ports), "getPorts() should return an array in worker");
test(
!!ports.length, "getPorts() should return ports granted in window context"
);
const port = ports[0];
test(
port instanceof SerialPort, "Port from getPorts() should be a SerialPort instance in worker"
);
test( typeof port.connected === "boolean", "Port should have connected property in worker"
);
test(
port.connected === true, "Port should be connected initially in worker"
);
test("readable" in port, "Port should have readable property in worker");
test(
port.readable === null, "Port readable should be null when closed in worker"
);
test("writable" in port, "Port should have writable property in worker");
test(
port.writable === null, "Port writable should be null when closed in worker"
);
test( typeof port.getInfo === "function", "Port should have getInfo method in worker"
);
const info = port.getInfo();
test( typeof info === "object" && info !== null, "getInfo() should return an object in worker"
);
test(info.usbVendorId === 0x2341, "Port should have correct usbVendorId");
test(info.usbProductId === 0x0043, "Port should have correct usbProductId");
test( typeof port.open === "function", "Port should have open method in worker"
);
test( typeof port.close === "function", "Port should have close method in worker"
);
test( typeof port.getSignals === "function", "Port should have getSignals method in worker"
);
test( typeof port.setSignals === "function", "Port should have setSignals method in worker"
);
test( typeof port.forget === "function", "Port should have forget method in worker"
);
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.