Bug 1697539 Comment 3 Edit History

Note: The actual edited comment in the bug view page will always show the original commenter’s name and original timestamp.

See the simplified test case below. This [assertion](https://searchfox.org/mozilla-central/rev/6eab79ab46c362b0191c4dad919f4cea2d6efb40/dom/xhr/XMLHttpRequestWorker.cpp#1311) is triggered because `xhr.send` is called again inside a sync xhr event loop.
```
  const xhr = new XMLHttpRequest({})
  xhr.addEventListener('readystatechange', (e) => {
    e.originalTarget.send('...')
  }, {})
  xhr.open('POST', 'FOOBAR', false)
  xhr.send()
```
The same test case works find on main thread, since there is a check in [XMLHttpRequestMainThread::SendInternal](https://searchfox.org/mozilla-central/rev/6b4e19ad33650fdf9cd8529cd68eeb98bff1b935/dom/xhr/XMLHttpRequestMainThread.cpp#2894-2897) to avoid this. However, the same check is no in `XMLHttpRequestWorker::Send`.
Adding the same check can fix the problem in this bug.
See the simplified test case below. This [assertion](https://searchfox.org/mozilla-central/rev/6eab79ab46c362b0191c4dad919f4cea2d6efb40/dom/xhr/XMLHttpRequestWorker.cpp#1311) is triggered because `xhr.send` is called again inside a sync xhr event loop.
```
  const xhr = new XMLHttpRequest({})
  xhr.addEventListener('readystatechange', (e) => {
    e.originalTarget.send('...')
  }, {})
  xhr.open('POST', 'FOOBAR', false)
  xhr.send()
```
The same test case works fine on main thread, since there is a check in [XMLHttpRequestMainThread::SendInternal](https://searchfox.org/mozilla-central/rev/6b4e19ad33650fdf9cd8529cd68eeb98bff1b935/dom/xhr/XMLHttpRequestMainThread.cpp#2894-2897) to avoid this. However, the same check is no in `XMLHttpRequestWorker::Send`.
Adding the same check can fix the problem in this bug.
See the simplified test case below. This [assertion](https://searchfox.org/mozilla-central/rev/6eab79ab46c362b0191c4dad919f4cea2d6efb40/dom/xhr/XMLHttpRequestWorker.cpp#1311) is triggered because `xhr.send` is called again inside a sync xhr event loop.
```
  const xhr = new XMLHttpRequest({})
  xhr.addEventListener('readystatechange', (e) => {
    e.originalTarget.send('...')
  }, {})
  xhr.open('POST', 'FOOBAR', false)
  xhr.send()
```
The same test case works fine on main thread, since there is a check in [XMLHttpRequestMainThread::SendInternal](https://searchfox.org/mozilla-central/rev/6b4e19ad33650fdf9cd8529cd68eeb98bff1b935/dom/xhr/XMLHttpRequestMainThread.cpp#2894-2897) to avoid this. However, the same check is missing in `XMLHttpRequestWorker::Send`.
Adding the same check can fix the problem in this bug.

Back to Bug 1697539 Comment 3