MCPcopy Create free account
hub / github.com/Yaffle/EventSource / otherTests

Function otherTests

tests/tests.js:385–683  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

383 mainTests();
384
385 var otherTests = function () {
386 var getURL = function (protocol, credentials) {
387 return protocol + "//" + credentials + location.hostname + ":" + location.port + location.pathname.split("/").slice(0, -1).join("/") + "/events";
388 };
389 var url4CORS = getURL(location.protocol === "https:" ? "http:" : "https");
390 var urlWithAuthorization = getURL(location.protocol, "user012:pass012");
391
392 // try with native EventSource in Opera 12
393 asyncTest("URL with username and password for Basic Authorization", function () {
394 var es = undefined;
395 try {
396 es = new EventSource(urlWithAuthorization + "?authorization=true&estest=" + encodeURIComponent(commonHeaders + "\n\n" + "\ndata:<authorization>\n\n"));
397 } catch (error) {
398 if (global.console != undefined) {
399 global.console.log(error);
400 }
401 }
402 if (es != undefined) {
403 es.onmessage = function (event) {
404 var data = event.data;
405 ok(data === "Basic dXNlcjAxMjpwYXNzMDEy", data); // window.btoa("user012:pass012")
406 es.close();
407 start();
408 };
409 es.onerror = function (event) {
410 ok(false, "failed");
411 es.close();
412 start();
413 };
414 } else {
415 ok(false, "failed");
416 start();
417 }
418 });
419
420 asyncTest("blob: URL", function () {
421 if (global.URL != undefined) {
422 var es = new EventSource(global.URL.createObjectURL(new global.Blob(["retry:1000\ndata:1\n\n"], {
423 type: "text/event-stream;charset=utf-8"
424 })));
425 var message = "";
426 es.onmessage = function (event) {
427 message = event.data;
428 };
429 es.onerror = function (event) {
430 ok(message === "1" && es.readyState === EventSource.CONNECTING, "failed");
431 es.close();
432 start();
433 };
434 } else {
435 ok(false, "failed");
436 start();
437 }
438 });
439
440 asyncTest("data: URL", function () {
441 var es = undefined;
442 try {

Callers 1

tests.jsFile · 0.85

Calls 4

getURLFunction · 0.85
handler2Function · 0.85
startFunction · 0.70
aFunction · 0.70

Tested by

no test coverage detected