mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-11 20:35:50 +00:00
Bug 940217 - Fix error report about StopIteration promise (r=Yoric)
This commit is contained in:
parent
14f35ba0ec
commit
515206e74f
@ -880,7 +880,7 @@ let DirectoryIterator = function DirectoryIterator(path, options) {
|
||||
* @rejects {StopIteration} If all entries have already been visited
|
||||
* or the iterator has been closed.
|
||||
*/
|
||||
this._itmsg = Scheduler.post(
|
||||
this.__itmsg = Scheduler.post(
|
||||
"new_DirectoryIterator", [Type.path.toMsg(path), options],
|
||||
path
|
||||
);
|
||||
@ -890,6 +890,17 @@ DirectoryIterator.prototype = {
|
||||
iterator: function () this,
|
||||
__iterator__: function () this,
|
||||
|
||||
// Once close() is called, _itmsg should reject with a
|
||||
// StopIteration. However, we don't want to create the promise until
|
||||
// it's needed because it might never be used. In that case, we
|
||||
// would get a warning on the console.
|
||||
get _itmsg() {
|
||||
if (!this.__itmsg) {
|
||||
this.__itmsg = Promise.reject(StopIteration);
|
||||
}
|
||||
return this.__itmsg;
|
||||
},
|
||||
|
||||
/**
|
||||
* Determine whether the directory exists.
|
||||
*
|
||||
@ -1029,7 +1040,9 @@ DirectoryIterator.prototype = {
|
||||
let self = this;
|
||||
return this._itmsg.then(
|
||||
function withIterator(iterator) {
|
||||
self._itmsg = Promise.reject(StopIteration);
|
||||
// Set __itmsg to null so that the _itmsg getter returns a
|
||||
// rejected StopIteration promise if it's ever used.
|
||||
self.__itmsg = null;
|
||||
return Scheduler.post("DirectoryIterator_prototype_close", [iterator]);
|
||||
}
|
||||
);
|
||||
|
Loading…
Reference in New Issue
Block a user