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>
13 These tests require a connected serial device configured to act as a
14 "loopback" device, with the transmit and receive pins wired together.
17 manual_serial_test(async (t
, port
) => {
18 await port
.open({baudRate
: 115200, bufferSize
: 1024});
20 let reader
= port
.readable
.getReader();
21 let readPromise
= (async () => {
22 // A single zero byte will be read before the break is detected.
23 const {value
, done
} = await reader
.read();
24 compareArrays(value
, new Uint8Array([0]));
28 const {value
, done
} = await reader
.read();
29 assert_unreached(`Expected break, got ${value.byteLength} bytes`);
31 assert_equals(e
.constructor, DOMException
);
32 assert_equals(e
.name
, 'BreakError');
36 await port
.setSignals({break: true});
38 await port
.setSignals({break: false});
40 const writer
= port
.writable
.getWriter();
41 // |data| is small enough to be completely transmitted.
42 let data
= new Uint8Array([1, 2, 3, 4, 5, 6, 7, 8]);
43 await writer
.write(data
);
46 reader
= port
.readable
.getReader();
47 const buffer
= await
readWithLength(reader
, data
.byteLength
);;
48 compareArrays(buffer
, data
);
52 }, 'Break is detected.');