Simulated asynch environment for JavaScript
Create a new bobble with some asynchronous behavior.
var bobble = new Bobble("
var a = false;
setTimeout(function() { a = true; }, 100);
advanceToTime(100);
console.log(a);
");
Within the bobble time can be manually advanced using advanceToTime to execute scheduled events. You can advanceToTime with the same value to trigger instantaneous events like those scheduled by postMessage
The time covered advanceToTime is treated as though the JavaScript thread was busy during the interval. This means that intervals that would have fired multiple times within that interval will fire only once.
Ask the bobble to execute its payload.
bobble.run();
Inside the bobble, time-dependent asynchronous JavaScript is executed synchronously, and the passage of time is metered out manually. The system simulates:
- setTimeout
- setInterval
- clearTimeout
- clearInterval
- postMessage
- window.addEventListener('message', receiver)
- Date