Skip to content

Fix Raven.js throwing exception when run in Selenium (fixes #495) #500

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

Merged
merged 1 commit into from
Feb 9, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion src/raven.js
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,14 @@ Raven.prototype = {
}

// We don't wanna wrap it twice!
if (func.__raven__) {
try {
if (func.__raven__) {
return func;
}
} catch (e) {
// Just accessing the __raven__ prop in some Selenium environments
// can cause a "Permission denied" exception (see raven-js#495).
// Bail on wrapping and return the function as-is (defers to window.onerror).
return func;
}

Expand Down
13 changes: 13 additions & 0 deletions test/raven.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -1729,6 +1729,19 @@ describe('Raven (public API)', function() {
}, error);
});

it('should return input funciton as-is if accessing __raven__ prop throws exception', function (){
// see raven-js#495
var fn = function () {};
Object.defineProperty(fn, '__raven__', {
get: function () {
throw new Error('Permission denied')
}
});
assert.throw(function () { fn.__raven__; }, 'Permission denied');
var wrapped = Raven.wrap(fn);
assert.equal(fn, wrapped);
});

});

describe('.context', function() {
Expand Down