Skip to content
This repository has been archived by the owner on Mar 13, 2018. It is now read-only.

Commit

Permalink
Make the window.onerror test more resilient to old browsers
Browse files Browse the repository at this point in the history
Check the number of arguments passed to window.onerror before
asserting the value of the argument.
  • Loading branch information
arv committed Apr 8, 2014
1 parent a86a1b9 commit 3171298
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions test/js/events.js
Original file line number Diff line number Diff line change
Expand Up @@ -1391,19 +1391,26 @@ test('retarget order (multiple shadow roots)', function() {
var msg = 'Intentional error';
var errorCount = 0;

window.onerror = function(msg, source, lineNumber, columnNumber, error) {
window.onerror = function(msg, source, lineNumber, columnNumber, err) {
document.removeEventListener('click', f);
window.onerror = old;
assert.isTrue(msg.indexOf(msg) >= 0);
assert.typeOf(source, 'string');
assert.typeOf(lineNumber, 'number');
assert.typeOf(columnNumber, 'number');
// error is not available in IE11.
// Firefox 28 does not pass the columnNumber, error
// Safari 6 does not pass the columnNumber, error
// IE11 does not pass the error
if (arguments.length >= 4)
assert.typeOf(columnNumber, 'number');
if (arguments.length >= 5)
assert.equal(err, error);

errorCount++;
};

var error = new Error(msg);
document.addEventListener('click', f = function(e) {
throw new Error(msg);
throw error;
});

document.body.click();
Expand Down

0 comments on commit 3171298

Please sign in to comment.