ui: Ensure event sources are closed to the correct state when connecting (#6036)

This fails the tests, but wouldn't produce an actual bug as the source
is still set to closing, just 1 tick later.
This commit is contained in:
John Cowen 2019-07-01 21:20:21 +01:00 committed by John Cowen
parent bcc9dbba45
commit cb51f9674d
2 changed files with 5 additions and 2 deletions

View File

@ -68,10 +68,12 @@ export default function(
close() {
// additional readyState 3 = CLOSING
switch (this.readyState) {
case 0: // CONNECTING
case 2: // CLOSED
// it's already CLOSED , do nothing
this.readyState = 2;
break;
default:
// OPEN
this.readyState = 3; // CLOSING
}
// non-standard

View File

@ -82,10 +82,11 @@ module('Integration | Utility | dom/event-source/callable', function(hooks) {
});
});
test("it can be closed before the first tick, and therefore doesn't run", function(assert) {
assert.expect(3);
assert.expect(4);
const EventSource = domEventSourceCallable(EventTarget);
const listener = this.stub();
const source = new EventSource();
assert.equal(source.readyState, 0);
source.close();
assert.equal(source.readyState, 2);
source.addEventListener('open', function(e) {