Load error handling doesn't depend on browser features, so test it everywher
[#24901981]
This commit is contained in:
@@ -2018,65 +2018,61 @@ describe("Env integration", function() {
|
|||||||
env.execute();
|
env.execute();
|
||||||
});
|
});
|
||||||
|
|
||||||
describe("In a browser", function() {
|
it('reports errors that occur during loading', function(done) {
|
||||||
if (typeof document !== 'undefined') {
|
var global = {
|
||||||
it('reports errors that occur during loading', function(done) {
|
setTimeout: function(fn, delay) { setTimeout(fn, delay) },
|
||||||
var global = {
|
clearTimeout: function(fn, delay) { clearTimeout(fn, delay) },
|
||||||
setTimeout: function(fn, delay) { setTimeout(fn, delay) },
|
};
|
||||||
clearTimeout: function(fn, delay) { clearTimeout(fn, delay) },
|
spyOn(jasmineUnderTest, 'getGlobal').and.returnValue(global);
|
||||||
};
|
|
||||||
spyOn(jasmineUnderTest, 'getGlobal').and.returnValue(global);
|
|
||||||
|
|
||||||
var env = new jasmineUnderTest.Env(),
|
var env = new jasmineUnderTest.Env(),
|
||||||
reporter = jasmine.createSpyObj('reporter', ['jasmineDone', 'suiteDone', 'specDone']);
|
reporter = jasmine.createSpyObj('reporter', ['jasmineDone', 'suiteDone', 'specDone']);
|
||||||
|
|
||||||
reporter.jasmineDone.and.callFake(function(e) {
|
reporter.jasmineDone.and.callFake(function(e) {
|
||||||
expect(e.failedExpectations).toEqual([
|
expect(e.failedExpectations).toEqual([
|
||||||
{
|
{
|
||||||
passed: false,
|
passed: false,
|
||||||
globalErrorType: 'load',
|
globalErrorType: 'load',
|
||||||
message: 'Uncaught SyntaxError: Unexpected end of input'
|
message: 'Uncaught SyntaxError: Unexpected end of input'
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
passed: false,
|
passed: false,
|
||||||
globalErrorType: 'load',
|
globalErrorType: 'load',
|
||||||
message: 'Uncaught Error: ENOCHEESE'
|
message: 'Uncaught Error: ENOCHEESE'
|
||||||
}
|
}
|
||||||
]);
|
]);
|
||||||
|
|
||||||
done();
|
done();
|
||||||
});
|
});
|
||||||
|
|
||||||
env.addReporter(reporter);
|
env.addReporter(reporter);
|
||||||
global.onerror('Uncaught SyntaxError: Unexpected end of input');
|
global.onerror('Uncaught SyntaxError: Unexpected end of input');
|
||||||
global.onerror('Uncaught Error: ENOCHEESE');
|
global.onerror('Uncaught Error: ENOCHEESE');
|
||||||
|
|
||||||
env.execute();
|
env.execute();
|
||||||
|
});
|
||||||
|
|
||||||
|
describe('If suppressLoadErrors was called', function() {
|
||||||
|
it('does not report errors that occur during loading', function(done) {
|
||||||
|
var global = {
|
||||||
|
setTimeout: function(fn, delay) { setTimeout(fn, delay) },
|
||||||
|
clearTimeout: function(fn, delay) { clearTimeout(fn, delay) },
|
||||||
|
};
|
||||||
|
spyOn(jasmineUnderTest, 'getGlobal').and.returnValue(global);
|
||||||
|
|
||||||
|
var env = new jasmineUnderTest.Env(),
|
||||||
|
reporter = jasmine.createSpyObj('reporter', ['jasmineDone', 'suiteDone', 'specDone']);
|
||||||
|
|
||||||
|
reporter.jasmineDone.and.callFake(function(e) {
|
||||||
|
expect(e.failedExpectations).toEqual([]);
|
||||||
|
done();
|
||||||
});
|
});
|
||||||
}
|
|
||||||
|
|
||||||
describe('If suppressLoadErrors was called', function() {
|
env.addReporter(reporter);
|
||||||
it('does not report errors that occur during loading', function(done) {
|
env.suppressLoadErrors(true);
|
||||||
var global = {
|
global.onerror('Uncaught Error: ENOCHEESE');
|
||||||
setTimeout: function(fn, delay) { setTimeout(fn, delay) },
|
|
||||||
clearTimeout: function(fn, delay) { clearTimeout(fn, delay) },
|
|
||||||
};
|
|
||||||
spyOn(jasmineUnderTest, 'getGlobal').and.returnValue(global);
|
|
||||||
|
|
||||||
var env = new jasmineUnderTest.Env(),
|
env.execute();
|
||||||
reporter = jasmine.createSpyObj('reporter', ['jasmineDone', 'suiteDone', 'specDone']);
|
|
||||||
|
|
||||||
reporter.jasmineDone.and.callFake(function(e) {
|
|
||||||
expect(e.failedExpectations).toEqual([]);
|
|
||||||
done();
|
|
||||||
});
|
|
||||||
|
|
||||||
env.addReporter(reporter);
|
|
||||||
env.suppressLoadErrors(true);
|
|
||||||
global.onerror('Uncaught Error: ENOCHEESE');
|
|
||||||
|
|
||||||
env.execute();
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user