test_formSubmission.html 34 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826
  1. <!DOCTYPE HTML>
  2. <html>
  3. <!--
  4. https://bugzilla.mozilla.org/show_bug.cgi?id=523771
  5. -->
  6. <head>
  7. <title>Test for Bug 523771</title>
  8. <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
  9. <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
  10. <meta http-equiv="Content-Type" content="text/html;charset=utf-8">
  11. </head>
  12. <body>
  13. <a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=523771">Mozilla Bug 523771</a>
  14. <p id="display"></p>
  15. <iframe name="target_iframe" id="target_iframe"></iframe>
  16. <form action="form_submit_server.sjs" target="target_iframe" id="form"
  17. method="POST" enctype="multipart/form-data">
  18. <table>
  19. <tr>
  20. <td>Control type</td>
  21. <td>Name and value</td>
  22. <td>Name, empty value</td>
  23. <td>Name, no value</td>
  24. <td>Empty name, with value</td>
  25. <td>No name, with value</td>
  26. <td>No name or value</td>
  27. <td>Strange name/value</td>
  28. </tr>
  29. <tr>
  30. <td>Default input</td>
  31. <td><input name="n1_1" value="v1_1"></td>
  32. <td><input name="n1_2" value=""></td>
  33. <td><input name="n1_3"></td>
  34. <td><input name="" value="v1_4"></td>
  35. <td><input value="v1_5"></td>
  36. <td><input></td>
  37. <td><input name="n1_7_&#13;_&#10;_&#13;&#10;_ _&quot;"
  38. value="v1_7_&#13;_&#10;_&#13;&#10;_ _&quot;"></td>
  39. </tr>
  40. <tr>
  41. <td>Text input</td>
  42. <td><input type=text name="n2_1" value="v2_1"></td>
  43. <td><input type=text name="n2_2" value=""></td>
  44. <td><input type=text name="n2_3"></td>
  45. <td><input type=text name="" value="v2_4"></td>
  46. <td><input type=text value="v2_5"></td>
  47. <td><input type=text></td>
  48. <td><input type=text name="n2_7_&#13;_&#10;_&#13;&#10;_ _&quot;"
  49. value="v2_7_&#13;_&#10;_&#13;&#10;_ _&quot;"></td>
  50. </tr>
  51. <tr>
  52. <td>Checkbox unchecked</td>
  53. <td><input type=checkbox name="n3_1" value="v3_1"></td>
  54. <td><input type=checkbox name="n3_2" value=""></td>
  55. <td><input type=checkbox name="n3_3"></td>
  56. <td><input type=checkbox name="" value="v3_4"></td>
  57. <td><input type=checkbox value="v3_5"></td>
  58. <td><input type=checkbox></td>
  59. <td><input type=checkbox name="n3_7_&#13;_&#10;_&#13;&#10;_ _&quot;"
  60. value="v3_7_&#13;_&#10;_&#13;&#10;_ _&quot;"></td>
  61. </tr>
  62. <tr>
  63. <td>Checkbox checked</td>
  64. <td><input checked type=checkbox name="n4_1" value="v4_1"></td>
  65. <td><input checked type=checkbox name="n4_2" value=""></td>
  66. <td><input checked type=checkbox name="n4_3"></td>
  67. <td><input checked type=checkbox name="" value="v4_4"></td>
  68. <td><input checked type=checkbox value="v4_5"></td>
  69. <td><input checked type=checkbox></td>
  70. <td><input checked type=checkbox
  71. name="n4_7_&#13;_&#10;_&#13;&#10;_ _&quot;"
  72. value="v4_7_&#13;_&#10;_&#13;&#10;_ _&quot;"></td>
  73. </tr>
  74. <tr>
  75. <td>Radio unchecked</td>
  76. <td><input type=radio name="n5_1" value="v5_1"></td>
  77. <td><input type=radio name="n5_2" value=""></td>
  78. <td><input type=radio name="n5_3"></td>
  79. <td><input type=radio name="" value="v5_4"></td>
  80. <td><input type=radio value="v5_5"></td>
  81. <td><input type=radio></td>
  82. <td><input type=radio name="n5_7_&#13;_&#10;_&#13;&#10;_ _&quot;"
  83. value="v5_7_&#13;_&#10;_&#13;&#10;_ _&quot;"></td>
  84. </tr>
  85. <tr>
  86. <td>Radio checked</td>
  87. <td><input checked type=radio name="n6_1" value="v6_1"></td>
  88. <td><input checked type=radio name="n6_2" value=""></td>
  89. <td><input checked type=radio name="n6_3"></td>
  90. <td><input checked type=radio name="" value="v6_4"></td>
  91. <td><input checked type=radio value="v6_5"></td>
  92. <td><input checked type=radio></td>
  93. <td><input checked type=radio
  94. name="n6_7_&#13;_&#10;_&#13;&#10;_ _&quot;"
  95. value="v6_7_&#13;_&#10;_&#13;&#10;_ _&quot;"></td>
  96. </tr>
  97. <tr>
  98. <td>Hidden input</td>
  99. <td><input type=hidden name="n7_1" value="v7_1"></td>
  100. <td><input type=hidden name="n7_2" value=""></td>
  101. <td><input type=hidden name="n7_3"></td>
  102. <td><input type=hidden nane="" value="v7_4"></td>
  103. <td><input type=hidden value="v7_5"></td>
  104. <td><input type=hidden></td>
  105. <td><input type=hidden name="n7_7_&#13;_&#10;_&#13;&#10;_ _&quot;"
  106. value="v7_7_&#13;_&#10;_&#13;&#10;_ _&quot;"></td>
  107. </tr>
  108. <tr>
  109. <td>Password input</td>
  110. <td><input type=password name="n8_1" value="v8_1"></td>
  111. <td><input type=password name="n8_2" value=""></td>
  112. <td><input type=password name="n8_3"></td>
  113. <td><input type=password name="" value="v8_4"></td>
  114. <td><input type=password value="v8_5"></td>
  115. <td><input type=password></td>
  116. <td><input type=password name="n8_7_&#13;_&#10;_&#13;&#10;_ _&quot;"
  117. value="v8_7_&#13;_&#10;_&#13;&#10;_ _&quot;"></td>
  118. </tr>
  119. <tr>
  120. <td>Submit input</td>
  121. <td><input type=submit name="n9_1" value="v9_1"></td>
  122. <td><input type=submit name="n9_2" value=""></td>
  123. <td><input type=submit name="n9_3"></td>
  124. <td><input type=submit name="" value="v9_4"></td>
  125. <td><input type=submit value="v9_5"></td>
  126. <td><input type=submit></td>
  127. <td><input type=submit name="n9_7_&#13;_&#10;_&#13;&#10;_ _&quot;"
  128. value="v9_7_&#13;_&#10;_&#13;&#10;_ _&quot;"></td>
  129. </tr>
  130. <tr>
  131. <td>Button input</td>
  132. <td><input type=button name="n10_1" value="v10_1"></td>
  133. <td><input type=button name="n10_2" value=""></td>
  134. <td><input type=button name="n10_3"></td>
  135. <td><input type=button name="" value="v10_4"></td>
  136. <td><input type=button value="v10_5"></td>
  137. <td><input type=button></td>
  138. <td><input type=button name="n10_7_&#13;_&#10;_&#13;&#10;_ _&quot;"
  139. value="v10_7_&#13;_&#10;_&#13;&#10;_ _&quot;"></td>
  140. </tr>
  141. <tr>
  142. <td>Image input</td>
  143. <td><input type=image src="file_formSubmission_img.jpg" name="n11_1" value="v11_1"></td>
  144. <td><input type=image src="file_formSubmission_img.jpg" name="n11_2" value=""></td>
  145. <td><input type=image src="file_formSubmission_img.jpg" name="n11_3"></td>
  146. <td><input type=image src="file_formSubmission_img.jpg" name="" value="v11_4"></td>
  147. <td><input type=image src="file_formSubmission_img.jpg" value="v11_5"></td>
  148. <td><input type=image src="file_formSubmission_img.jpg"></td>
  149. <td><input type=image src="file_formSubmission_img.jpg"
  150. name="n11_7_&#13;_&#10;_&#13;&#10;_ _&quot;"
  151. value="v11_7_&#13;_&#10;_&#13;&#10;_ _&quot;"></td>
  152. </tr>
  153. <tr>
  154. <td>Reset input</td>
  155. <td><input type=reset name="n12_1" value="v12_1"></td>
  156. <td><input type=reset name="n12_2" value=""></td>
  157. <td><input type=reset name="n12_3"></td>
  158. <td><input type=reset name="" value="v12_4"></td>
  159. <td><input type=reset value="v12_5"></td>
  160. <td><input type=reset></td>
  161. <td><input type=reset name="n12_7_&#13;_&#10;_&#13;&#10;_ _&quot;"
  162. value="v12_7_&#13;_&#10;_&#13;&#10;_ _&quot;"></td>
  163. </tr>
  164. <tr>
  165. <td>Unknown input</td>
  166. <td><input type=foobar name="n13_1" value="v13_1"></td>
  167. <td><input type=foobar name="n13_2" value=""></td>
  168. <td><input type=foobar name="n13_3"></td>
  169. <td><input type=foobar name="" value="v13_4"></td>
  170. <td><input type=foobar value="v13_5"></td>
  171. <td><input type=foobar></td>
  172. <td><input type=foobar name="n13_7_&#13;_&#10;_&#13;&#10;_ _&quot;"
  173. value="v13_7_&#13;_&#10;_&#13;&#10;_ _&quot;"></td>
  174. </tr>
  175. <tr>
  176. <td>Default button</td>
  177. <td><button name="n14_1" value="v14_1"></button></td>
  178. <td><button name="n14_2" value=""></button></td>
  179. <td><button name="n14_3"></button></td>
  180. <td><button name="" value="v14_4"></button></td>
  181. <td><button value="v14_5"></button></td>
  182. <td><button></button></td>
  183. <td><button name="n14_7_&#13;_&#10;_&#13;&#10;_ _&quot;"
  184. value="v14_7_&#13;_&#10;_&#13;&#10;_ _&quot;"></button></td>
  185. </tr>
  186. <tr>
  187. <td>Submit button</td>
  188. <td><button type=submit name="n15_1" value="v15_1"></button></td>
  189. <td><button type=submit name="n15_2" value=""></button></td>
  190. <td><button type=submit name="n15_3"></button></td>
  191. <td><button type=submit name="" value="v15_4"></button></td>
  192. <td><button type=submit value="v15_5"></button></td>
  193. <td><button type=submit></button></td>
  194. <td><button type=submit name="n15_7_&#13;_&#10;_&#13;&#10;_ _&quot;"
  195. value="v15_7_&#13;_&#10;_&#13;&#10;_ _&quot;"></button></td>
  196. </tr>
  197. <tr>
  198. <td>Button button</td>
  199. <td><button type=button name="n16_1" value="v16_1"></button></td>
  200. <td><button type=button name="n16_2" value=""></button></td>
  201. <td><button type=button name="n16_3"></button></td>
  202. <td><button type=button name="" value="v16_4"></button></td>
  203. <td><button type=button value="v16_5"></button></td>
  204. <td><button type=button></button></td>
  205. <td><button type=button name="n16_7_&#13;_&#10;_&#13;&#10;_ _&quot;"
  206. value="v16_7_&#13;_&#10;_&#13;&#10;_ _&quot;"></button></td>
  207. </tr>
  208. <tr>
  209. <td>Reset button</td>
  210. <td><button type=reset name="n17_1" value="v17_1"></button></td>
  211. <td><button type=reset name="n17_2" value=""></button></td>
  212. <td><button type=reset name="n17_3"></button></td>
  213. <td><button type=reset name="" value="v17_4"></button></td>
  214. <td><button type=reset value="v17_5"></button></td>
  215. <td><button type=reset></button></td>
  216. <td><button type=reset name="n17_7_&#13;_&#10;_&#13;&#10;_ _&quot;"
  217. value="v17_7_&#13;_&#10;_&#13;&#10;_ _&quot;"></button></td>
  218. </tr>
  219. <tr>
  220. <td>Unknown button</td>
  221. <td><button type=foobar name="n18_1" value="v18_1"></button></td>
  222. <td><button type=foobar name="n18_2" value=""></button></td>
  223. <td><button type=foobar name="n18_3"></button></td>
  224. <td><button type=foobar name="" value="v18_4"></button></td>
  225. <td><button type=foobar value="v18_5"></button></td>
  226. <td><button type=foobar ></button></td>
  227. <td><button type=foobar name="n18_7_&#13;_&#10;_&#13;&#10;_ _&quot;"
  228. value="v18_7_&#13;_&#10;_&#13;&#10;_ _&quot;"></button></td>
  229. </tr>
  230. <tr>
  231. <td>&lt;input type='url'&gt;</td>
  232. <td><input type=url name="n19_1" value="http://v19_1.org"></td>
  233. <td><input type=url name="n19_2" value=""></td>
  234. <td><input type=url name="n19_3"></td>
  235. <td><input type=url name="" value="http://v19_4.org"></td>
  236. <td><input type=url value="http://v19_5.org"></td>
  237. <td><input type=url ></td>
  238. <td><input type=url name="n19_7_&#13;_&#10;_&#13;&#10;__&quot;"
  239. value="http://v19_7_&#13;_&#10;_&#13;&#10;__&quot;">
  240. <!-- Put UTF-8 value in the "strange" column. -->
  241. <input type=url name="n19_8" value="http://m&#xf3;zill&auml;.&#xf3;rg"></td>
  242. </tr>
  243. <tr>
  244. <td>&lt;input type='email'&gt;</td>
  245. <td><input type=email name="n20_1" value="v20_1@bar"></td>
  246. <td><input type=email name="n20_2" value=""></td>
  247. <td><input type=email name="n20_3"></td>
  248. <td><input type=email name="" value="v20_4@bar"></td>
  249. <td><input type=email value="v20_5@bar"></td>
  250. <td><input type=email ></td>
  251. <td><input type=email name="n20_7_&#13;_&#10;_&#13;&#10;__&quot;"
  252. value="v20_7_&#13;_&#10;_&#13;&#10;__&quot;@bar">
  253. <!-- Put UTF-8 value is the "strange" column. -->
  254. <input type=email name="n20_8" value="foo@mózillä.órg"></td>
  255. </tr>
  256. </table>
  257. <p>
  258. File input:
  259. <input type=file name="file_1" class="setfile">
  260. <input type=file name="file_2">
  261. <input type=file name="" class="setfile">
  262. <input type=file name="">
  263. <input type=file class="setfile">
  264. <input type=file>
  265. </p>
  266. <p>
  267. Multifile input:
  268. <input multiple type=file name="file_3" class="setfile">
  269. <input multiple type=file name="file_4" class="setfile multi">
  270. <input multiple type=file name="file_5">
  271. <input multiple type=file name="" class="setfile">
  272. <input multiple type=file name="" class="setfile multi">
  273. <input multiple type=file name="">
  274. <input multiple type=file class="setfile">
  275. <input multiple type=file class="setfile multi">
  276. <input multiple type=file>
  277. </p>
  278. <p>
  279. Textarea:
  280. <textarea name="t1">t_1_v</textarea>
  281. <textarea name="t2"></textarea>
  282. <textarea name="">t_3_v</textarea>
  283. <textarea>t_4_v</textarea>
  284. <textarea></textarea>
  285. <textarea name="t6">
  286. t_6_v</textarea>
  287. <textarea name="t7">t_7_v
  288. </textarea>
  289. <textarea name="t8">
  290. t_8_v
  291. </textarea>
  292. <textarea name="t9_&#13;_&#10;_&#13;&#10;_ _&quot;">t_9_&#13;_&#10;_&#13;&#10;_ _&quot;_v</textarea>
  293. <textarea name="t10" value="t_10_bogus">t_10_v</textarea>
  294. </p>
  295. <p>
  296. Select one:
  297. <select name="sel_1"></select>
  298. <select name="sel_1b"><option></option></select>
  299. <select name="sel_1c"><option selected></option></select>
  300. <select name="sel_2"><option value="sel_2_v"></option></select>
  301. <select name="sel_3"><option selected value="sel_3_v"></option></select>
  302. <select name="sel_4"><option value="sel_4_v1"></option><option value="sel_4_v2"></option></select>
  303. <select name="sel_5"><option selected value="sel_5_v1"></option><option value="sel_5_v2"></option></select>
  304. <select name="sel_6"><option value="sel_6_v1"></option><option selected value="sel_6_v2"></option></select>
  305. <select name="sel_7"><option>sel_7_v1</option><option>sel_7_v2</option></select>
  306. <select name="sel_8"><option selected>sel_8_v1</option><option>sel_8_v2</option></select>
  307. <select name="sel_9"><option>sel_9_v1</option><option selected>sel_9_v2</option></select>
  308. <select name="sel_10"><option value="sel_10_v1">sel_10_v1_text</option><option value="sel_10_v2">sel_10_v2_text</option></select>
  309. <select name="sel_11"><option selected value="sel_11_v1">sel_11_v1_text</option><option value="sel_11_v2">sel_11_v2_text</option></select>
  310. <select name="sel_12"><option value="sel_12_v1">sel_12_v1_text</option><option selected value="sel_12_v2">sel_12_v2_text</option></select>
  311. <select name="sel_13"><option disabled>sel_13_v1</option><option>sel_13_v2</option></select>
  312. <select name="sel_14"><option disabled selected>sel_14_v1</option><option>sel_14_v2</option></select>
  313. <select name="sel_15"><option disabled>sel_15_v1</option><option selected>sel_15_v2</option></select>
  314. <select name="sel_16"><option>sel_16_v1</option><option disabled>sel_16_v2</option></select>
  315. <select name="sel_17"><option selected>sel_17_v1</option><option disabled>sel_17_v2</option></select>
  316. <select name="sel_18"><option>sel_18_v1</option><option disabled selected>sel_18_v2</option></select>
  317. <select name=""><option selected value="sel_13_v1"></option><option value="sel_13_v2"></option></select>
  318. <select name=""><option value="sel_14_v1"></option><option selected value="sel_14_v2"></option></select>
  319. <select name=""><option selected>sel_15_v1</option><option>sel_15_v2</option></select>
  320. <select name=""><option>sel_16_v1</option><option selected>sel_16_v2</option></select>
  321. <select><option selected value="sel_17_v1"></option><option value="sel_17_v2"></option></select>
  322. <select><option value="sel_18_v1"></option><option selected value="sel_18_v2"></option></select>
  323. <select><option selected>sel_19_v1</option><option>sel_19_v2</option></select>
  324. <select><option>sel_20_v1</option><option selected>sel_20_v2</option></select>
  325. </p>
  326. <p>
  327. Select multiple:
  328. <select multiple name="msel_1"></select>
  329. <select multiple name="msel_1b"><option></option></select>
  330. <select multiple name="msel_1c"><option selected></option></select>
  331. <select multiple name="msel_2"><option value="msel_2_v"></option></select>
  332. <select multiple name="msel_3"><option selected value="msel_3_v"></option></select>
  333. <select multiple name="msel_4"><option value="msel_4_v1"></option><option value="msel_4_v2"></option></select>
  334. <select multiple name="msel_5"><option selected value="msel_5_v1"></option><option value="msel_5_v2"></option></select>
  335. <select multiple name="msel_6"><option value="msel_6_v1"></option><option selected value="msel_6_v2"></option></select>
  336. <select multiple name="msel_7"><option selected value="msel_7_v1"></option><option selected value="msel_7_v2"></option></select>
  337. <select multiple name="msel_8"><option>msel_8_v1</option><option>msel_8_v2</option></select>
  338. <select multiple name="msel_9"><option selected>msel_9_v1</option><option>msel_9_v2</option></select>
  339. <select multiple name="msel_10"><option>msel_10_v1</option><option selected>msel_10_v2</option></select>
  340. <select multiple name="msel_11"><option selected>msel_11_v1</option><option selected>msel_11_v2</option></select>
  341. <select multiple name="msel_12"><option value="msel_12_v1">msel_12_v1_text</option><option value="msel_12_v2">msel_12_v2_text</option></select>
  342. <select multiple name="msel_13"><option selected value="msel_13_v1">msel_13_v1_text</option><option value="msel_13_v2">msel_13_v2_text</option></select>
  343. <select multiple name="msel_14"><option value="msel_14_v1">msel_14_v1_text</option><option selected value="msel_14_v2">msel_14_v2_text</option></select>
  344. <select multiple name="msel_15"><option selected value="msel_15_v1">msel_15_v1_text</option><option selected value="msel_15_v2">msel_15_v2_text</option></select>
  345. <select multiple name="msel_16"><option>msel_16_v1</option><option>msel_16_v2</option><option>msel_16_v3</option></select>
  346. <select multiple name="msel_17"><option selected>msel_17_v1</option><option>msel_17_v2</option><option>msel_17_v3</option></select>
  347. <select multiple name="msel_18"><option>msel_18_v1</option><option selected>msel_18_v2</option><option>msel_18_v3</option></select>
  348. <select multiple name="msel_19"><option selected>msel_19_v1</option><option selected>msel_19_v2</option><option>msel_19_v3</option></select>
  349. <select multiple name="msel_20"><option>msel_20_v1</option><option>msel_20_v2</option><option selected>msel_20_v3</option></select>
  350. <select multiple name="msel_21"><option selected>msel_21_v1</option><option>msel_21_v2</option><option selected>msel_21_v3</option></select>
  351. <select multiple name="msel_22"><option>msel_22_v1</option><option selected>msel_22_v2</option><option selected>msel_22_v3</option></select>
  352. <select multiple name="msel_23"><option selected>msel_23_v1</option><option selected>msel_23_v2</option><option selected>msel_23_v3</option></select>
  353. <select multiple name="msel_24"><option disabled>msel_24_v1</option><option>msel_24_v2</option></select>
  354. <select multiple name="msel_25"><option disabled selected>msel_25_v1</option><option>msel_25_v2</option></select>
  355. <select multiple name="msel_26"><option disabled>msel_26_v1</option><option selected>msel_26_v2</option></select>
  356. <select multiple name="msel_27"><option disabled selected>msel_27_v1</option><option selected>msel_27_v2</option></select>
  357. <select multiple name="msel_28"><option>msel_28_v1</option><option disabled>msel_28_v2</option></select>
  358. <select multiple name="msel_29"><option selected>msel_29_v1</option><option disabled>msel_29_v2</option></select>
  359. <select multiple name="msel_30"><option>msel_30_v1</option><option disabled selected>msel_30_v2</option></select>
  360. <select multiple name="msel_31"><option selected>msel_31_v1</option><option disabled selected>msel_31_v2</option></select>
  361. <select multiple name="msel_32"><option disabled selected>msel_32_v1</option><option disabled selected>msel_32_v2</option></select>
  362. <select multiple name=""><option>msel_33_v1</option><option>msel_33_v2</option></select>
  363. <select multiple name=""><option selected>msel_34_v1</option><option>msel_34_v2</option></select>
  364. <select multiple name=""><option>msel_35_v1</option><option selected>msel_35_v2</option></select>
  365. <select multiple name=""><option selected>msel_36_v1</option><option selected>msel_36_v2</option></select>
  366. <select multiple><option>msel_37_v1</option><option>msel_37_v2</option></select>
  367. <select multiple><option selected>msel_38_v1</option><option>msel_38_v2</option></select>
  368. <select multiple><option>msel_39_v1</option><option selected>msel_39_v2</option></select>
  369. <select multiple><option selected>msel_40_v1</option><option selected>msel_40_v2</option></select>
  370. </p>
  371. </form>
  372. <pre id="test">
  373. <script class="testbody" type="text/javascript;version=1.8">
  374. SimpleTest.waitForExplicitFinish();
  375. const placeholder_myFile1 = {};
  376. const placeholder_myFile2 = {};
  377. const placeholder_emptyFile = {};
  378. var myFile1, myFile2, emptyFile;
  379. let openerURL = SimpleTest.getTestFileURL("formSubmission_chrome.js");
  380. let opener = SpecialPowers.loadChromeScript(openerURL);
  381. {
  382. let xhr = new XMLHttpRequest;
  383. xhr.open("GET", "/dynamic/getMyDirectory.sjs", false);
  384. xhr.send();
  385. let basePath = xhr.responseText;
  386. opener.addMessageListener("files.opened", onFilesOpened);
  387. opener.sendAsyncMessage("files.open", [
  388. basePath + "file_formSubmission_text.txt",
  389. basePath + "file_formSubmission_img.jpg",
  390. ]);
  391. }
  392. function onFilesOpened(files) {
  393. let [textFile, imageFile] = files;
  394. opener.destroy();
  395. let singleFile = textFile;
  396. let multiFile = [textFile, imageFile];
  397. var addList = document.getElementsByClassName("setfile");
  398. let i = 0;
  399. var input;
  400. while (input = addList[i++]) {
  401. if (input.classList.contains("multi")) {
  402. SpecialPowers.wrap(input).mozSetFileArray(multiFile);
  403. } else {
  404. SpecialPowers.wrap(input).mozSetFileArray([singleFile]);
  405. }
  406. }
  407. input = document.createElement("input");
  408. input.type = "file";
  409. input.multiple = true;
  410. SpecialPowers.wrap(input).mozSetFileArray(multiFile);
  411. myFile1 = input.files[0];
  412. myFile2 = input.files[1];
  413. is(myFile1.size, 20, "File1 size");
  414. is(myFile2.size, 2711, "File2 size");
  415. emptyFile = { name: "", type: "application/octet-stream" };
  416. // Now, actually run the tests; see below.
  417. onFilesSet();
  418. };
  419. var expectedSub = [
  420. // Default input
  421. { name: "n1_1", value: "v1_1" },
  422. { name: "n1_2", value: "" },
  423. { name: "n1_3", value: "" },
  424. { name: "n1_7_\r\n_\r\n_\r\n_ _\"", value: "v1_7____ _\"" },
  425. // Text input
  426. { name: "n2_1", value: "v2_1" },
  427. { name: "n2_2", value: "" },
  428. { name: "n2_3", value: "" },
  429. { name: "n2_7_\r\n_\r\n_\r\n_ _\"", value: "v2_7____ _\"" },
  430. // Checkbox unchecked
  431. // Checkbox checked
  432. { name: "n4_1", value: "v4_1" },
  433. { name: "n4_2", value: "" },
  434. { name: "n4_3", value: "on" },
  435. { name: "n4_7_\r\n_\r\n_\r\n_ _\"", value: "v4_7_\r\n_\r\n_\r\n_ _\"" },
  436. // Radio unchecked
  437. // Radio checked
  438. { name: "n6_1", value: "v6_1" },
  439. { name: "n6_2", value: "" },
  440. { name: "n6_3", value: "on" },
  441. { name: "n6_7_\r\n_\r\n_\r\n_ _\"", value: "v6_7_\r\n_\r\n_\r\n_ _\"" },
  442. // Hidden input
  443. { name: "n7_1", value: "v7_1" },
  444. { name: "n7_2", value: "" },
  445. { name: "n7_3", value: "" },
  446. { name: "n7_7_\r\n_\r\n_\r\n_ _\"", value: "v7_7_\r\n_\r\n_\r\n_ _\"" },
  447. // Password input
  448. { name: "n8_1", value: "v8_1" },
  449. { name: "n8_2", value: "" },
  450. { name: "n8_3", value: "" },
  451. { name: "n8_7_\r\n_\r\n_\r\n_ _\"", value: "v8_7____ _\"" },
  452. // Submit input
  453. // Button input
  454. // Image input
  455. // Reset input
  456. // Unknown input
  457. { name: "n13_1", value: "v13_1" },
  458. { name: "n13_2", value: "" },
  459. { name: "n13_3", value: "" },
  460. { name: "n13_7_\r\n_\r\n_\r\n_ _\"", value: "v13_7____ _\"" },
  461. // <input type='url'>
  462. { name: "n19_1", value: "http://v19_1.org" },
  463. { name: "n19_2", value: "" },
  464. { name: "n19_3", value: "" },
  465. { name: "n19_7_\r\n_\r\n_\r\n__\"", value: "http://v19_7_____\"" },
  466. { name: "n19_8", value: "http://m\xf3zill\xe4.\xf3rg" },
  467. // <input type='email'>
  468. { name: "n20_1", value: "v20_1@bar" },
  469. { name: "n20_2", value: "" },
  470. { name: "n20_3", value: "" },
  471. { name: "n20_7_\r\n_\r\n_\r\n__\"", value: "v20_7_____\"@bar" },
  472. { name: "n20_8", value: "foo@mózillä.órg" },
  473. // Default button
  474. // Submit button
  475. // Button button
  476. // Reset button
  477. // Unknown button
  478. // File
  479. { name: "file_1", value: placeholder_myFile1 },
  480. { name: "file_2", value: placeholder_emptyFile },
  481. // Multiple file
  482. { name: "file_3", value: placeholder_myFile1 },
  483. { name: "file_4", value: placeholder_myFile1 },
  484. { name: "file_4", value: placeholder_myFile2 },
  485. { name: "file_5", value: placeholder_emptyFile },
  486. // Textarea
  487. { name: "t1", value: "t_1_v" },
  488. { name: "t2", value: "" },
  489. { name: "t6", value: "t_6_v" },
  490. { name: "t7", value: "t_7_v\r\n" },
  491. { name: "t8", value: "\r\n t_8_v \r\n" },
  492. { name: "t9_\r\n_\r\n_\r\n_ _\"", value: "t_9_\r\n_\r\n_\r\n_ _\"_v" },
  493. { name: "t10", value: "t_10_v" },
  494. // Select one
  495. { name: "sel_1b", value: "" },
  496. { name: "sel_1c", value: "" },
  497. { name: "sel_2", value: "sel_2_v" },
  498. { name: "sel_3", value: "sel_3_v" },
  499. { name: "sel_4", value: "sel_4_v1" },
  500. { name: "sel_5", value: "sel_5_v1" },
  501. { name: "sel_6", value: "sel_6_v2" },
  502. { name: "sel_7", value: "sel_7_v1" },
  503. { name: "sel_8", value: "sel_8_v1" },
  504. { name: "sel_9", value: "sel_9_v2" },
  505. { name: "sel_10", value: "sel_10_v1" },
  506. { name: "sel_11", value: "sel_11_v1" },
  507. { name: "sel_12", value: "sel_12_v2" },
  508. { name: "sel_13", value: "sel_13_v2" },
  509. { name: "sel_15", value: "sel_15_v2" },
  510. { name: "sel_16", value: "sel_16_v1" },
  511. { name: "sel_17", value: "sel_17_v1" },
  512. // Select three
  513. { name: "msel_1c", value: "" },
  514. { name: "msel_3", value: "msel_3_v" },
  515. { name: "msel_5", value: "msel_5_v1" },
  516. { name: "msel_6", value: "msel_6_v2" },
  517. { name: "msel_7", value: "msel_7_v1" },
  518. { name: "msel_7", value: "msel_7_v2" },
  519. { name: "msel_9", value: "msel_9_v1" },
  520. { name: "msel_10", value: "msel_10_v2" },
  521. { name: "msel_11", value: "msel_11_v1" },
  522. { name: "msel_11", value: "msel_11_v2" },
  523. { name: "msel_13", value: "msel_13_v1" },
  524. { name: "msel_14", value: "msel_14_v2" },
  525. { name: "msel_15", value: "msel_15_v1" },
  526. { name: "msel_15", value: "msel_15_v2" },
  527. { name: "msel_17", value: "msel_17_v1" },
  528. { name: "msel_18", value: "msel_18_v2" },
  529. { name: "msel_19", value: "msel_19_v1" },
  530. { name: "msel_19", value: "msel_19_v2" },
  531. { name: "msel_20", value: "msel_20_v3" },
  532. { name: "msel_21", value: "msel_21_v1" },
  533. { name: "msel_21", value: "msel_21_v3" },
  534. { name: "msel_22", value: "msel_22_v2" },
  535. { name: "msel_22", value: "msel_22_v3" },
  536. { name: "msel_23", value: "msel_23_v1" },
  537. { name: "msel_23", value: "msel_23_v2" },
  538. { name: "msel_23", value: "msel_23_v3" },
  539. { name: "msel_26", value: "msel_26_v2" },
  540. { name: "msel_27", value: "msel_27_v2" },
  541. { name: "msel_29", value: "msel_29_v1" },
  542. { name: "msel_31", value: "msel_31_v1" },
  543. ];
  544. var expectedAugment = [
  545. { name: "aName", value: "aValue" },
  546. //{ name: "aNameBool", value: "false" },
  547. { name: "aNameNum", value: "9.2" },
  548. { name: "aNameFile1", value: placeholder_myFile1 },
  549. { name: "aNameFile2", value: placeholder_myFile2 },
  550. //{ name: "aNameObj", value: "[object XMLHttpRequest]" },
  551. //{ name: "aNameNull", value: "null" },
  552. //{ name: "aNameUndef", value: "undefined" },
  553. ];
  554. function checkMPSubmission(sub, expected, test) {
  555. function getPropCount(o) {
  556. var x, l = 0;
  557. for (x in o) ++l;
  558. return l;
  559. }
  560. function mpquote(s) {
  561. return s.replace(/\r\n/g, " ")
  562. .replace(/\r/g, " ")
  563. .replace(/\n/g, " ")
  564. .replace(/\"/g, "\\\"");
  565. }
  566. is(sub.length, expected.length,
  567. "Correct number of multipart items in " + test);
  568. if (sub.length != expected.length) {
  569. alert(JSON.stringify(sub));
  570. }
  571. var i;
  572. for (i = 0; i < expected.length; ++i) {
  573. if (!("fileName" in expected[i])) {
  574. is(sub[i].headers["Content-Disposition"],
  575. "form-data; name=\"" + mpquote(expected[i].name) + "\"",
  576. "Correct name in " + test);
  577. is (getPropCount(sub[i].headers), 1,
  578. "Wrong number of headers in " + test);
  579. is(sub[i].body,
  580. expected[i].value.replace(/\r\n|\r|\n/, "\r\n"),
  581. "Correct value in " + test);
  582. }
  583. else {
  584. is(sub[i].headers["Content-Disposition"],
  585. "form-data; name=\"" + mpquote(expected[i].name) + "\"; filename=\"" +
  586. mpquote(expected[i].fileName) + "\"",
  587. "Correct name in " + test);
  588. is(sub[i].headers["Content-Type"],
  589. expected[i].contentType,
  590. "Correct content type in " + test);
  591. is (getPropCount(sub[i].headers), 2,
  592. "Wrong number of headers in " + test);
  593. is(sub[i].body,
  594. expected[i].value,
  595. "Correct value in " + test);
  596. }
  597. }
  598. }
  599. function utf8encode(s) {
  600. return unescape(encodeURIComponent(s));
  601. }
  602. function checkURLSubmission(sub, expected) {
  603. function urlEscape(s) {
  604. return escape(utf8encode(s)).replace(/%20/g, "+")
  605. .replace(/\//g, "%2F")
  606. .replace(/@/g, "%40");
  607. }
  608. subItems = sub.split("&");
  609. is(subItems.length, expected.length,
  610. "Correct number of url items");
  611. var i;
  612. for (i = 0; i < expected.length; ++i) {
  613. let expect = urlEscape(expected[i].name) + "=" +
  614. urlEscape(("fileName" in expected[i]) ? expected[i].fileName : expected[i].value);
  615. is (subItems[i], expect, "expected URL part");
  616. }
  617. }
  618. function checkPlainSubmission(sub, expected) {
  619. is(sub,
  620. expected.map(function(v) {
  621. return v.name + "=" +
  622. (("fileName" in v) ? v.fileName : v.value) +
  623. "\r\n";
  624. }).join(""),
  625. "Correct submission");
  626. }
  627. function setDisabled(list, state) {
  628. Array.prototype.forEach.call(list, function(e) {
  629. e.disabled = state;
  630. });
  631. }
  632. var gen;
  633. function onFilesSet() {
  634. gen = runTest();
  635. addLoadEvent(function() {
  636. gen.next();
  637. });
  638. }
  639. function runTest() {
  640. // Set up the expectedSub array
  641. fileReader1 = new FileReader;
  642. fileReader1.readAsBinaryString(myFile1);
  643. fileReader2 = new FileReader;
  644. fileReader2.readAsBinaryString(myFile2);
  645. fileReader1.onload = fileReader2.onload = function() { gen.next(); };
  646. yield undefined; // Wait for both FileReaders. We don't care which order they finish.
  647. yield undefined;
  648. function fileFixup(o) {
  649. if (o.value === placeholder_myFile1) {
  650. o.value = fileReader1.result;
  651. o.fileName = myFile1.name;
  652. o.contentType = myFile1.type;
  653. }
  654. else if (o.value === placeholder_myFile2) {
  655. o.value = fileReader2.result;
  656. o.fileName = myFile2.name;
  657. o.contentType = myFile2.type;
  658. }
  659. else if (o.value === placeholder_emptyFile) {
  660. o.value = "";
  661. o.fileName = emptyFile.name;
  662. o.contentType = emptyFile.type;
  663. }
  664. };
  665. expectedSub.forEach(fileFixup);
  666. expectedAugment.forEach(fileFixup);
  667. var form = $("form");
  668. // multipart/form-data
  669. var iframe = $("target_iframe");
  670. iframe.onload = function() { gen.next(); };
  671. // Make normal submission
  672. form.submit();
  673. yield undefined; // Wait for iframe to load as a result of the submission
  674. var submission = JSON.parse(iframe.contentDocument.documentElement.textContent);
  675. checkMPSubmission(submission, expectedSub, "normal submission");
  676. // Disabled controls
  677. setDisabled(document.querySelectorAll("input, select, textarea"), true);
  678. form.submit();
  679. yield undefined;
  680. submission = JSON.parse(iframe.contentDocument.documentElement.textContent);
  681. checkMPSubmission(submission, [], "disabled controls");
  682. // Reenabled controls
  683. setDisabled(document.querySelectorAll("input, select, textarea"), false);
  684. form.submit();
  685. yield undefined;
  686. submission = JSON.parse(iframe.contentDocument.documentElement.textContent);
  687. checkMPSubmission(submission, expectedSub, "reenabled controls");
  688. // text/plain
  689. form.action = "form_submit_server.sjs?plain";
  690. form.enctype = "text/plain";
  691. form.submit();
  692. yield undefined;
  693. submission = JSON.parse(iframe.contentDocument.documentElement.textContent);
  694. checkPlainSubmission(submission, expectedSub);
  695. // application/x-www-form-urlencoded
  696. form.action = "form_submit_server.sjs?url";
  697. form.enctype = "application/x-www-form-urlencoded";
  698. form.submit();
  699. yield undefined;
  700. submission = JSON.parse(iframe.contentDocument.documentElement.textContent);
  701. checkURLSubmission(submission, expectedSub);
  702. // application/x-www-form-urlencoded
  703. form.action = "form_submit_server.sjs?xxyy";
  704. form.method = "GET";
  705. form.enctype = "";
  706. form.submit();
  707. yield undefined;
  708. submission = JSON.parse(iframe.contentDocument.documentElement.textContent);
  709. checkURLSubmission(submission, expectedSub);
  710. // application/x-www-form-urlencoded
  711. form.action = "form_submit_server.sjs";
  712. form.method = "";
  713. form.enctype = "";
  714. form.submit();
  715. yield undefined;
  716. submission = JSON.parse(iframe.contentDocument.documentElement.textContent);
  717. checkURLSubmission(submission, expectedSub);
  718. // Send form using XHR and FormData
  719. xhr = new XMLHttpRequest();
  720. xhr.onload = function() { gen.next(); };
  721. xhr.open("POST", "form_submit_server.sjs");
  722. xhr.send(new FormData(form));
  723. yield undefined; // Wait for XHR load
  724. checkMPSubmission(JSON.parse(xhr.responseText), expectedSub, "send form using XHR and FormData");
  725. // Send disabled form using XHR and FormData
  726. setDisabled(document.querySelectorAll("input, select, textarea"), true);
  727. xhr.open("POST", "form_submit_server.sjs");
  728. xhr.send(new FormData(form));
  729. yield undefined;
  730. checkMPSubmission(JSON.parse(xhr.responseText), [], "send disabled form using XHR and FormData");
  731. setDisabled(document.querySelectorAll("input, select, textarea"), false);
  732. // Send FormData
  733. function addToFormData(fd) {
  734. fd.append("aName", "aValue");
  735. fd.append("aNameNum", 9.2);
  736. fd.append("aNameFile1", myFile1);
  737. fd.append("aNameFile2", myFile2);
  738. }
  739. var fd = new FormData();
  740. addToFormData(fd);
  741. xhr.open("POST", "form_submit_server.sjs");
  742. xhr.send(fd);
  743. yield undefined;
  744. checkMPSubmission(JSON.parse(xhr.responseText), expectedAugment, "send FormData");
  745. // Augment <form> using FormData
  746. fd = new FormData(form);
  747. addToFormData(fd);
  748. xhr.open("POST", "form_submit_server.sjs");
  749. xhr.send(fd);
  750. yield undefined;
  751. checkMPSubmission(JSON.parse(xhr.responseText),
  752. expectedSub.concat(expectedAugment), "send augmented FormData");
  753. SimpleTest.finish();
  754. yield undefined;
  755. }
  756. </script>
  757. </pre>
  758. </body>
  759. </html>