1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/content/canvas/test/webgl-conformance/resources/cors-util.js Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,31 @@ 1.4 +/* This Source Code Form is subject to the terms of the Mozilla Public 1.5 + * License, v. 2.0. If a copy of the MPL was not distributed with this 1.6 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 1.7 + 1.8 +function getExampleDotComURL(conformanceDirRelativePath) { 1.9 + var prefix = 'http://example.com/tests/content/canvas/test/webgl-conformance/'; 1.10 + return prefix + conformanceDirRelativePath; 1.11 +} 1.12 + 1.13 +function setExampleDotComImage(imageElemID, imagePath, relPathToBase, onLoadCallback) { 1.14 + var img = document.getElementById(imageElemID); 1.15 + if (!img) 1.16 + throw 'Bad `imageElemID`: ' + imageElemID; 1.17 + 1.18 + if (onLoadCallback) 1.19 + img.onload = onLoadCallback; 1.20 + 1.21 + img.onerror = function() { 1.22 + console.log('Failed to load image from: ' + img.src); 1.23 + console.log('Loading same-domain backup image.'); 1.24 + 1.25 + img.onerror = function() { 1.26 + console.log('Failed to load backup image from: ' + img.src); 1.27 + return; 1.28 + }; 1.29 + 1.30 + img.src = relPathToBase + imagePath; 1.31 + }; 1.32 + 1.33 + img.src = getExampleDotComURL(imagePath); 1.34 +}