Permalink
Browse files

Detect broken CORS image implementation and warn about it.

  • Loading branch information...
1 parent 02c8cab commit 96f5a5d83a8aad24a1d3bc15acbb756f430a0532 @kg kg committed Aug 27, 2012
Showing with 16 additions and 4 deletions.
  1. +12 −2 Libraries/JSIL.Browser.Loaders.js
  2. +4 −2 Libraries/JSIL.Browser.js
@@ -206,6 +206,8 @@ function loadBinaryFileAsync (uri, onComplete) {
});
}
+var warnedAboutCORSImage = false;
+
var assetLoaders = {
"Library": function loadLibrary (filename, data, onError, onDoneLoading, state) {
loadTextAsync(jsilConfig.libraryRoot + filename, function (result, error) {
@@ -241,8 +243,16 @@ var assetLoaders = {
},
"Image": function loadImage (filename, data, onError, onDoneLoading) {
var e = document.createElement("img");
- // CORS is so dumb
- e.crossOrigin = "anonymous";
+ if (jsilConfig.CORS) {
+ if ("crossOrigin" in e) {
+ e.crossOrigin = "";
+ } else {
+ if (!warnedAboutCORSImage) {
+ JSIL.Host.logWriteLine("WARNING: This game requires support for CORS, and your browser does not support it for images.");
+ warnedAboutCORSImage = true;
+ }
+ }
+ }
var finisher = function () {
$jsilbrowserstate.allAssetNames.push(filename);
@@ -504,8 +504,9 @@ function finishLoading () {
updateProgressBar("Loading " + item[3], null, state.assetsFinished, state.assetCount);
- if (typeof (cb) === "function")
+ if (typeof (cb) === "function") {
cb(state);
+ }
} finally {
state.finishIndex += 1;
state.assetsFinished += 1;
@@ -662,7 +663,8 @@ function loadAssets (assets, onDoneLoading) {
finishIndex: 0,
pendingScriptLoads: 0,
jsilInitialized: false,
- assetsLoadingNames: {}
+ assetsLoadingNames: {},
+ failedFinishes: 0
};
for (var i = 0, l = assets.length; i < l; i++) {

0 comments on commit 96f5a5d

Please sign in to comment.