Commit e2bcdce3 authored by Romain Courteaud's avatar Romain Courteaud

Propagate failure parameters.

parent 7e1d09df
...@@ -294,16 +294,23 @@ ...@@ -294,16 +294,23 @@
next_loading_gadget_deferred.resolve(gadget); next_loading_gadget_deferred.resolve(gadget);
}).fail(function () { }).fail(function () {
// One error during css/js loading // One error during css/js loading
next_loading_gadget_deferred.reject(); next_loading_gadget_deferred.reject.apply(
next_loading_gadget_deferred,
arguments
);
}); });
}).fail(function () { }).fail(function () {
// Failed to fetch dependencies information. // Failed to fetch dependencies information.
next_loading_gadget_deferred.reject(); next_loading_gadget_deferred.reject.apply(
next_loading_gadget_deferred,
arguments
);
}); });
}).fail(function () { }).fail(function () {
// Klass not correctly loaded. Reject instanciation // Klass not correctly loaded. Reject instanciation
next_loading_gadget_deferred.reject(); next_loading_gadget_deferred.reject.apply(next_loading_gadget_deferred,
arguments);
}); });
}); });
...@@ -561,8 +568,8 @@ ...@@ -561,8 +568,8 @@
dfr.reject(jqXHR, "Unexpected content type"); dfr.reject(jqXHR, "Unexpected content type");
} }
}) })
.fail(function (jqXHR, textStatus, errorThrown) { .fail(function () {
dfr.reject(jqXHR, textStatus, errorThrown); dfr.reject.apply(dfr, arguments);
}); });
} }
return dfr.promise(); return dfr.promise();
...@@ -744,7 +751,8 @@ ...@@ -744,7 +751,8 @@
gadget_loading_klass = undefined; gadget_loading_klass = undefined;
loading_gadget_deferred.resolve(); loading_gadget_deferred.resolve();
}).fail(function () { }).fail(function () {
loading_gadget_deferred.reject(); loading_gadget_deferred.reject.apply(loading_gadget_deferred,
arguments);
}); });
}); });
} }
......
...@@ -321,7 +321,9 @@ ...@@ -321,7 +321,9 @@
ok(false, "text/plain should fail"); ok(false, "text/plain should fail");
}) })
.fail(function (jqXHR, textStatus) { .fail(function (jqXHR, textStatus) {
equal("200", jqXHR.status); equal(jqXHR.status, "200");
equal(textStatus, "Unexpected content type");
equal(jqXHR.getResponseHeader("Content-Type"), "text/plain");
}) })
.always(function () { .always(function () {
start(); start();
...@@ -347,10 +349,11 @@ ...@@ -347,10 +349,11 @@
stop(); stop();
renderJS.declareGadgetKlass(url) renderJS.declareGadgetKlass(url)
.done(function () { .done(function () {
ok(false, "text/plain should fail"); ok(false, "Non parsable HTML should fail");
}) })
.fail(function (jqXHR, textStatus) { .fail(function (jqXHR, textStatus) {
equal("200", jqXHR.status); equal("200", jqXHR.status);
equal(textStatus, "HTML Parsing failed");
}) })
.always(function () { .always(function () {
mock.verify(); mock.verify();
...@@ -455,7 +458,7 @@ ...@@ -455,7 +458,7 @@
ok(false, "404 should fail"); ok(false, "404 should fail");
}) })
.fail(function (jqXHR, textStatus) { .fail(function (jqXHR, textStatus) {
equal("404", jqXHR.status); equal(jqXHR.status, "404");
}) })
.always(function () { .always(function () {
start(); start();
...@@ -474,7 +477,7 @@ ...@@ -474,7 +477,7 @@
ok(false, "404 should fail"); ok(false, "404 should fail");
}) })
.fail(function (jqXHR, textStatus) { .fail(function (jqXHR, textStatus) {
equal("404", jqXHR.status); equal(jqXHR.status, "404");
}) })
.always(function () { .always(function () {
start(); start();
...@@ -779,11 +782,34 @@ ...@@ -779,11 +782,34 @@
}); });
}); });
// test('clearGadgetKlassList leads to CSS reload', function () { test('clearGadgetKlassList leads to CSS reload', function () {
// // Check that declareCSS reload the CSS // Check that declareCSS reload the CSS
// // after clearGadgetKlassList is called // after clearGadgetKlassList is called
// ok(false, "not implemented"); var url = "data:text/css;base64," +
// }); window.btoa("#qunit-fixture {background-color: blue;}"),
count = $('head').find('link[rel=stylesheet]').length;
stop();
renderJS.declareCSS(url)
.done(function () {
renderJS.clearGadgetKlassList();
equal($('head').find('link[rel=stylesheet]').length, count + 1);
renderJS.declareCSS(url)
.done(function () {
equal($('head').find('link[rel=stylesheet]').length, count + 2);
})
.fail(function (jqXHR, textStatus) {
ok(false, "Failed to load " + textStatus + " " + jqXHR.status);
})
.always(function () {
start();
});
})
.fail(function (jqXHR, textStatus) {
ok(false, "Failed to load " + textStatus + " " + jqXHR.status);
start();
});
});
///////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////
// RenderJSGadget.getInterfaceList // RenderJSGadget.getInterfaceList
...@@ -1309,8 +1335,8 @@ ...@@ -1309,8 +1335,8 @@
.done(function (new_gadget) { .done(function (new_gadget) {
ok(false); ok(false);
}) })
.fail(function () { .fail(function (jqXHR, textStatus) {
ok(true); equal("404", jqXHR.status);
}) })
.always(function () { .always(function () {
start(); start();
...@@ -1340,8 +1366,9 @@ ...@@ -1340,8 +1366,9 @@
.done(function (new_gadget) { .done(function (new_gadget) {
ok(false); ok(false);
}) })
.fail(function () { .fail(function (jqXHR, textStatus) {
ok(true); equal(jqXHR.status, 404);
equal(textStatus, "error");
}) })
.always(function () { .always(function () {
start(); start();
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment