| @@ -456,8 +456,9 @@ | ||
| 456 | 456 | function one() { |
| 457 | 457 | if (settled) return; |
| 458 | 458 | settled = 1; |
| 459 | 459 | clearTimeout(timer); |
| 460 | + if (!cap && !phase) armDeadline(); | |
| 460 | 461 | if (inPhase === phase) done(); |
| 461 | 462 | } |
| 462 | 463 | script.addEventListener('load', one); |
| 463 | 464 | script.addEventListener('error', one); |
| @@ -483,13 +484,25 @@ | ||
| 483 | 484 | }); |
| 484 | 485 | }); |
| 485 | 486 | if (observer) observer.observe(document.documentElement, { childList: true, subtree: true }); |
| 486 | 487 | |
| 487 | - // A server that never answers does not hold the events past 15s. | |
| 488 | - deadline = setTimeout(function () { | |
| 489 | - pending = 1; | |
| 490 | - done(); | |
| 491 | - }, 15000); | |
| 488 | + // A server that never answers does not hold DOMContentLoaded past 15s | |
| 489 | + // with no progress. Each replayed external that loads or fails in the | |
| 490 | + // first phase restarts the 15s, so the whole wait is at most 15s per | |
| 491 | + // external. A fixed 15s from the first interaction sent the events while | |
| 492 | + // a slow connection was still bringing in jQuery and the builder scripts, | |
| 493 | + // and those then missed them for good. An injected script has its own 1s | |
| 494 | + // cap and restarts nothing: the observer also sees the page's own | |
| 495 | + // scripts, and a page that keeps adding them (an ad refresh, a carousel | |
| 496 | + // cloning a slide with a script in it) would hold the events forever. | |
| 497 | + function armDeadline() { | |
| 498 | + clearTimeout(deadline); | |
| 499 | + deadline = setTimeout(function () { | |
| 500 | + pending = 1; | |
| 501 | + done(); | |
| 502 | + }, 15000); | |
| 503 | + } | |
| 504 | + armDeadline(); | |
| 492 | 505 | |
| 493 | 506 | // An inline module evaluates asynchronously but fires no load (the spec |
| 494 | 507 | // fires it only for scripts from a URL), so its replayed text starts and |
| 495 | 508 | // ends with a line that dispatches xs-mod with its index, and the end is |