Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Edge case where {}.hasOwnProperty throws #1104

Closed
brian-mann opened this issue May 16, 2016 · 0 comments
Closed

Edge case where {}.hasOwnProperty throws #1104

brian-mann opened this issue May 16, 2016 · 0 comments

Comments

@brian-mann
Copy link

(This issue tracker is only for bug reports or feature requests, if this is neither, please choose appropriate channel from http://bluebirdjs.com/docs/support.html)

Please answer the questions the best you can:

  1. What version of bluebird is the issue happening on? latest

  2. What platform and version? (For example Node.js 0.12 or Google Chrome 32) Chrome 50

  3. Did this issue happen with earlier version of bluebird? yes

(Write description of your issue here, stack traces from errors and code that reproduces the issue are helpful)

There is an edge case with hasOwnProperty throwing a DOMException.

This function https://github.com/petkaantonov/bluebird/blob/master/src/thenables.js#L51 needs to be inside a try / catch like this:

var hasProp = {}.hasOwnProperty;
function isAnyBluebirdPromise(obj) {
    try {
      return hasProp.call(obj, "_promise0");
    } catch (err) {
      return false;
    }
}

We have situations where objects like Storage are getting passed here and will throw.

Uncaught DOMException: Failed to read the '_promise0' property from 'Storage': access is denied for this document.

A simple try / catch with the catch handler returning false would do the trick!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants