test_fallback.js 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. runTests([
  2. // Test 1
  3. function() {
  4. var count = 0;
  5. SVGInject.create('SVGInject1', {
  6. afterLoad: fail,
  7. onFail: function(img, status) {
  8. if (status === 'SVG_NOT_SUPPORTED') {
  9. ++count;
  10. if (count > 9) {
  11. fail();
  12. } else if (count == 9) {
  13. success();
  14. }
  15. } else {
  16. fail();
  17. }
  18. }
  19. });
  20. },
  21. // Test 2
  22. function() {
  23. var count = 0;
  24. SVGInject.create('SVGInject2', {
  25. afterLoad: fail,
  26. onFail: function(img, status) {
  27. if (status === 'SVG_NOT_SUPPORTED') {
  28. img.src = img.src.slice(0, -4) + ".png";
  29. ++count;
  30. if (count > 9) {
  31. fail();
  32. } else if (count == 9) {
  33. success();
  34. }
  35. } else {
  36. fail();
  37. }
  38. }
  39. });
  40. },
  41. // Test 3
  42. function() {
  43. var count = 0;
  44. SVGInject.create('SVGInject3', {
  45. afterLoad: fail,
  46. onFail: function(img, status) {
  47. if (status === 'SVG_NOT_SUPPORTED') {
  48. img.src = img.src.slice(0, -4) + ".png";
  49. ++count;
  50. if (count > 9) {
  51. fail();
  52. } else if (count == 9) {
  53. success();
  54. }
  55. } else {
  56. fail();
  57. }
  58. }
  59. });
  60. domReady(function() {
  61. SVGInject3(document.getElementById('test-3').getElementsByTagName('img'));
  62. });
  63. },
  64. // Test 4
  65. function() {
  66. var count = 0;
  67. SVGInject.create('SVGInject4', {
  68. beforeLoad: fail,
  69. afterLoad: fail,
  70. beforeInject: fail,
  71. afterInject: fail,
  72. onFail: function(img, status) {
  73. if (status === 'SVG_NOT_SUPPORTED') {
  74. if (++count == 6) {
  75. success();
  76. } else if (count > 6) {
  77. fail();
  78. }
  79. } else {
  80. fail();
  81. }
  82. }
  83. });
  84. }
  85. ]);