Skip to content

Commit

Permalink
Updated tests to better detect problems with slow async and fast sync…
Browse files Browse the repository at this point in the history
… loads of the same module.
  • Loading branch information
micmath committed Jul 13, 2009
1 parent 9a051ac commit 09e007d
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 14 deletions.
6 changes: 6 additions & 0 deletions test/gloader_async_sync.html
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,11 @@
</script>

<script type="text/javascript">
// make the asynchronous call go slow
// we want to force the case where the second synchronous load
// completes before the first synchronous load
window.withDelay = true;

gloader.load(["glow", "1.0.0", "glow.widgets.Panel"], {
async: true,
onload: function(glow) {
Expand All @@ -44,6 +49,7 @@
</script>

<script type="text/javascript">
window.withDelay = false;
gloader.load(["glow", "1.0.0", "glow.widgets.Panel"]);
</script>

Expand Down
6 changes: 4 additions & 2 deletions test/live_gloader_async_sync.html
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,12 @@
}
);

gloader.settings.clear("override");
gloader.settings.clear("debug");
//gloader.settings.clear("override");
//gloader.settings.clear("debug");
</script>

<script type="text/javascript">
console.log("loading [glow, 1, glow.dom]");
gloader.load(
["glow", "1", "glow.dom"]
,
Expand All @@ -43,6 +44,7 @@
</script>

<script type="text/javascript">
console.log("loading [glow, 1]");
gloader.load(["glow", "1"]);
</script>

Expand Down
30 changes: 18 additions & 12 deletions test/mock/glow/1.0.0/widgets/widgets.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,21 @@ gloader.module({
}
});

gloader.module({
name: 'glow.widgets.Panel',
library: ['glow', '1.0.0'],
depends: [
['glow', '1.0.0', 'glow.widgets']
],

builder: function(glow) {
glow.widgets.Panel = function() {
};
}
});
function createModule() {
gloader.module({
name: 'glow.widgets.Panel',
library: ['glow', '1.0.0'],
depends: [
['glow', '1.0.0', 'glow.widgets']
],

builder: function(glow) {
glow.widgets.Panel = function() {
};
}
});
}

// simulate a slow network connection?
if (window.withDelay) { setTimeout(createModule, 1000); }
else createModule();

0 comments on commit 09e007d

Please sign in to comment.