var httpserver = new HttpServer(); var httpserver2 = new HttpServer(); var httpserver3 = new HttpServer(); var testpath = "/simple"; var redirectpath = "/redirect"; var negativetestpath = "/negative"; var httpbody = "<?xml version='1.0' ?><root>0123456789</root>";
// Test sync XHR sending
Cu.evalInSandbox('var createXHR = ' + createXHR.toString(), sb); var res = Cu.evalInSandbox('var sync = createXHR("4444/simple"); sync.send(null); sync', sb); Assert.ok(checkResults(res));
var principal = res.responseXML.nodePrincipal; Assert.ok(principal.isContentPrincipal); var requestURL = "http://localhost:4444/redirect"; Assert.equal(principal.spec, requestURL);
// negative test sync XHR sending (to ensure that the xhr do not have chrome caps, see bug 779821) try {
Cu.evalInSandbox('var createXHR = ' + createXHR.toString(), sb); var res = Cu.evalInSandbox('var sync = createXHR("4445/negative"); sync.send(null); sync', sb); Assert.equal(false, true, "XHR created from sandbox should not have chrome caps");
} catch (e) { Assert.ok(true);
}
// Test redirect handling. // This request bounces to server 2 and then back to server 1. Neither of // these servers support CORS, but if the expanded principal is used as the // triggering principal, this should work.
Cu.evalInSandbox('var createXHR = ' + createXHR.toString(), sb); var res = Cu.evalInSandbox('var sync = createXHR("4444/redirect"); sync.send(null); sync', sb); Assert.ok(checkResults(res));
var principal = res.responseXML.nodePrincipal; Assert.ok(principal.isContentPrincipal); var requestURL = "http://localhost:4444/redirect"; Assert.equal(principal.spec, requestURL);
// Test async XHR sending
sb.finish = function(){
httpserver.stop(finishIfDone);
}
// We want to execute checkResults from the scope of the sandbox as well to // make sure that there are no permission errors related to nsEP. For that // we need to clone the function into the sandbox and make a few things // available for it.
Cu.evalInSandbox('var checkResults = ' + checkResults.toSource(), sb);
sb.equal = equal;
sb.httpbody = httpbody;
function changeListener(event) { if (checkResults(async))
finish();
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.