// FIXME: 2. If this.[[state]] is not "closed", reject promise with an "InvalidStateError" DOMException and return promise.
// FIXME: 3. If options["dataBits"] is not 7 or 8, reject promise with TypeError and return promise.
// FIXME: 4. If options["stopBits"] is not 1 or 2, reject promise with TypeError and return promise.
// FIXME: 5. If options["bufferSize"] is 0, reject promise with TypeError and return promise.
// FIXME: 6. Optionally, if options["bufferSize"] is larger than the implementation is able to support, reject promise with a TypeError and return promise.
// FIXME: 7. Set this.[[state]] to "opening".
// FIXME: 8. Perform the following steps in parallel.
{
// FIXME: 1. Invoke the operating system to open the serial port using the connection parameters (or their defaults) specified in options.
// FIXME: 2. If this fails for any reason, queue a global task on the relevant global object of this using the serial port task source to reject promise with a "NetworkError" DOMException and abort these steps.
// FIXME: 3. Set this.[[state]] to "opened".
// FIXME: 4. Set this.[[bufferSize]] to options["bufferSize"].
// FIXME: 5. Queue a global task on the relevant global object of this using the serial port task source to resolve promise with undefined.
// FIXME: 2. If this.[[state]] is not "opened", reject promise with an "InvalidStateError" DOMException and return promise.
// FIXME: 3. Perform the following steps in parallel:
{
// FIXME: 1. Query the operating system for the status of the control signals that may be asserted by the device connected to the serial port.
// FIXME: 2. If the operating system fails to determine the status of these signals for any reason, queue a global task on the relevant global object of
// this using the serial port task source to reject promise with a "NetworkError" DOMException and abort these steps.
// FIXME: 3. Let dataCarrierDetect be true if the "data carrier detect" or "DCD" signal has been asserted by the device, and false otherwise.
// FIXME: 4. Let clearToSend be true if the "clear to send" or "CTS" signal has been asserted by the device, and false otherwise.
// FIXME: 5. Let ringIndicator be true if the "ring indicator" or "RI" signal has been asserted by the device, and false otherwise.
// FIXME: 6. Let dataSetReady be true if the "data set ready" or "DSR" signal has been asserted by the device, and false otherwise.
// FIXME: 7. Let signals be the ordered map «[ "dataCarrierDetect" → dataCarrierDetect, "clearToSend" → clearToSend, "ringIndicator" → ringIndicator, "dataSetReady" → dataSetReady ]».
// FIXME: 8. Queue a global task on the relevant global object of this using the serial port task source to resolve promise with signals.
// FIXME: 2. If this.[[state]] is not "opened", reject promise with an "InvalidStateError" DOMException and return promise.
// FIXME: 3. Let cancelPromise be the result of invoking cancel on this.[[readable]] or a promise resolved with undefined if this.[[readable]] is null.
// FIXME: 4. Let abortPromise be the result of invoking abort on this.[[writable]] or a promise resolved with undefined if this.[[writable]] is null.
// FIXME: 5. Let pendingClosePromise be a new promise.
// FIXME: 6. If this.[[readable]] and this.[[writable]] are null, resolve pendingClosePromise with undefined.
// FIXME: 7. Set this.[[pendingClosePromise]] to pendingClosePromise.
// FIXME: 8. Let combinedPromise be the result of getting a promise to wait for all with «cancelPromise, abortPromise, pendingClosePromise».
// FIXME: 9. Set this.[[state]] to "closing".
// FIXME: 10. React to combinedPromise.
{
// If combinedPromise was fulfilled, then:
// FIXME: 1. Run the following steps in parallel:
{
// FIXME: 1. Invoke the operating system to close the serial port and release any associated resources.
// FIXME: 2. Set this.[[state]] to "closed".
// FIXME: 3. Set this.[[readFatal]] and this.[[writeFatal]] to false.
// FIXME: 4. Set this.[[pendingClosePromise]] to null.
// FIXME: 5. Queue a global task on the relevant global object of this using the serial port task source to resolve promise with undefined.
}
// If combinedPromise was rejected with reason r, then:
{
// FIXME: 1. Set this.[[pendingClosePromise]] to null.
// FIXME: 2. Queue a global task on the relevant global object of this using the serial port task source to reject promise with r.
// FIXME: 1. If the user agent can't perform this action (e.g. permission was granted by administrator policy), return a promise resolved with undefined.
// FIXME: 2. Run the following steps in parallel:
{
// FIXME: 1. Set this.[[state]] to "forgetting".
// FIXME: 2. Remove this from the sequence of serial ports on the system which the user has allowed the site to access as the result of a previous call to requestPort().
// FIXME: 3. Set this.[[state]] to "forgotten".
// FIXME: 4. Queue a global task on the relevant global object of this using the serial port task source to resolve promise with undefined.