Skip to content

Edge case where {}.hasOwnProperty throws #1104

@brian-mann

Description

@brian-mann

(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!

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions