Commit d0926d4
Fix WebSocket test flake and update UrlLib/AndroidExtensions (#150)
Fix WebSocket test flake and update dependencies.
## The Bug
Tests called `done()` from both `onerror` and `onclose`, causing mocha's
"done() called multiple times" error when the native layer fired both
events.
## Root Cause
The Windows and Apple WebSocket implementations only fired `onError` on
connection failures, not `onClose`. Android's `org.java_websocket`
library fires both naturally. This inconsistency meant tests couldn't
rely on a single terminal event.
## The Fix
**UrlLib** (bumped to 880c257): Added a single `CloseOnce` helper on
Windows and `invalidateAndCancelWithCloseCode` on Apple that checks the
close code internally — fires `onError` for abnormal codes, then
`onClose` exactly once. All platforms now consistently fire `onClose` as
the terminal event.
**AndroidExtensions** (bumped to 2e85a8d): Removed the redundant
`errorCallback` from `onClose` that was re-interpreting close codes. The
`org.java_websocket` library already fires `onError` for error
conditions.
**Tests**: Refactored so `done()` is called exactly once from `onclose`
(the terminal event). Errors from earlier phases (assertion failures,
`onerror`) are collected in an `error` variable and reported via
`done(error)`. Catch blocks call `ws.close()` to ensure `onclose` fires
promptly on assertion failure. All `expect` assertions are preserved for
property and value checks (`readyState`, `url`, message content). The
invalid domain test verifies `onerror` fires before `onclose`.
## Dependencies
- BabylonJS/UrlLib#26
- BabylonJS/AndroidExtensions#16
---------
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>1 parent 7371f11 commit d0926d4
2 files changed
Lines changed: 60 additions & 35 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
11 | 11 | | |
12 | 12 | | |
13 | 13 | | |
14 | | - | |
| 14 | + | |
15 | 15 | | |
16 | 16 | | |
17 | 17 | | |
| |||
37 | 37 | | |
38 | 38 | | |
39 | 39 | | |
40 | | - | |
| 40 | + | |
41 | 41 | | |
42 | 42 | | |
43 | 43 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | | - | |
| 1 | + | |
2 | 2 | | |
3 | 3 | | |
4 | 4 | | |
| |||
407 | 407 | | |
408 | 408 | | |
409 | 409 | | |
| 410 | + | |
| 411 | + | |
410 | 412 | | |
411 | 413 | | |
412 | 414 | | |
413 | 415 | | |
414 | 416 | | |
415 | 417 | | |
416 | 418 | | |
417 | | - | |
| 419 | + | |
| 420 | + | |
418 | 421 | | |
419 | 422 | | |
420 | 423 | | |
421 | 424 | | |
422 | 425 | | |
423 | 426 | | |
424 | | - | |
425 | 427 | | |
426 | 428 | | |
427 | | - | |
| 429 | + | |
428 | 430 | | |
| 431 | + | |
429 | 432 | | |
430 | 433 | | |
431 | 434 | | |
432 | | - | |
433 | | - | |
434 | | - | |
435 | | - | |
436 | | - | |
437 | | - | |
| 435 | + | |
| 436 | + | |
| 437 | + | |
| 438 | + | |
| 439 | + | |
| 440 | + | |
| 441 | + | |
438 | 442 | | |
| 443 | + | |
439 | 444 | | |
440 | 445 | | |
441 | | - | |
442 | | - | |
| 446 | + | |
| 447 | + | |
443 | 448 | | |
444 | 449 | | |
445 | 450 | | |
446 | 451 | | |
447 | 452 | | |
448 | 453 | | |
| 454 | + | |
449 | 455 | | |
450 | 456 | | |
451 | 457 | | |
| |||
457 | 463 | | |
458 | 464 | | |
459 | 465 | | |
460 | | - | |
| 466 | + | |
| 467 | + | |
461 | 468 | | |
462 | 469 | | |
463 | 470 | | |
464 | 471 | | |
465 | 472 | | |
466 | 473 | | |
467 | | - | |
468 | 474 | | |
469 | 475 | | |
470 | | - | |
| 476 | + | |
471 | 477 | | |
| 478 | + | |
472 | 479 | | |
473 | 480 | | |
474 | 481 | | |
475 | | - | |
476 | | - | |
477 | | - | |
| 482 | + | |
| 483 | + | |
| 484 | + | |
| 485 | + | |
| 486 | + | |
| 487 | + | |
| 488 | + | |
| 489 | + | |
| 490 | + | |
478 | 491 | | |
479 | | - | |
480 | | - | |
| 492 | + | |
| 493 | + | |
481 | 494 | | |
482 | 495 | | |
483 | 496 | | |
484 | | - | |
485 | | - | |
| 497 | + | |
| 498 | + | |
486 | 499 | | |
487 | 500 | | |
488 | 501 | | |
489 | 502 | | |
490 | 503 | | |
491 | 504 | | |
492 | | - | |
493 | 505 | | |
494 | 506 | | |
495 | | - | |
| 507 | + | |
496 | 508 | | |
| 509 | + | |
497 | 510 | | |
498 | 511 | | |
499 | 512 | | |
500 | | - | |
501 | | - | |
502 | | - | |
503 | | - | |
504 | | - | |
505 | | - | |
| 513 | + | |
| 514 | + | |
| 515 | + | |
| 516 | + | |
| 517 | + | |
| 518 | + | |
| 519 | + | |
506 | 520 | | |
| 521 | + | |
507 | 522 | | |
508 | 523 | | |
509 | | - | |
510 | | - | |
| 524 | + | |
| 525 | + | |
511 | 526 | | |
512 | 527 | | |
513 | 528 | | |
| |||
522 | 537 | | |
523 | 538 | | |
524 | 539 | | |
| 540 | + | |
525 | 541 | | |
526 | | - | |
| 542 | + | |
| 543 | + | |
| 544 | + | |
| 545 | + | |
| 546 | + | |
| 547 | + | |
| 548 | + | |
| 549 | + | |
| 550 | + | |
| 551 | + | |
527 | 552 | | |
528 | 553 | | |
529 | 554 | | |
| |||
0 commit comments