【发布时间】:2015-03-02 01:57:41
【问题描述】:
我只是好奇 CasperJS 如何处理与调用堆栈有关的事件。
假设我们有一些代码:
casper.on('foo', function() {
this.wait(60000);
this.echo('foo');
});
casper.start('http://www.stackoverflow.com', function() {
this.echo('start');
this.emit('foo');
});
casper.then(function() {
this.echo('done');
});
casper.run();
我知道 then() 将等待检查 3 flags:pendingWait、loadInProgress 和 navigationRequested。打印出调用堆栈显示发出调用在函数 start() 中,所以在事件完成之前不会认为 start() 完成? IE。将 then() 等到事件完成
我用 60 秒的等待时间对此进行了测试,我确实得到了输出:
start
foo
done
虽然我不确定超过某个超时是否会触发下一个 then()。
【问题讨论】:
标签: javascript events casperjs callstack