Merge pull request #4826 from dferer/localstorage-exceptions
Wrapped localstorage.setItem in try block to avoid uncaught exceptions.
This commit is contained in:
commit
fb74b02218
@ -1011,7 +1011,7 @@ PDFJS.createPromiseCapability = createPromiseCapability;
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Polyfill for Promises:
|
* Polyfill for Promises:
|
||||||
* The following promise implementation tries to generally implment the
|
* The following promise implementation tries to generally implement the
|
||||||
* Promise/A+ spec. Some notable differences from other promise libaries are:
|
* Promise/A+ spec. Some notable differences from other promise libaries are:
|
||||||
* - There currently isn't a seperate deferred and promise object.
|
* - There currently isn't a seperate deferred and promise object.
|
||||||
* - Unhandled rejections eventually show an error if they aren't handled.
|
* - Unhandled rejections eventually show an error if they aren't handled.
|
||||||
@ -1057,6 +1057,11 @@ PDFJS.createPromiseCapability = createPromiseCapability;
|
|||||||
});
|
});
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
if (typeof globalScope.Promise.prototype.catch !== 'function') {
|
||||||
|
globalScope.Promise.prototype.catch = function (onReject) {
|
||||||
|
return globalScope.Promise.prototype.then(undefined, onReject);
|
||||||
|
};
|
||||||
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
//#if !MOZCENTRAL
|
//#if !MOZCENTRAL
|
||||||
@ -1180,7 +1185,11 @@ PDFJS.createPromiseCapability = createPromiseCapability;
|
|||||||
function Promise(resolver) {
|
function Promise(resolver) {
|
||||||
this._status = STATUS_PENDING;
|
this._status = STATUS_PENDING;
|
||||||
this._handlers = [];
|
this._handlers = [];
|
||||||
resolver.call(this, this._resolve.bind(this), this._reject.bind(this));
|
try {
|
||||||
|
resolver.call(this, this._resolve.bind(this), this._reject.bind(this));
|
||||||
|
} catch (e) {
|
||||||
|
this._reject(e);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* Builds a promise that is resolved when all the passed in promises are
|
* Builds a promise that is resolved when all the passed in promises are
|
||||||
@ -1307,6 +1316,10 @@ PDFJS.createPromiseCapability = createPromiseCapability;
|
|||||||
});
|
});
|
||||||
HandlerManager.scheduleHandlers(this);
|
HandlerManager.scheduleHandlers(this);
|
||||||
return nextPromise;
|
return nextPromise;
|
||||||
|
},
|
||||||
|
|
||||||
|
catch: function Promise_catch(onReject) {
|
||||||
|
return this.then(undefined, onReject);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -101,7 +101,7 @@ var ViewHistory = (function ViewHistoryClosure() {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
this.file[name] = val;
|
this.file[name] = val;
|
||||||
this._writeToStorage();
|
return this._writeToStorage();
|
||||||
},
|
},
|
||||||
|
|
||||||
setMultiple: function ViewHistory_setMultiple(properties) {
|
setMultiple: function ViewHistory_setMultiple(properties) {
|
||||||
@ -111,7 +111,7 @@ var ViewHistory = (function ViewHistoryClosure() {
|
|||||||
for (var name in properties) {
|
for (var name in properties) {
|
||||||
this.file[name] = properties[name];
|
this.file[name] = properties[name];
|
||||||
}
|
}
|
||||||
this._writeToStorage();
|
return this._writeToStorage();
|
||||||
},
|
},
|
||||||
|
|
||||||
get: function ViewHistory_get(name, defaultValue) {
|
get: function ViewHistory_get(name, defaultValue) {
|
||||||
|
@ -1983,6 +1983,8 @@ function updateViewarea() {
|
|||||||
'zoom': normalizedScaleValue,
|
'zoom': normalizedScaleValue,
|
||||||
'scrollLeft': intLeft,
|
'scrollLeft': intLeft,
|
||||||
'scrollTop': intTop
|
'scrollTop': intTop
|
||||||
|
}).catch(function() {
|
||||||
|
// unable to write to storage
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
var href = PDFView.getAnchorUrl(pdfOpenParams);
|
var href = PDFView.getAnchorUrl(pdfOpenParams);
|
||||||
|
Loading…
Reference in New Issue
Block a user