Bug 1193526 - Handle image.src being invalid. r=jgilbert

MozReview-Commit-ID: IhTC5kkiBu5
This commit is contained in:
Morris Tseng 2016-04-27 11:55:45 +08:00
Родитель 53a7c08931
Коммит 455022580c
3 изменённых файлов: 30 добавлений и 11 удалений

Просмотреть файл

@ -48,7 +48,15 @@ function generateTest(pixelFormat, pixelType, pathToTestRoot, prologue) {
textureLoc = gl.getUniformLocation(program, "tex"); textureLoc = gl.getUniformLocation(program, "tex");
wtu.loadTexture(gl, pathToTestRoot + "/resources/red-green.png", runTest); var image = new Image();
image.onload = function() {
runTest(image);
};
image.onerror = function() {
testFailed("Creating image from canvas failed. Image src: " + this.src);
finishTest();
};
image.src = pathToTestRoot + "/resources/red-green.png";
} }
function runOneIteration(image, useTexSubImage2D, flipY, topColor, bottomColor) function runOneIteration(image, useTexSubImage2D, flipY, topColor, bottomColor)

Просмотреть файл

@ -48,7 +48,15 @@ function generateTest(pixelFormat, pixelType, pathToTestRoot, prologue) {
textureLoc = gl.getUniformLocation(program, "tex"); textureLoc = gl.getUniformLocation(program, "tex");
wtu.loadTexture(gl, pathToTestRoot + "/resources/red-green.svg", runTest); var image = new Image();
image.onload = function() {
runTest(image);
};
image.onerror = function() {
testFailed("Creating image from canvas failed. Image src: " + this.src);
finishTest();
};
image.src = pathToTestRoot + "/resources/red-green.svg";
} }
function runOneIteration(image, useTexSubImage2D, flipY, topColor, bottomColor) function runOneIteration(image, useTexSubImage2D, flipY, topColor, bottomColor)

Просмотреть файл

@ -1147,6 +1147,9 @@ var loadTexture = function(gl, url, callback) {
gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, gl.RGBA, gl.UNSIGNED_BYTE, image); gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, gl.RGBA, gl.UNSIGNED_BYTE, image);
callback(image); callback(image);
}; };
image.onerror = function() {
throw new Error('Failed to load image at: ' + image.src);
};
image.src = url; image.src = url;
return texture; return texture;
}; };