jsf.js_next_gen 4.0.0-RC.3 → 4.0.0-RC.31

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (185) hide show
  1. package/dist/docs/assets/main.js +56 -52
  2. package/dist/docs/assets/style.css +23 -0
  3. package/dist/window/faces-development.js +2961 -3011
  4. package/dist/window/faces-development.js.br +0 -0
  5. package/dist/window/faces-development.js.gz +0 -0
  6. package/dist/window/faces-development.js.map +1 -1
  7. package/dist/window/faces.js +1 -1
  8. package/dist/window/faces.js.LICENSE.txt +0 -2
  9. package/dist/window/faces.js.br +0 -0
  10. package/dist/window/faces.js.gz +0 -0
  11. package/dist/window/faces.js.map +1 -1
  12. package/dist/window/jsf-development.js +2966 -3016
  13. package/dist/window/jsf-development.js.br +0 -0
  14. package/dist/window/jsf-development.js.gz +0 -0
  15. package/dist/window/jsf-development.js.map +1 -1
  16. package/dist/window/jsf.js +1 -1
  17. package/dist/window/jsf.js.LICENSE.txt +0 -2
  18. package/dist/window/jsf.js.br +0 -0
  19. package/dist/window/jsf.js.gz +0 -0
  20. package/dist/window/jsf.js.map +1 -1
  21. package/package.json +16 -16
  22. package/src/main/test.xml +23 -0
  23. package/src/main/typescript/@types/definitions/index.d.ts +12 -7
  24. package/src/main/typescript/api/_api.ts +4 -3
  25. package/src/main/typescript/impl/AjaxImpl.ts +125 -41
  26. package/src/main/typescript/impl/core/Const.ts +52 -41
  27. package/src/main/typescript/impl/util/Assertions.ts +16 -8
  28. package/src/main/typescript/impl/util/ExtDomQuery.ts +12 -4
  29. package/src/main/typescript/impl/util/FileUtils.ts +66 -0
  30. package/src/main/typescript/impl/util/HiddenInputBuilder.ts +89 -0
  31. package/src/main/typescript/impl/util/Lang.ts +9 -11
  32. package/src/main/typescript/impl/xhrCore/ErrorData.ts +15 -10
  33. package/src/main/typescript/impl/xhrCore/EventData.ts +2 -2
  34. package/src/main/typescript/impl/xhrCore/IResponseProcessor.ts +15 -1
  35. package/src/main/typescript/impl/xhrCore/RequestDataResolver.ts +69 -24
  36. package/src/main/typescript/impl/xhrCore/ResonseDataResolver.ts +4 -4
  37. package/src/main/typescript/impl/xhrCore/Response.ts +55 -38
  38. package/src/main/typescript/impl/xhrCore/ResponseProcessor.ts +173 -98
  39. package/src/main/typescript/impl/xhrCore/XhrFormData.ts +91 -168
  40. package/src/main/typescript/impl/xhrCore/XhrRequest.ts +39 -23
  41. package/src/main/typescript/myfaces/OamSubmit.ts +29 -13
  42. package/src/main/typescript/test/frameworkBase/_ext/monadish/DomQueryTest.spec.ts +1 -1
  43. package/src/main/typescript/test/frameworkBase/_ext/shared/StandardInits.ts +73 -1
  44. package/src/main/typescript/test/frameworkBase/_ext/shared/XmlResponses.ts +40 -1
  45. package/src/main/typescript/test/impl/ImplTest.spec.ts +3 -3
  46. package/src/main/typescript/test/impl/ImplTest_23.spec.ts +3 -3
  47. package/src/main/typescript/test/xhrCore/EventTests.spec.ts +1 -1
  48. package/src/main/typescript/test/xhrCore/FileUploadTest.spec.ts +5 -2
  49. package/src/main/typescript/test/xhrCore/NamespacesRequestTest.spec.ts +203 -0
  50. package/src/main/typescript/test/xhrCore/OamSubmitTest.spec.ts +177 -0
  51. package/src/main/typescript/test/xhrCore/RequestParamsTest.spec.ts +158 -17
  52. package/src/main/typescript/test/xhrCore/RequestTest.spec.ts +70 -3
  53. package/src/main/typescript/test/xhrCore/RequestTest_23.spec.ts +39 -3
  54. package/src/main/typescript/test/xhrCore/ResponseTest.spec.ts +372 -34
  55. package/src/main/typescript/test/xhrCore/ResponseTest23.spec.ts +43 -9
  56. package/src/main/typescript/test/xhrCore/XhrFormDataTest.spec.ts +67 -49
  57. package/src/main/typescript/test.xml +6 -0
  58. package/src/main/typescript/tsconfig.json +2 -2
  59. package/src/test/resources/jsf-development.js +1 -1
  60. package/src/tmp/test.html +12 -88
  61. package/target/api/_api.js +16 -29
  62. package/target/api/_api.js.map +1 -1
  63. package/target/api/faces.js +4 -4
  64. package/target/api/faces.js.map +1 -1
  65. package/target/api/jsf.js +9 -9
  66. package/target/api/jsf.js.map +1 -1
  67. package/target/classes/com/example/jsfs_js_ts/DecoratedFacesJS.class +0 -0
  68. package/target/classes/com/example/jsfs_js_ts/DecoratingResourceHandlerWrapper.class +0 -0
  69. package/target/classes/com/example/jsfs_js_ts/FacesJSMapFileResourceWrapper.class +0 -0
  70. package/target/classes/com/example/jsfs_js_ts/FacesJSMappingDecorator.class +0 -0
  71. package/target/impl/AjaxImpl.js +155 -89
  72. package/target/impl/AjaxImpl.js.map +1 -1
  73. package/target/impl/PushImpl.js +45 -48
  74. package/target/impl/PushImpl.js.map +1 -1
  75. package/target/impl/core/Const.js +52 -40
  76. package/target/impl/core/Const.js.map +1 -1
  77. package/target/impl/core/Context.js +10 -0
  78. package/target/impl/core/Context.js.map +1 -0
  79. package/target/impl/core/ImplTypes.js +9 -14
  80. package/target/impl/core/ImplTypes.js.map +1 -1
  81. package/target/impl/i18n/Messages.js +3 -4
  82. package/target/impl/i18n/Messages.js.map +1 -1
  83. package/target/impl/util/Assertions.js +20 -24
  84. package/target/impl/util/Assertions.js.map +1 -1
  85. package/target/impl/util/AsyncQueue.js +28 -36
  86. package/target/impl/util/AsyncQueue.js.map +1 -1
  87. package/target/impl/util/ExtDomQuery.js +153 -221
  88. package/target/impl/util/ExtDomQuery.js.map +1 -1
  89. package/target/impl/util/FileUtils.js +64 -0
  90. package/target/impl/util/FileUtils.js.map +1 -0
  91. package/target/impl/util/HiddenElementBuilder.js +7 -0
  92. package/target/impl/util/HiddenElementBuilder.js.map +1 -0
  93. package/target/impl/util/HiddenInputBuilder.js +79 -0
  94. package/target/impl/util/HiddenInputBuilder.js.map +1 -0
  95. package/target/impl/util/Lang.js +23 -32
  96. package/target/impl/util/Lang.js.map +1 -1
  97. package/target/impl/util/URLCodec.js +77 -0
  98. package/target/impl/util/URLCodec.js.map +1 -0
  99. package/target/impl/xhrCore/ErrorData.js +41 -64
  100. package/target/impl/xhrCore/ErrorData.js.map +1 -1
  101. package/target/impl/xhrCore/EventData.js +10 -13
  102. package/target/impl/xhrCore/EventData.js.map +1 -1
  103. package/target/impl/xhrCore/RequestContext.js +11 -0
  104. package/target/impl/xhrCore/RequestContext.js.map +1 -0
  105. package/target/impl/xhrCore/RequestDataResolver.js +71 -27
  106. package/target/impl/xhrCore/RequestDataResolver.js.map +1 -1
  107. package/target/impl/xhrCore/ResonseDataResolver.js +16 -16
  108. package/target/impl/xhrCore/ResonseDataResolver.js.map +1 -1
  109. package/target/impl/xhrCore/Response.js +43 -28
  110. package/target/impl/xhrCore/Response.js.map +1 -1
  111. package/target/impl/xhrCore/ResponseProcessor.js +217 -162
  112. package/target/impl/xhrCore/ResponseProcessor.js.map +1 -1
  113. package/target/impl/xhrCore/XhrFormData.js +92 -208
  114. package/target/impl/xhrCore/XhrFormData.js.map +1 -1
  115. package/target/impl/xhrCore/XhrRequest.js +104 -104
  116. package/target/impl/xhrCore/XhrRequest.js.map +1 -1
  117. package/target/myfaces/OamSubmit.js +33 -24
  118. package/target/myfaces/OamSubmit.js.map +1 -1
  119. package/target/test/frameworkBase/LangTest.spec.js +46 -32
  120. package/target/test/frameworkBase/LangTest.spec.js.map +1 -1
  121. package/target/test/frameworkBase/_ext/monadish/DomQueryTest.spec.js +238 -228
  122. package/target/test/frameworkBase/_ext/monadish/DomQueryTest.spec.js.map +1 -1
  123. package/target/test/frameworkBase/_ext/monadish/LangTest.spec.js +45 -31
  124. package/target/test/frameworkBase/_ext/monadish/LangTest.spec.js.map +1 -1
  125. package/target/test/frameworkBase/_ext/monadish/MappingProbes.js +24 -33
  126. package/target/test/frameworkBase/_ext/monadish/MappingProbes.js.map +1 -1
  127. package/target/test/frameworkBase/_ext/monadish/MappingTest.spec.js +8 -8
  128. package/target/test/frameworkBase/_ext/monadish/MappingTest.spec.js.map +1 -1
  129. package/target/test/frameworkBase/_ext/monadish/MonadTest.spec.js +31 -31
  130. package/target/test/frameworkBase/_ext/monadish/MonadTest.spec.js.map +1 -1
  131. package/target/test/frameworkBase/_ext/monadish/StreamTest.spec.js +50 -48
  132. package/target/test/frameworkBase/_ext/monadish/StreamTest.spec.js.map +1 -1
  133. package/target/test/frameworkBase/_ext/shared/StandardInits.js +310 -132
  134. package/target/test/frameworkBase/_ext/shared/StandardInits.js.map +1 -1
  135. package/target/test/frameworkBase/_ext/shared/XmlResponses.js +235 -22
  136. package/target/test/frameworkBase/_ext/shared/XmlResponses.js.map +1 -1
  137. package/target/test/impl/ImplTest.spec.js +32 -59
  138. package/target/test/impl/ImplTest.spec.js.map +1 -1
  139. package/target/test/impl/ImplTest_23.spec.js +32 -59
  140. package/target/test/impl/ImplTest_23.spec.js.map +1 -1
  141. package/target/test/impl/SeparatorCharsTest.spec.js +17 -17
  142. package/target/test/impl/SeparatorCharsTest.spec.js.map +1 -1
  143. package/target/test/myfaces/OamSubmit.spec.js +25 -25
  144. package/target/test/myfaces/OamSubmit.spec.js.map +1 -1
  145. package/target/test/queue/AsynchronousProbe.js +23 -29
  146. package/target/test/queue/AsynchronousProbe.js.map +1 -1
  147. package/target/test/queue/AsynchronousQueueTest.spec.js +39 -70
  148. package/target/test/queue/AsynchronousQueueTest.spec.js.map +1 -1
  149. package/target/test/xhrCore/EventTests.spec.js +43 -74
  150. package/target/test/xhrCore/EventTests.spec.js.map +1 -1
  151. package/target/test/xhrCore/FakeWebsocket.js +14 -16
  152. package/target/test/xhrCore/FakeWebsocket.js.map +1 -1
  153. package/target/test/xhrCore/FileUploadTest.spec.js +48 -78
  154. package/target/test/xhrCore/FileUploadTest.spec.js.map +1 -1
  155. package/target/test/xhrCore/NamespacesRequestTest.spec.js +204 -0
  156. package/target/test/xhrCore/NamespacesRequestTest.spec.js.map +1 -0
  157. package/target/test/xhrCore/OamSubmitTest.spec.js +180 -0
  158. package/target/test/xhrCore/OamSubmitTest.spec.js.map +1 -0
  159. package/target/test/xhrCore/RequestParamsTest.spec.js +174 -73
  160. package/target/test/xhrCore/RequestParamsTest.spec.js.map +1 -1
  161. package/target/test/xhrCore/RequestTest.spec.js +173 -149
  162. package/target/test/xhrCore/RequestTest.spec.js.map +1 -1
  163. package/target/test/xhrCore/RequestTest_23.spec.js +127 -142
  164. package/target/test/xhrCore/RequestTest_23.spec.js.map +1 -1
  165. package/target/test/xhrCore/ResponseTest.spec.js +415 -100
  166. package/target/test/xhrCore/ResponseTest.spec.js.map +1 -1
  167. package/target/test/xhrCore/ResponseTest23.spec.js +152 -91
  168. package/target/test/xhrCore/ResponseTest23.spec.js.map +1 -1
  169. package/target/test/xhrCore/ShadowDomTest.spec.js +30 -61
  170. package/target/test/xhrCore/ShadowDomTest.spec.js.map +1 -1
  171. package/target/test/xhrCore/WebsocketTest.js +60 -93
  172. package/target/test/xhrCore/WebsocketTest.js.map +1 -1
  173. package/target/test/xhrCore/XhrFormDataTest.spec.js +79 -30
  174. package/target/test/xhrCore/XhrFormDataTest.spec.js.map +1 -1
  175. package/target/test-classes/.gz +0 -0
  176. package/target/test-classes/com/example/jsfs_js_ts/JsfsJsTsApplicationTests.class +0 -0
  177. package/target/test-classes/fileuploadtest.html +24 -0
  178. package/target/test-classes/jsf-development.js +3559 -0
  179. package/target/test-classes/jsf-development.js.br +0 -0
  180. package/target/test-classes/jsf-development.js.gz +0 -0
  181. package/target/test-classes/jsf-development.js.map +1 -0
  182. package/target/test-classes/jsf.js +3 -0
  183. package/target/test-classes/jsf.js.br +0 -0
  184. package/target/test-classes/jsf.js.gz +0 -0
  185. package/tmp.xml +36 -0
