()
| 632 | } |
| 633 | |
| 634 | function checkLoaded() { |
| 635 | var err, usingPathFallback, |
| 636 | waitInterval = config.waitSeconds * 1000, |
| 637 | //It is possible to disable the wait interval by using waitSeconds of 0. |
| 638 | expired = waitInterval && (context.startTime + waitInterval) < new Date().getTime(), |
| 639 | noLoads = [], |
| 640 | reqCalls = [], |
| 641 | stillLoading = false, |
| 642 | needCycleCheck = true; |
| 643 | |
| 644 | //Do not bother if this call was a result of a cycle break. |
| 645 | if (inCheckLoaded) { |
| 646 | return; |
| 647 | } |
| 648 | |
| 649 | inCheckLoaded = true; |
| 650 | |
| 651 | //Figure out the state of all the modules. |
| 652 | eachProp(enabledRegistry, function (mod) { |
| 653 | var map = mod.map, |
| 654 | modId = map.id; |
| 655 | |
| 656 | //Skip things that are not enabled or in error state. |
| 657 | if (!mod.enabled) { |
| 658 | return; |
| 659 | } |
| 660 | |
| 661 | if (!map.isDefine) { |
| 662 | reqCalls.push(mod); |
| 663 | } |
| 664 | |
| 665 | if (!mod.error) { |
| 666 | //If the module should be executed, and it has not |
| 667 | //been inited and time is up, remember it. |
| 668 | if (!mod.inited && expired) { |
| 669 | if (hasPathFallback(modId)) { |
| 670 | usingPathFallback = true; |
| 671 | stillLoading = true; |
| 672 | } else { |
| 673 | noLoads.push(modId); |
| 674 | removeScript(modId); |
| 675 | } |
| 676 | } else if (!mod.inited && mod.fetched && map.isDefine) { |
| 677 | stillLoading = true; |
| 678 | if (!map.prefix) { |
| 679 | //No reason to keep looking for unfinished |
| 680 | //loading. If the only stillLoading is a |
| 681 | //plugin resource though, keep going, |
| 682 | //because it may be that a plugin resource |
| 683 | //is waiting on a non-plugin cycle. |
| 684 | return (needCycleCheck = false); |
| 685 | } |
| 686 | } |
| 687 | } |
| 688 | }); |
| 689 | |
| 690 | if (expired && noLoads.length) { |
| 691 | //If wait time expired, throw error of unloaded modules. |
no test coverage detected