PageRenderTime 54ms CodeModel.GetById 21ms RepoModel.GetById 0ms app.codeStats 0ms

/src/flash/test.html

https://github.com/lxmtalk/kissy
HTML | 211 lines | 169 code | 28 blank | 14 comment | 0 complexity | 0f52936bb1d67d134ff6db2836182aed MD5 | raw file
  1. <!doctype html>
  2. <html>
  3. <head>
  4. <meta charset="utf-8"/>
  5. <title>Flash Test</title>
  6. </head>
  7. <body>
  8. <script src="../test/test.js"></script>
  9. <script>KISSY.Test.Config.times = 1;</script>
  10. <h2>Test Data</h2>
  11. <div>
  12. <object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" width="200" height="150" id="myFlashContent">
  13. <param name="movie" value="assets/test.swf"/>
  14. <!--[if !IE]>-->
  15. <object type="application/x-shockwave-flash" data="assets/test.swf" width="200" height="150">
  16. <!--<![endif]-->
  17. <a href="http://www.adobe.com/go/getflashplayer">
  18. <img src="get_flash_player.gif" alt="Get Adobe Flash player"/>
  19. </a>
  20. <!--[if !IE]>-->
  21. </object>
  22. <!--<![endif]-->
  23. </object>
  24. <object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" width="200" height="150" id="myFlashContent2">
  25. <param name="movie" value="assets/test.swf"/>
  26. <!--[if !IE]>-->
  27. <object type="application/x-shockwave-flash" data="assets/test.swf" width="200" height="150">
  28. <!--<![endif]-->
  29. <a href="http://www.adobe.com/go/getflashplayer">
  30. <img src="get_flash_player.gif" alt="Get Adobe Flash player"/>
  31. </a>
  32. <!--[if !IE]>-->
  33. </object>
  34. <!--<![endif]-->
  35. </object>
  36. </div>
  37. <div id="test-flash3"></div>
  38. <div id="test-flash4"></div>
  39. <script src="../../build/packages/kissy.js"></script>
  40. <script src="../../build/flash/flash-pkg.js"></script>
  41. <!--
  42. <script src="flash.js"></script>
  43. <script src="flash-ua.js"></script>
  44. <script src="flash-embed.js"></script>
  45. -->
  46. <!-- Test Cases -->
  47. <script>
  48. var S = KISSY, UA = S.UA, F = S.Flash,RE_FLASH_TAGS = /object|embed/i;
  49. function test_ua(test) {
  50. if (UA.fpv() === undefined) test.fail();
  51. if (!UA.fpvGEQ()) test.fail();
  52. if (!UA.fpvGEQ('9.1')) test.fail();
  53. if (!UA.fpvGEQ('9.9.1')) test.fail();
  54. if (UA.fpvGEQ('18')) test.fail();
  55. test.extraMsg = '当插件安装不正常时,该测试用例需要 FAILED';
  56. test.echo('UA.fpv = ' + UA.fpv());
  57. }
  58. function test_add_register(test) {
  59. F.add('#myFlashContent', { version: '99' }, function(data) {
  60. if (data.status !== 0) test.fail();
  61. if (F.length > 0) test.fail();
  62. if(!RE_FLASH_TAGS.test(data.swf.nodeName))test.fail();
  63. });
  64. F.add('#myFlashContent2', { version: '9' }, function(data) {
  65. if (data.status !== 1) test.fail(data.status);
  66. if (F.length !== 1) test.fail(F.length);
  67. if(!RE_FLASH_TAGS.test(data.swf.nodeName))test.fail();
  68. if (data.dynamic) test.fail();
  69. });
  70. }
  71. function test_len(test) {
  72. if (F.length !== 1) test.fail(F.length);
  73. }
  74. function test_add_embed(test) {
  75. // target 不存在
  76. F.add('#non-exist', {
  77. src: 'assets/test.swf',
  78. version: 9,
  79. params: {
  80. wmode:"opaque",
  81. flashvars: 'a=1&b=2'
  82. }
  83. }, function(data) {
  84. });
  85. // 无 src
  86. F.add('#test-flash3', null, function(data) {
  87. if (data.status !== -3) test.fail();
  88. if (!data.dynamic) test.fail("add('#test-flash3'");
  89. });
  90. // 动态添加
  91. F.add('#test-flash3', {
  92. src: 'assets/test.swf',
  93. version: 9,
  94. attrs: {
  95. width: 200,
  96. height: 150
  97. },
  98. params: {
  99. wmode:"window",
  100. flashvars: {
  101. s: "string",
  102. b: false,
  103. n: 1,
  104. nul: null,
  105. und: undefined,
  106. url: "http://taobao.com/?x=1&z=2",
  107. o: {
  108. s: "string",
  109. b: false,
  110. n: 1,
  111. url: "http://taobao.com/?x=1&z=2"
  112. }
  113. }
  114. }
  115. }, function(data) {
  116. if (data.status !== 1) test.fail();
  117. // bugcheck: 重新获取对象,否则还是老对象. 如 入口为 div 如果不重新获取则仍然是 div longzang | 2010/8/9
  118. if(!RE_FLASH_TAGS.test(data.swf.nodeName))test.fail();
  119. });
  120. // 快速安装
  121. F.add('#test-flash4', {
  122. src: 'assets/test.swf',
  123. xi: 'express-install/expressInstall.swf',
  124. version: 12.2,
  125. params: {
  126. wmode:"window",
  127. flashvars: 'a=1&b=2'
  128. }
  129. }, function(data) {
  130. if (data.status !== 1) test.fail();
  131. if(!RE_FLASH_TAGS.test(data.swf.nodeName))test.fail();
  132. if (!data.dynamic) test.fail();
  133. });
  134. }
  135. function test_get(test) {
  136. if (!S.UA.safari) if ((F.get('myFlashContent2') || 0).nodeName !== 'OBJECT') test.fail();
  137. }
  138. function test_swfs(test){
  139. var swf = F.get('myFlashContent2');
  140. if(!swf)return;
  141. if(!RE_FLASH_TAGS.test(swf.nodeName))test.fail();
  142. }
  143. function test_contains(test) {
  144. if (S.UA.safari) return;
  145. if (!F.contains('myFlashContent2')) test.fail();
  146. if (F.contains('#test-xxxxx')) test.fail();
  147. }
  148. function test_remove(test) {
  149. F.remove('#test-flash4');
  150. if (F.contains('#test-flash4')) test.fail();
  151. }
  152. function test_flashvars(test) {
  153. var o = {
  154. str: "string",
  155. bool: false,
  156. num: 1,
  157. nul: null,
  158. und: undefined,
  159. fn: function() {
  160. },
  161. zero: 0,
  162. empty_str: '',
  163. url: "http://taobao.com/?x=1&z=2",
  164. obj: {
  165. str: "string",
  166. bool: false,
  167. num: 1,
  168. nul: null,
  169. und: undefined,
  170. fn: function() {
  171. },
  172. zero: 0,
  173. empty_str: '',
  174. url: "http://taobao.com/?x=1&z=2"
  175. }
  176. };
  177. test.echo(F.toFlashVars(o));
  178. o = {a: 1, b: { x: 2, z: 's=1&c=2' }};
  179. //if(F.toFlashVars(o) !== 'a=1&b={"x":2,"z":"s%3D1%26c%3D2"}') test.fail();
  180. }
  181. </script>
  182. </body>
  183. </html>