blob: 633f4e9d4a735cd453aaf56302a6ba4f5ff79ce2 [file] [log] [blame]
importScripts('../../../resources/js-test.js');
self.jsTestIsAsync = true;
description('Test createImageBitmap with invalid arguments in workers.');
var reason;
function shouldBeRejected(promise, message) {
return promise.then(function() {
testFailed('Resolved unexpectedly: ' + message);
}, function(e) {
reason = e;
testPassed('Rejected as expected: ' + message);
shouldBeTrue('reason instanceof Error');
debug(String(e));
});
}
var data;
self.addEventListener('message', function(e) {
data = e.data;
Promise.resolve().then(function() {
return shouldBeRejected(createImageBitmap(null, 0, 0, 10, 10), 'null');
}).then(function() {
return shouldBeRejected(createImageBitmap(data, 0, 0, 10, 0), 'invalid area');
}).then(function() {
return shouldBeRejected(createImageBitmap(data, 0, 0, 0, 10), 'invalid area');
}).catch(function(e) {
testFailed('Unexpected rejection: ' + e);
}).then(finishJSTest, finishJSTest);
});