5.9. Firing a success event

To fire a success event at a request, run these steps:

  1. Let event be the result of creating an event using [Event](https://dom.spec.whatwg.org/#event).

  2. Set event’s [type](https://dom.spec.whatwg.org/#dom-event-type) attribute to “success“.

  3. Set event’s [bubbles](https://dom.spec.whatwg.org/#dom-event-bubbles) and [cancelable](https://dom.spec.whatwg.org/#dom-event-cancelable) attributes to false.

  4. Let transaction be request’s transaction.

  5. Let legacyOutputDidListenersThrowFlag be initially false.

  6. If transaction’s state is inactive, then set transaction’s state to active.

  7. Dispatch event at request with legacyOutputDidListenersThrowFlag.

  8. If transaction’s state is active, then:

    1. Set transaction’s state to inactive.

    2. If legacyOutputDidListenersThrowFlag is true, then run abort a transaction with transaction and a newly created[AbortError](https://heycam.github.io/webidl/#aborterror)[DOMException](https://heycam.github.io/webidl/#idl-DOMException).

    3. If transaction’s request list is empty, then run commit a transaction with transaction.