@@ -91,6 +91,70 @@ export module StandardInits {
91
91
 
92
92
 
93
93
 
94
+ /**
95
+ * a page simulating basically a simple faces form
96
+ */
97
+ const HTML_FORM_PREFIXED = `<!DOCTYPE html>
98
+ <html lang="en">
99
+ <head>
100
+ <meta charset="UTF-8">
101
+ <title>Title</title>
102
+ </head>
103
+ <body>
104
+ <form id="form1">
105
+ <input type="text" id="form1:input_1::field" name="form1:input_1" value="form1:input_1_val"></input>
106
+ <input type="hidden" id="form1:jakarta.faces.ViewState" name="jakarta.faces.ViewState" value="blubbblubblubb"></input>
107
+ <input type="button" id="form1:input_2::field" name="form1:input_2" value="form1:input_1_val"></input>
108
+ <input type="text" id="form1:input_3::field" name="form1:input_23 value="form1:input_1_val"></input>
109
+ </form>
110
+ </body>
111
+ </html>`;
112
+
113
+
114
+
115
+ /**
116
+ * a page simulating basically a simple faces form
117
+ */
118
+ export const HTML_PREFIX_EMBEDDED_BODY = `<form id="form1">
119
+ <tobago-in id="page:input" class="tobago-auto-spacing">
120
+ <input type="text" name="page:input" id="page:input::field" class="form-control" value="input_value">
121
+ <tobago-behavior event="change" client-id="page:input" field-id="page:input::field" execute="page:input" render="page:output"></tobago-behavior>
122
+ </tobago-in>
123
+
124
+ <tobago-out id="page:output" class="tobago-auto-spacing">
125
+ <input type="text" name="page:output" id="page:output::field" class="form-control">
126
+ </tobago-out>
127
+ </form>`;
128
+
129
+ const HTML_FORM_PREFIXED_EMBEDDED = `<!DOCTYPE html>
130
+ <html lang="en">
131
+ <head>
132
+ <meta charset="UTF-8">
133
+ <title>Title</title>
134
+ </head>
135
+ <body>
136
+ ${HTML_PREFIX_EMBEDDED_BODY}
137
+ </body>
138
+ </html>`;
139
+
140
+
141
+ const HTML_FORM_NAMESPACED = `<!DOCTYPE html>
142
+ <html lang="en">
143
+ <head>
144
+ <meta charset="UTF-8">
145
+ <title>Title</title>
146
+ </head>
147
+ <body>
148
+ <form id="jd_0:blarg">
149
+ <input type="text" id="jd_0:input_1" name="jd_0:input_1" value="input_1_val"></input>
150
+ <input type="hidden" id="jd_0:jakarta.faces.ViewState" name="jakarta.faces.ViewState" value="blubbblubblubb"></input>
151
+ <input type="button" id="jd_0:input_2" name="input_2" value="input_1_val"></input>
152
+ </form>
153
+ </body>
154
+ </html>`;
155
+
156
+
157
+
94
158
  /**
95
159
  * a page simulating basically a simple faces form
96
160
  */
@@ -102,7 +166,7 @@ export module StandardInits {
102
166
  </head>
103
167
  <body>
104
168
  <form id="blarg" enctype="multipart/form-data">
105
- <input type="file" id="fíleupload"></input>
169
+ <input type="file" id="fíleupload" name="fíleupload"></input>
106
170
  <input type="text" id="input_1" name="input_1" value="input_1_val"></input>
107
171
  <input type="hidden" id="jakarta.faces.ViewState" name="jakarta.faces.ViewState" value="blubbblubblubb"></input>
108
172
  <input type="button" id="input_2" name="input_2" value="input_1_val"></input>
@@ -277,6 +341,9 @@ export module StandardInits {
277
341
  export function defaultMyFaces(withJsf = true): Promise<() => void> {
278
342
  return init(HTML_FORM_DEFAULT, withJsf);
279
343
  }
344
+ export function defaultMyFacesNamespaces(withJsf = true): Promise<() => void> {
345
+ return init(HTML_FORM_NAMESPACED, withJsf);
346
+ }
280
347
  export function defaultMyFaces23(withJsf = true): Promise<() => void> {
281
348
  return init(HTML_FORM_DEFAULT.replace(/jakarta/gi, "javax"), withJsf, false);
282
349
  }
@@ -302,6 +369,11 @@ export module StandardInits {
302
369
  return <any>init((IS_40) ? PROTOCOL_PAGE : PROTOCOL_PAGE.replace(/jakarta/gi,"javax"), withJsf, IS_40);
303
370
  }
304
371
 
372
+ export function prefixEmbeddedPage(withJsf = true, IS_40 = true): Promise<() => void> {
373
+ return <any>init((IS_40) ? HTML_FORM_PREFIXED_EMBEDDED : HTML_FORM_PREFIXED_EMBEDDED.replace(/jakarta/gi,"javax"), withJsf, IS_40);
374
+ }
375
+
376
+
305
377
  export function defaultSeparatorChar(separatorChar: string, withJsf = true, IS_40 = true): Promise<() => void> {
306
378
  let template = HTML_DEFAULT_SEPARATOR_CHAR(separatorChar, IS_40);
307
379
  return init(template, withJsf);
@@ -194,7 +194,7 @@ export class XmlResponses {
194
194
  <partial-response id="j_id__v_0"><changes><update id="jakarta.faces.Resource">
195
195
  <![CDATA[
196
196
  <script src="../../../xhrCore/fixtures/addedViewHead3.js"></script>
197
- <style type="text/css" rel="../../../xhrCore/fixtures/addedViewHead2.css"></style>
197
+ <link rel="stylesheet" href="../../../xhrCore/fixtures/addedViewHead2.css"></link>
198
198
  <script type="text/javascript">
199
199
  document.getElementById('resource_area_1').innerHTML = 'booga';
200
200
  </script>
@@ -204,6 +204,45 @@ export class XmlResponses {
204
204
  </partial-response>
205
205
  `
206
206
 
207
+ static HEAD_REPLACE = `
208
+ <partial-response id="j_id__v_0"><changes><update id="jakarta.faces.ViewHead">
209
+ <![CDATA[
210
+ <head>
211
+ <script type="text/javascript" src="../../../xhrCore/fixtures/addedViewHead3.js"></script>
212
+ <link rel="stylesheet" href="../../../xhrCore/fixtures/addedViewHead2.css"></link>
213
+ <script type="text/javascript">
214
+ setTimeout(() => document.getElementById('resource_area_1').innerHTML = 'booga', 100);
215
+ </script>
216
+ </head>
217
+ ]]>
218
+ </update>
219
+ </changes>
220
+ </partial-response>
221
+ `
222
+
223
+ static HEAD_REPLACE2 = `
224
+ <partial-response id="j_id__v_0"><changes><update id="jakarta.faces.ViewHead">
225
+ <![CDATA[
226
+ <head>
227
+ <title>After Update</title>
228
+ <meta charset="UTF-8">
229
+ <meta name="description" content="Free Web tutorials">
230
+ <meta name="keywords" content="HTML, CSS, JavaScript, JSF">
231
+ <meta name="viewport" content="width=device-width, initial-scale=0.8">
232
+ <meta name="author" content="Whoever">
233
+ <script type="text/javascript" src="../../../xhrCore/fixtures/addedViewHead3.js"></script>
234
+ <link rel="stylesheet" href="../../../xhrCore/fixtures/addedViewHead2.css"></link>
235
+ <script type="text/javascript">
236
+ setTimeout(() => document.getElementById('resource_area_1').innerHTML = 'booga', 100);
237
+ </script>
238
+ </head>
239
+ ]]>
240
+ </update>
241
+ </changes>
242
+ </partial-response>
243
+ `
244
+
245
+
207
246
  static NONCE_REPLY = `
208
247
  <partial-response><changes><update id='nonce_result'>
209
248
  <![CDATA[<script nonce='test12d3' type='text/javascript' src='http://foobaz/nonce_script.js'></script>]]>
@@ -20,7 +20,7 @@ import {expect} from 'chai';
20
20
  import * as sinon from 'sinon';
21
21
 
22
22
  import {StandardInits} from "../frameworkBase/_ext/shared/StandardInits";
23
- import {P_EXECUTE, P_RENDER} from "../../impl/core/Const";
23
+ import {CTX_PARAM_REQ_PASS_THR, P_EXECUTE, P_RENDER} from "../../impl/core/Const";
24
24
  import defaultMyFaces = StandardInits.defaultMyFaces;
25
25
 
26
26
 
@@ -60,9 +60,9 @@ describe('faces.ajax.request test suite', () => {
60
60
  expect(addRequestToQueue.callCount).to.eq(1);
61
61
  const context = (<Config>addRequestToQueue.args[0][2]);
62
62
 
63
- expect(context.getIf("passThrgh", P_RENDER).value).eq("@all");
63
+ expect(context.getIf(CTX_PARAM_REQ_PASS_THR, P_RENDER).value).eq("@all");
64
64
  //Execute issuing form due to @form and always the issuing element
65
- expect(context.getIf("passThrgh", P_EXECUTE).value).eq("blarg input_2");
65
+ expect(context.getIf(CTX_PARAM_REQ_PASS_THR, P_EXECUTE).value).eq("blarg input_2");
66
66
  } finally {
67
67
  //once done we restore the proper state
68
68
  addRequestToQueue.restore();
@@ -20,7 +20,7 @@ import {expect} from 'chai';
20
20
  import * as sinon from 'sinon';
21
21
 
22
22
  import {StandardInits} from "../frameworkBase/_ext/shared/StandardInits";
23
- import {P_EXECUTE, P_RENDER} from "../../impl/core/Const";
23
+ import {CTX_PARAM_REQ_PASS_THR, P_EXECUTE, P_RENDER} from "../../impl/core/Const";
24
24
  import defaultMyFaces23 = StandardInits.defaultMyFaces23;
25
25
 
26
26
 
@@ -60,9 +60,9 @@ describe('javax.ajax.request test suite', () => {
60
60
  expect(addRequestToQueue.callCount).to.eq(1);
61
61
  const context = (<Config>addRequestToQueue.args[0][2]);
62
62
 
63
- expect(context.getIf("passThrgh", P_RENDER).value).eq("@all");
63
+ expect(context.getIf(CTX_PARAM_REQ_PASS_THR, P_RENDER).value).eq("@all");
64
64
  //Execute issuing form due to @form and always the issuing element
65
- expect(context.getIf("passThrgh", P_EXECUTE).value).eq("blarg input_2");
65
+ expect(context.getIf(CTX_PARAM_REQ_PASS_THR, P_EXECUTE).value).eq("blarg input_2");
66
66
  } finally {
67
67
  //once done we restore the proper state
68
68
  addRequestToQueue.restore();
@@ -108,7 +108,7 @@ describe('tests the addOnEvent and addOnError handling', function () {
108
108
  expect(onErrorCalled1).to.eq(1);
109
109
  expect(onErrorCalled2).to.eq(1);
110
110
  expect(errorTitle).to.eq('Erro21');
111
- expect(errorMessage).to.eq('Error2 Text');
111
+ expect(errorMessage).to.eq('serverError: Error2 Text');
112
112
  });
113
113
 
114
114
  it("must have an id set if there is an emitting element", function () {
@@ -17,7 +17,7 @@ import {describe, it} from "mocha";
17
17
  import * as sinon from "sinon";
18
18
  import {expect} from "chai";
19
19
  import {StandardInits} from "../frameworkBase/_ext/shared/StandardInits";
20
- import {DomQuery} from "mona-dish";
20
+ import {DomQuery, DQ} from "mona-dish";
21
21
  import defaultFileForm = StandardInits.defaultFileForm;
22
22
  import {Implementation} from "../../impl/AjaxImpl";
23
23
 
@@ -66,6 +66,8 @@ describe('Tests on the xhr core when it starts to call the request', function ()
66
66
  const CONTENT_TYPE = "Content-Type";
67
67
  const POST = "POST";
68
68
 
69
+ global["debug_f"] = true;
70
+
69
71
  try {
70
72
 
71
73
  let button = DomQuery.byId("input_1");
@@ -128,11 +130,12 @@ describe('Tests on the xhr core when it starts to call the request', function ()
128
130
  const MULTIPART_FORM = "multipart/form-data";
129
131
  const POST = "POST";
130
132
 
133
+
131
134
  try {
132
135
  let button = DomQuery.byId("input_1");
133
136
 
134
137
  button.addEventListener("click", (event: Event) => {
135
- faces.ajax.request(event.target, event, {render: '@all', execute: 'input_1 fileupload'});
138
+ faces.ajax.request(event.target, event, {render: '@all', execute: '@none'});
136
139
  }).click();
137
140
 
138
141
  expect(this.requests.length).to.eq(1);
@@ -0,0 +1,203 @@
1
+ /*! Licensed to the Apache Software Foundation (ASF) under one or more
2
+ * contributor license agreements. See the NOTICE file distributed with
3
+ * this work for additional information regarding copyright ownership.
4
+ * The ASF licenses this file to you under the Apache License, Version 2.0
5
+ * (the "License"); you may not use this file except in compliance with
6
+ * the License. You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+
17
+ import {describe, it} from "mocha";
18
+ import * as sinon from "sinon";
19
+ import {expect} from "chai";
20
+ import {StandardInits} from "../frameworkBase/_ext/shared/StandardInits";
21
+ import {DomQuery, DQ$, Stream} from "mona-dish";
22
+ import {
23
+ $nsp,
24
+ COMPLETE,
25
+ P_AJAX,
26
+ P_EXECUTE,
27
+ P_PARTIAL_SOURCE,
28
+ P_RENDER,
29
+ P_VIEWSTATE,
30
+ P_WINDOW_ID,
31
+ SUCCESS
32
+ } from "../../impl/core/Const";
33
+ import defaultMyFaces = StandardInits.defaultMyFaces;
34
+ import STD_XML = StandardInits.STD_XML;
35
+ import defaultMyFacesNamespaces = StandardInits.defaultMyFacesNamespaces;
36
+ import {escape} from "querystring";
37
+
38
+ declare var faces: any;
39
+ declare var Implementation: any;
40
+
41
+ let issueStdReq = function (element) {
42
+ faces.ajax.request(element, null, {
43
+ execute: "input_1",
44
+ render: "@form",
45
+ params: {
46
+ pass1: "pass1",
47
+ pass2: "pass2"
48
+ }
49
+ });
50
+ };
51
+
52
+ describe('Namespacing tests', function () {
53
+ beforeEach(async function () {
54
+
55
+ let waitForResult = defaultMyFacesNamespaces();
56
+
57
+ return waitForResult.then((close) => {
58
+
59
+ this.xhr = sinon.useFakeXMLHttpRequest();
60
+ this.requests = [];
61
+ this.xhr.onCreate = (xhr) => {
62
+ this.requests.push(xhr);
63
+ };
64
+ (<any>global).XMLHttpRequest = this.xhr;
65
+ window.XMLHttpRequest = this.xhr;
66
+
67
+ this.jsfAjaxResponse = sinon.spy((<any>global).faces.ajax, "response");
68
+
69
+ this.closeIt = () => {
70
+ (<any>global).XMLHttpRequest = window.XMLHttpRequest = this.xhr.restore();
71
+ this.jsfAjaxResponse.restore();
72
+ Implementation.reset();
73
+ close();
74
+ }
75
+ });
76
+ });
77
+
78
+ afterEach(function () {
79
+ this.closeIt();
80
+ });
81
+
82
+ it('must send the element identifiers properly encoded', function () {
83
+ let send = sinon.spy(XMLHttpRequest.prototype, "send");
84
+ try {
85
+ global["debug3"] = true;
86
+ faces.ajax.request(document.getElementById("jd_0:input_2"), null, {
87
+ execute: ":input_1",
88
+ render: ":blarg :input_2",
89
+ params: {
90
+ pass1: "pass1",
91
+ pass2: "pass2"
92
+ }
93
+ });
94
+
95
+ expect(send.called).to.be.true;
96
+ let argsVal: any = send.args[0][0];
97
+ let arsArr = argsVal.split("&");
98
+ let resultsMap = {};
99
+ for (let val of arsArr) {
100
+ let keyVal = val.split("=");
101
+ resultsMap[keyVal[0]] = keyVal[1];
102
+ }
103
+
104
+ expect(resultsMap["pass1"]).to.eq("pass1");
105
+ expect(resultsMap["pass2"]).to.eq("pass2");
106
+ expect(!!resultsMap["render"]).to.be.false;
107
+ expect(!!resultsMap["execute"]).to.be.false;
108
+ expect(P_WINDOW_ID in resultsMap).to.be.false;
109
+ expect(P_VIEWSTATE in resultsMap).to.be.true;
110
+ expect(resultsMap[P_PARTIAL_SOURCE]).to.eq(escape("jd_0:input_2"));
111
+ expect(resultsMap[P_AJAX]).to.eq("true");
112
+ expect(resultsMap[P_RENDER]).to.eq(escape("jd_0:blarg jd_0:input_2"));
113
+ expect(resultsMap[P_EXECUTE]).to.eq(escape("jd_0:input_1 jd_0:input_2"));
114
+ } finally {
115
+ send.restore();
116
+ }
117
+ })
118
+
119
+ it('must send the element identifiers properly encoded 2', function () {
120
+ let send = sinon.spy(XMLHttpRequest.prototype, "send");
121
+ try {
122
+ faces.ajax.request(document.getElementById("jd_0:input_2"), null, {
123
+ execute: "jd_0:input_1",
124
+ render: ":blarg jd_0:input_2",
125
+ params: {
126
+ pass1: "pass1",
127
+ pass2: "pass2"
128
+ }
129
+ });
130
+
131
+ expect(send.called).to.be.true;
132
+ let argsVal: any = send.args[0][0];
133
+ let arsArr = argsVal.split("&");
134
+ let resultsMap = {};
135
+ for (let val of arsArr) {
136
+ let keyVal = val.split("=");
137
+ resultsMap[keyVal[0]] = keyVal[1];
138
+ }
139
+
140
+ expect(resultsMap["pass1"]).to.eq("pass1");
141
+ expect(resultsMap["pass2"]).to.eq("pass2");
142
+ expect(!!resultsMap["render"]).to.be.false;
143
+ expect(!!resultsMap["execute"]).to.be.false;
144
+ expect(P_WINDOW_ID in resultsMap).to.be.false;
145
+ expect(P_VIEWSTATE in resultsMap).to.be.true;
146
+ expect(resultsMap[P_PARTIAL_SOURCE]).to.eq(escape("jd_0:input_2"));
147
+ expect(resultsMap[P_AJAX]).to.eq("true");
148
+ expect(resultsMap[P_RENDER]).to.eq(escape("jd_0:blarg jd_0:input_2"));
149
+ expect(resultsMap[P_EXECUTE]).to.eq(escape("jd_0:input_1 jd_0:input_2"));
150
+ } finally {
151
+ send.restore();
152
+ }
153
+ })
154
+
155
+
156
+ it('must get name prefixed viewstate properly', function () {
157
+ let send = sinon.spy(XMLHttpRequest.prototype, "send");
158
+ try {
159
+ DQ$(`[name*='${P_VIEWSTATE}']`).attr("name").value = `jd_0:${P_VIEWSTATE}`;
160
+ DQ$(`[name*='${P_VIEWSTATE}']`).val = "booga";
161
+
162
+ faces.ajax.request(document.getElementById("jd_0:input_2"), null, {
163
+ execute: "jd_0:input_1",
164
+ render: ":blarg jd_0:input_2",
165
+ params: {
166
+ pass1: "pass1",
167
+ pass2: "pass2"
168
+ }
169
+ });
170
+
171
+ expect(send.called).to.be.true;
172
+ let argsVal: any = send.args[0][0];
173
+ let arsArr = argsVal.split("&");
174
+ let resultsMap = {};
175
+ for (let val of arsArr) {
176
+ let keyVal = val.split("=");
177
+ resultsMap[unescape(keyVal[0])] = unescape(keyVal[1]);
178
+ }
179
+ const NAMING_CONTAINER_PREF = "jd_0:";
180
+ expect(resultsMap[NAMING_CONTAINER_PREF + "pass1"]).to.eq("pass1");
181
+ expect(resultsMap[NAMING_CONTAINER_PREF + "pass2"]).to.eq("pass2");
182
+ expect(!!resultsMap["render"]).to.be.false;
183
+ expect(!!resultsMap["execute"]).to.be.false;
184
+
185
+ let hasWindowdId = Stream.ofAssoc(resultsMap).filter(data => data[0].indexOf(P_WINDOW_ID) != -1).first().isPresent();
186
+ let hasViewState = Stream.ofAssoc(resultsMap).filter(data => data[0].indexOf(P_VIEWSTATE) != -1).first().isPresent();
187
+
188
+ expect(hasWindowdId).to.be.false;
189
+ expect(hasViewState).to.be.true;
190
+
191
+ let viewState = Stream.ofAssoc(resultsMap).filter(data => data[0].indexOf(P_VIEWSTATE) != -1).map(item => item[1]).first().value;
192
+
193
+ expect(viewState).to.eq("booga");
194
+ expect(resultsMap[NAMING_CONTAINER_PREF + P_PARTIAL_SOURCE]).to.eq("jd_0:input_2");
195
+ expect(resultsMap[NAMING_CONTAINER_PREF + P_AJAX]).to.eq("true");
196
+ expect(resultsMap[NAMING_CONTAINER_PREF + P_RENDER]).to.eq("jd_0:blarg jd_0:input_2");
197
+ expect(resultsMap[NAMING_CONTAINER_PREF + P_EXECUTE]).to.eq("jd_0:input_1 jd_0:input_2");
198
+ } finally {
199
+ send.restore();
200
+ }
201
+ })
202
+
203
+ });
@@ -0,0 +1,177 @@
1
+ /*! Licensed to the Apache Software Foundation (ASF) under one or more
2
+ * contributor license agreements. See the NOTICE file distributed with
3
+ * this work for additional information regarding copyright ownership.
4
+ * The ASF licenses this file to you under the Apache License, Version 2.0
5
+ * (the "License"); you may not use this file except in compliance with
6
+ * the License. You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+
17
+ import {describe} from "mocha";
18
+ import * as sinon from "sinon";
19
+ import {Implementation} from "../../impl/AjaxImpl";
20
+ import {StandardInits} from "../frameworkBase/_ext/shared/StandardInits";
21
+ import defaultMyFaces = StandardInits.defaultMyFaces;
22
+ import {DQ, DQ$} from "mona-dish";
23
+ import {expect} from "chai";
24
+
25
+ describe('Tests for the MyFaces specifig oam submit', function () {
26
+
27
+ beforeEach(async function () {
28
+
29
+ let waitForResult = defaultMyFaces();
30
+
31
+ return waitForResult.then((close) => {
32
+
33
+ this.xhr = sinon.useFakeXMLHttpRequest();
34
+ this.requests = [];
35
+ this.xhr.onCreate = (xhr) => {
36
+ this.requests.push(xhr);
37
+ };
38
+ (<any>global).XMLHttpRequest = this.xhr;
39
+ window.XMLHttpRequest = this.xhr;
40
+
41
+ this.jsfAjaxResponse = sinon.spy((<any>global).faces.ajax, "response");
42
+
43
+ this.closeIt = () => {
44
+ (<any>global).XMLHttpRequest = window.XMLHttpRequest = this.xhr.restore();
45
+ this.jsfAjaxResponse.restore();
46
+ Implementation.reset();
47
+ close();
48
+ }
49
+ });
50
+ });
51
+
52
+ afterEach(function () {
53
+ this.closeIt();
54
+ });
55
+
56
+ it(("must handle oam submit correctly, tuples"), (done) => {
57
+
58
+ let options = [["booga1", "value1"], ["booga2", "value2"]];
59
+
60
+ (DQ.byId("blarg")
61
+ .getAsElem(0).value as HTMLFormElement).onsubmit = (evt) => {
62
+ expect(DQ$("#blarg #booga1").inputValue.value).to.eq("value1");
63
+ expect(DQ$("#blarg #booga2").inputValue.value).to.eq("value2");
64
+ done();
65
+ return false;
66
+ };
67
+
68
+ myfaces.oam.submitForm("blarg", null, null, options);
69
+
70
+ });
71
+ it(("must handle oam submit correctly, associative array"), (done) => {
72
+
73
+ let options = {"booga1": "value1", "booga2": "value2"};
74
+
75
+ (DQ.byId("blarg")
76
+ .getAsElem(0).value as HTMLFormElement).onsubmit = (evt) => {
77
+ expect(DQ$("#blarg #booga1").inputValue.value).to.eq("value1");
78
+ expect(DQ$("#blarg #booga2").inputValue.value).to.eq("value2");
79
+ done();
80
+ return false;
81
+ };
82
+
83
+ myfaces.oam.submitForm("blarg", null, null, options);
84
+
85
+ });
86
+
87
+ it(("all hidden inputs must be cleared post submit"), (done) => {
88
+
89
+ let options = {"booga1": "value1", "booga2": "value2"};
90
+
91
+ (DQ.byId("blarg")
92
+ .getAsElem(0).value as HTMLFormElement).onsubmit = (evt) => {
93
+ expect(DQ$("#blarg #booga1").length).to.eq(1);
94
+ expect(DQ$("#blarg #booga2").length).to.eq(1);
95
+ return false;
96
+ };
97
+
98
+ myfaces.oam.submitForm("blarg", null, null, options);
99
+
100
+ expect(DQ$("#blarg #booga1").length).to.eq(0);
101
+ expect(DQ$("#blarg #booga2").length).to.eq(0);
102
+ done();
103
+ });
104
+
105
+ it(("must handle linkid correctly, associative array"), (done) => {
106
+
107
+ let options = {"booga1": "value1", "booga2": "value2"};
108
+
109
+ (DQ.byId("blarg")
110
+ .getAsElem(0).value as HTMLFormElement).onsubmit = (evt) => {
111
+ expect(DQ.byId(`blarg:_idcl`).inputValue.value).to.eq("bla");
112
+ done();
113
+ return false;
114
+ };
115
+
116
+ myfaces.oam.submitForm("blarg", "bla", null, options);
117
+
118
+ });
119
+
120
+ it(("must handle target correctly, associative array"), (done) => {
121
+
122
+ let options = {"booga1": "value1", "booga2": "value2"};
123
+ (DQ.byId("blarg")
124
+ .getAsElem(0).value as HTMLFormElement).onsubmit = (evt) => {
125
+ expect(DQ$(`#blarg`).attr("target").value).to.eq("target1");
126
+ done();
127
+ return false;
128
+ };
129
+ myfaces.oam.submitForm("blarg", "bla", "target1", options);
130
+
131
+ });
132
+
133
+ it(("must handle limited parameters"), (done) => {
134
+
135
+ (DQ.byId("blarg")
136
+ .getAsElem(0).value as HTMLFormElement).onsubmit = (evt) => {
137
+ expect(DQ.byId(`blarg:_idcl`).inputValue.value).to.eq("bla");
138
+ done();
139
+ return false;
140
+ };
141
+ try {
142
+ myfaces.oam.submitForm("blarg", "bla");
143
+ } catch(e) {
144
+ done(e);
145
+ }
146
+
147
+ });
148
+ it(("must handle limited parameters 2"), (done) => {
149
+
150
+ (DQ.byId("blarg")
151
+ .getAsElem(0).value as HTMLFormElement).onsubmit = (evt) => {
152
+ expect(DQ.byId(`blarg:_idcl`).inputValue.value).to.eq("bla");
153
+ done();
154
+ return false;
155
+ };
156
+ try {
157
+ myfaces.oam.submitForm("blarg", "bla", null);
158
+ } catch(e) {
159
+ done(e);
160
+ }
161
+ });
162
+ it(("must handle limited parameters 3"), (done) => {
163
+
164
+ (DQ.byId("blarg")
165
+ .getAsElem(0).value as HTMLFormElement).onsubmit = (evt) => {
166
+ expect(DQ.byId(`blarg:_idcl`).inputValue.value).to.eq("bla");
167
+ done();
168
+ return false;
169
+ };
170
+ try {
171
+ myfaces.oam.submitForm("blarg", "bla", null, null);
172
+ } catch(e) {
173
+ done(e);
174
+ }
175
+ });
176
+
177
+ });