diff -r 000000000000 -r 6474c204b198 content/canvas/test/webgl-conformance/resources/cors-util.js --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/content/canvas/test/webgl-conformance/resources/cors-util.js Wed Dec 31 06:09:35 2014 +0100 @@ -0,0 +1,31 @@ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +function getExampleDotComURL(conformanceDirRelativePath) { + var prefix = 'http://example.com/tests/content/canvas/test/webgl-conformance/'; + return prefix + conformanceDirRelativePath; +} + +function setExampleDotComImage(imageElemID, imagePath, relPathToBase, onLoadCallback) { + var img = document.getElementById(imageElemID); + if (!img) + throw 'Bad `imageElemID`: ' + imageElemID; + + if (onLoadCallback) + img.onload = onLoadCallback; + + img.onerror = function() { + console.log('Failed to load image from: ' + img.src); + console.log('Loading same-domain backup image.'); + + img.onerror = function() { + console.log('Failed to load backup image from: ' + img.src); + return; + }; + + img.src = relPathToBase + imagePath; + }; + + img.src = getExampleDotComURL(imagePath); +}