jsf.js_next_gen 4.0.0-beta-23 → 4.0.0

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 (200) hide show
  1. package/.nyc_output/09ca9ebc-2305-4357-8db9-48ddfc7dfde2.json +1 -0
  2. package/.nyc_output/7c496a14-166e-4aa5-85b9-47b22b055ad8.json +1 -0
  3. package/.nyc_output/processinfo/09ca9ebc-2305-4357-8db9-48ddfc7dfde2.json +1 -0
  4. package/.nyc_output/processinfo/7c496a14-166e-4aa5-85b9-47b22b055ad8.json +1 -0
  5. package/.nyc_output/processinfo/index.json +1 -1
  6. package/README.md +7 -22
  7. package/dist/docs/assets/main.js +56 -52
  8. package/dist/docs/assets/search.js +1 -1
  9. package/dist/docs/assets/style.css +23 -0
  10. package/dist/docs/functions/faces.ajax.addOnError.html +6 -4
  11. package/dist/docs/functions/faces.ajax.addOnEvent.html +2 -0
  12. package/dist/docs/functions/faces.ajax.request.html +7 -7
  13. package/dist/docs/functions/faces.ajax.response.html +0 -1
  14. package/dist/docs/functions/faces.push.close.html +4 -2
  15. package/dist/docs/functions/faces.push.init.html +19 -7
  16. package/dist/docs/functions/faces.push.open.html +4 -2
  17. package/dist/docs/functions/faces.util.chain.html +3 -3
  18. package/dist/docs/functions/myfaces.ab.html +9 -4
  19. package/dist/docs/functions/myfaces.onOnDomReady.html +72 -0
  20. package/dist/docs/index.html +7 -18
  21. package/dist/docs/modules/myfaces.html +3 -1
  22. package/dist/docs/variables/myfaces.oam.html +2 -1
  23. package/dist/window/faces-development.js +2147 -1779
  24. package/dist/window/faces-development.js.br +0 -0
  25. package/dist/window/faces-development.js.gz +0 -0
  26. package/dist/window/faces-development.js.map +1 -1
  27. package/dist/window/faces.js +1 -1
  28. package/dist/window/faces.js.LICENSE.txt +17 -2
  29. package/dist/window/faces.js.br +0 -0
  30. package/dist/window/faces.js.gz +0 -0
  31. package/dist/window/faces.js.map +1 -1
  32. package/dist/window/jsf-development.js +2156 -1777
  33. package/dist/window/jsf-development.js.br +0 -0
  34. package/dist/window/jsf-development.js.gz +0 -0
  35. package/dist/window/jsf-development.js.map +1 -1
  36. package/dist/window/jsf.js +1 -1
  37. package/dist/window/jsf.js.LICENSE.txt +17 -2
  38. package/dist/window/jsf.js.br +0 -0
  39. package/dist/window/jsf.js.gz +0 -0
  40. package/dist/window/jsf.js.map +1 -1
  41. package/package.json +19 -18
  42. package/pom.xml +1 -1
  43. package/src/main/test.xml +23 -0
  44. package/src/main/typescript/@types/definitions/index.d.ts +24 -7
  45. package/src/main/typescript/api/_api.ts +79 -37
  46. package/src/main/typescript/api/jsf.ts +18 -0
  47. package/src/main/typescript/impl/AjaxImpl.ts +168 -78
  48. package/src/main/typescript/impl/PushImpl.ts +63 -38
  49. package/src/main/typescript/impl/core/Const.ts +52 -39
  50. package/src/main/typescript/impl/util/Assertions.ts +16 -8
  51. package/src/main/typescript/impl/util/AsyncQueue.ts +1 -1
  52. package/src/main/typescript/impl/util/AsyncRunnable.ts +4 -4
  53. package/src/main/typescript/impl/util/ExtDomQuery.ts +58 -45
  54. package/src/main/typescript/impl/util/FileUtils.ts +104 -0
  55. package/src/main/typescript/impl/util/HiddenInputBuilder.ts +89 -0
  56. package/src/main/typescript/impl/util/Lang.ts +30 -31
  57. package/src/main/typescript/impl/xhrCore/ErrorData.ts +15 -10
  58. package/src/main/typescript/impl/xhrCore/EventData.ts +2 -2
  59. package/src/main/typescript/impl/xhrCore/IResponseProcessor.ts +25 -11
  60. package/src/main/typescript/impl/xhrCore/RequestDataResolver.ts +78 -32
  61. package/src/main/typescript/impl/xhrCore/ResonseDataResolver.ts +10 -10
  62. package/src/main/typescript/impl/xhrCore/Response.ts +66 -49
  63. package/src/main/typescript/impl/xhrCore/ResponseProcessor.ts +202 -131
  64. package/src/main/typescript/impl/xhrCore/XhrFormData.ts +79 -166
  65. package/src/main/typescript/impl/xhrCore/XhrRequest.ts +80 -68
  66. package/src/main/typescript/myfaces/OamSubmit.ts +29 -13
  67. package/src/main/typescript/test/frameworkBase/_ext/monadish/DomQueryTest.spec.ts +19 -22
  68. package/src/main/typescript/test/frameworkBase/_ext/shared/StandardInits.ts +108 -1
  69. package/src/main/typescript/test/frameworkBase/_ext/shared/XmlResponses.ts +40 -1
  70. package/src/main/typescript/test/impl/ImplTest.spec.ts +3 -3
  71. package/src/main/typescript/test/impl/ImplTest_23.spec.ts +3 -7
  72. package/src/main/typescript/test/xhrCore/EventTests.spec.ts +1 -1
  73. package/src/main/typescript/test/xhrCore/FileUploadTest.spec.ts +5 -2
  74. package/src/main/typescript/test/xhrCore/NamespacesRequestTest.spec.ts +203 -0
  75. package/src/main/typescript/test/xhrCore/OamSubmitTest.spec.ts +177 -0
  76. package/src/main/typescript/test/xhrCore/RequestParamsTest.spec.ts +158 -17
  77. package/src/main/typescript/test/xhrCore/RequestTest.spec.ts +242 -11
  78. package/src/main/typescript/test/xhrCore/RequestTest_23.spec.ts +39 -3
  79. package/src/main/typescript/test/xhrCore/ResponseTest.spec.ts +373 -35
  80. package/src/main/typescript/test/xhrCore/ResponseTest23.spec.ts +43 -9
  81. package/src/main/typescript/test/xhrCore/TobagoFileUploadTest.spec.ts +109 -0
  82. package/src/main/typescript/test/xhrCore/XhrFormDataTest.spec.ts +67 -49
  83. package/src/main/typescript/test.xml +6 -0
  84. package/src/main/typescript/tsconfig.json +1 -1
  85. package/src/test/resources/jsf-development.js +1 -1
  86. package/src/tmp/test.html +12 -88
  87. package/target/api/_api.js +72 -31
  88. package/target/api/_api.js.map +1 -1
  89. package/target/api/jsf.js +11 -0
  90. package/target/api/jsf.js.map +1 -1
  91. package/target/classes/com/example/jsfs_js_ts/DecoratedFacesJS.class +0 -0
  92. package/target/classes/com/example/jsfs_js_ts/DecoratingResourceHandlerWrapper.class +0 -0
  93. package/target/classes/com/example/jsfs_js_ts/FacesJSMapFileResourceWrapper.class +0 -0
  94. package/target/classes/com/example/jsfs_js_ts/FacesJSMappingDecorator.class +0 -0
  95. package/target/impl/AjaxImpl.js +144 -59
  96. package/target/impl/AjaxImpl.js.map +1 -1
  97. package/target/impl/PushImpl.js +66 -35
  98. package/target/impl/PushImpl.js.map +1 -1
  99. package/target/impl/core/Const.js +51 -38
  100. package/target/impl/core/Const.js.map +1 -1
  101. package/target/impl/core/Context.js +10 -0
  102. package/target/impl/core/Context.js.map +1 -0
  103. package/target/impl/util/Assertions.js +12 -7
  104. package/target/impl/util/Assertions.js.map +1 -1
  105. package/target/impl/util/AsyncQueue.js.map +1 -1
  106. package/target/impl/util/ExtDomQuery.js +58 -40
  107. package/target/impl/util/ExtDomQuery.js.map +1 -1
  108. package/target/impl/util/FileUtils.js +96 -0
  109. package/target/impl/util/FileUtils.js.map +1 -0
  110. package/target/impl/util/HiddenElementBuilder.js +7 -0
  111. package/target/impl/util/HiddenElementBuilder.js.map +1 -0
  112. package/target/impl/util/HiddenInputBuilder.js +79 -0
  113. package/target/impl/util/HiddenInputBuilder.js.map +1 -0
  114. package/target/impl/util/Lang.js +29 -30
  115. package/target/impl/util/Lang.js.map +1 -1
  116. package/target/impl/util/URLCodec.js +77 -0
  117. package/target/impl/util/URLCodec.js.map +1 -0
  118. package/target/impl/util/XhrQueueController.js +82 -0
  119. package/target/impl/util/XhrQueueController.js.map +1 -0
  120. package/target/impl/xhrCore/ErrorData.js +10 -8
  121. package/target/impl/xhrCore/ErrorData.js.map +1 -1
  122. package/target/impl/xhrCore/EventData.js +1 -1
  123. package/target/impl/xhrCore/EventData.js.map +1 -1
  124. package/target/impl/xhrCore/RequestContext.js +11 -0
  125. package/target/impl/xhrCore/RequestContext.js.map +1 -0
  126. package/target/impl/xhrCore/RequestDataResolver.js +70 -23
  127. package/target/impl/xhrCore/RequestDataResolver.js.map +1 -1
  128. package/target/impl/xhrCore/ResonseDataResolver.js +9 -9
  129. package/target/impl/xhrCore/ResonseDataResolver.js.map +1 -1
  130. package/target/impl/xhrCore/Response.js +44 -29
  131. package/target/impl/xhrCore/Response.js.map +1 -1
  132. package/target/impl/xhrCore/ResponseProcessor.js +182 -116
  133. package/target/impl/xhrCore/ResponseProcessor.js.map +1 -1
  134. package/target/impl/xhrCore/XhrFormData.js +68 -156
  135. package/target/impl/xhrCore/XhrFormData.js.map +1 -1
  136. package/target/impl/xhrCore/XhrQueHandler.js +11 -0
  137. package/target/impl/xhrCore/XhrQueHandler.js.map +1 -0
  138. package/target/impl/xhrCore/XhrQueueController.js +62 -0
  139. package/target/impl/xhrCore/XhrQueueController.js.map +1 -0
  140. package/target/impl/xhrCore/XhrRequest.js +68 -59
  141. package/target/impl/xhrCore/XhrRequest.js.map +1 -1
  142. package/target/myfaces/OamSubmit.js +23 -14
  143. package/target/myfaces/OamSubmit.js.map +1 -1
  144. package/target/test/frameworkBase/_ext/monadish/DomQueryTest.spec.js +16 -16
  145. package/target/test/frameworkBase/_ext/monadish/DomQueryTest.spec.js.map +1 -1
  146. package/target/test/frameworkBase/_ext/monadish/ExtendedArrayTest.spec.js +76 -0
  147. package/target/test/frameworkBase/_ext/monadish/ExtendedArrayTest.spec.js.map +1 -0
  148. package/target/test/frameworkBase/_ext/monadish/markups/tobago-with-header.js +925 -0
  149. package/target/test/frameworkBase/_ext/monadish/markups/tobago-with-header.js.map +1 -0
  150. package/target/test/frameworkBase/_ext/monadish/markups/tobago-without-header.js +112 -0
  151. package/target/test/frameworkBase/_ext/monadish/markups/tobago-without-header.js.map +1 -0
  152. package/target/test/frameworkBase/_ext/shared/StandardInits.js +100 -1
  153. package/target/test/frameworkBase/_ext/shared/StandardInits.js.map +1 -1
  154. package/target/test/frameworkBase/_ext/shared/XmlResponses.js +37 -1
  155. package/target/test/frameworkBase/_ext/shared/XmlResponses.js.map +1 -1
  156. package/target/test/impl/ImplTest.spec.js +2 -2
  157. package/target/test/impl/ImplTest.spec.js.map +1 -1
  158. package/target/test/impl/ImplTest_23.spec.js +2 -2
  159. package/target/test/impl/ImplTest_23.spec.js.map +1 -1
  160. package/target/test/myfaces/OnLoadSpec.js +57 -0
  161. package/target/test/myfaces/OnLoadSpec.js.map +1 -0
  162. package/target/test/xhrCore/EventTests.spec.js +1 -1
  163. package/target/test/xhrCore/EventTests.spec.js.map +1 -1
  164. package/target/test/xhrCore/FileUploadTest.spec.js +2 -1
  165. package/target/test/xhrCore/FileUploadTest.spec.js.map +1 -1
  166. package/target/test/xhrCore/NamespacesRequestTest.spec.js +204 -0
  167. package/target/test/xhrCore/NamespacesRequestTest.spec.js.map +1 -0
  168. package/target/test/xhrCore/OamSubmitTest.spec.js +180 -0
  169. package/target/test/xhrCore/OamSubmitTest.spec.js.map +1 -0
  170. package/target/test/xhrCore/RequestParamsTest.spec.js +142 -10
  171. package/target/test/xhrCore/RequestParamsTest.spec.js.map +1 -1
  172. package/target/test/xhrCore/RequestTest.spec.js +217 -9
  173. package/target/test/xhrCore/RequestTest.spec.js.map +1 -1
  174. package/target/test/xhrCore/RequestTest_23.spec.js +34 -2
  175. package/target/test/xhrCore/RequestTest_23.spec.js.map +1 -1
  176. package/target/test/xhrCore/ResponseTest.spec.js +308 -24
  177. package/target/test/xhrCore/ResponseTest.spec.js.map +1 -1
  178. package/target/test/xhrCore/ResponseTest23.spec.js +38 -8
  179. package/target/test/xhrCore/ResponseTest23.spec.js.map +1 -1
  180. package/target/test/xhrCore/TobagoFileUploadTest.spec.js +128 -0
  181. package/target/test/xhrCore/TobagoFileUploadTest.spec.js.map +1 -0
  182. package/target/test/xhrCore/XhrFormDataTest.spec.js +57 -34
  183. package/target/test/xhrCore/XhrFormDataTest.spec.js.map +1 -1
  184. package/target/test-classes/.gz +0 -0
  185. package/target/test-classes/com/example/jsfs_js_ts/JsfsJsTsApplicationTests.class +0 -0
  186. package/target/test-classes/fileuploadtest.html +24 -0
  187. package/target/test-classes/jsf-development.js +3559 -0
  188. package/target/test-classes/jsf-development.js.br +0 -0
  189. package/target/test-classes/jsf-development.js.gz +0 -0
  190. package/target/test-classes/jsf-development.js.map +1 -0
  191. package/target/test-classes/jsf.js +3 -0
  192. package/target/test-classes/jsf.js.br +0 -0
  193. package/target/test-classes/jsf.js.gz +0 -0
  194. package/tmp.xml +36 -0
  195. package/.nyc_output/2303b649-59d9-485c-9228-73b0ec8787a7.json +0 -1
  196. package/.nyc_output/756f2f03-c85b-4cdb-9b92-5799eb45ef1e.json +0 -1
  197. package/.nyc_output/processinfo/2303b649-59d9-485c-9228-73b0ec8787a7.json +0 -1
  198. package/.nyc_output/processinfo/756f2f03-c85b-4cdb-9b92-5799eb45ef1e.json +0 -1
  199. package/target/types/index.js +0 -18
  200. package/target/types/index.js.map +0 -1
@@ -21,9 +21,9 @@ import * as sinon from "sinon";
21
21
 
22
22
  import {XmlResponses} from "../frameworkBase/_ext/shared/XmlResponses";
23
23
  import {expect} from "chai";
24
- import {DomQuery, DQ} from "mona-dish";
24
+ import {DomQuery, DQ, DQ$} from "mona-dish";
25
25
  import protocolPage = StandardInits.protocolPage;
26
- import exp from "constants";
26
+
27
27
 
28
28
  declare var faces: any;
29
29
  declare var Implementation: any;
@@ -32,7 +32,7 @@ declare var Implementation: any;
32
32
  * response test
33
33
  * the idea is simply to pass in a dom
34
34
  * the context and a response xml and then check what happens
35
- * we do not need to to through the entire ajax cyle for that.
35
+ * we do not need to go through the entire ajax cycle for that.
36
36
  */
37
37
  describe('Tests of the various aspects of the response protocol functionality', function () {
38
38
 
@@ -199,7 +199,7 @@ describe('Tests of the various aspects of the response protocol functionality',
199
199
  "embedded scripts must be executed").to.be.true;
200
200
  });
201
201
 
202
- it("must have a viewstate update to be peformed", function () {
202
+ it("must have a viewState update to be performed", function () {
203
203
  DQ.byId("cmd_viewstate").click();
204
204
 
205
205
  this.respond(XmlResponses.VIEWSTATE_1);
@@ -225,11 +225,11 @@ describe('Tests of the various aspects of the response protocol functionality',
225
225
 
226
226
  });
227
227
 
228
- it("must have updated the viewstates properly", function () {
228
+ it("must have updated the viewstates properly", function (done) {
229
229
  DQ.byId("cmd_eval").click();
230
230
  /*js full submit form, coming from the integration tests*/
231
231
  window.document.body.innerHTML = `<form id="j_id__v_0" name="j_id__v_0" method="post" action="/IntegrationJSTest/integrationtestsjasmine/test7-eventtest.jsf"
232
- enctype="application/x-www-form-urlencoded"><span id="updatePanel">hello world</span><a href="#"
232
+ ><span id="updatePanel">hello world</span><a href="#"
233
233
  onclick="return faces.util.chain(this, event,'return false;', 'return myfaces.ab(\'j_id_1l\',\'updateTrigger\');');"
234
234
  id="updateTrigger"
235
235
  name="updateTrigger"
@@ -245,18 +245,18 @@ describe('Tests of the various aspects of the response protocol functionality',
245
245
 
246
246
  // language=XML
247
247
  this.respond(`<?xml version="1.0" encoding="UTF-8"?>
248
- <partial-response id="j_id__v_0">
249
- <changes>
250
- <update id="updatePanel"><![CDATA[<span id="updatePanel">hello world</span>]]></update>
251
- <update id="j_id__v_0:jakarta.faces.ViewState:1"><![CDATA[RTUyRDI0NzE4QzAxM0E5RDAwMDAwMDVD]]></update>
252
- </changes>
253
- </partial-response>`);
254
-
248
+ <partial-response id="j_id__v_0">
249
+ <changes>
250
+ <update id="updatePanel"><![CDATA[<span id="updatePanel">hello world</span>]]></update>
251
+ <update id="j_id__v_0:jakarta.faces.ViewState:1"><![CDATA[RTUyRDI0NzE4QzAxM0E5RDAwMDAwMDVD]]></update>
252
+ </changes>
253
+ </partial-response>`);
255
254
 
256
- expect(DQ.byId("jakarta.faces.ViewState").isAbsent()).to.be.false;
257
-
258
- expect((<HTMLInputElement>document.getElementById("jakarta.faces.ViewState")).value == "RTUyRDI0NzE4QzAxM0E5RDAwMDAwMDVD").to.be.true;
259
- expect(DQ.byId("jakarta.faces.ViewState").inputValue.value == "RTUyRDI0NzE4QzAxM0E5RDAwMDAwMDVD").to.be.true;
255
+ setTimeout(() => {
256
+ expect(DQ$("[name*='jakarta.faces.ViewState']").isPresent()).to.be.true;
257
+ expect(DQ$("[name*='jakarta.faces.ViewState']").val == "RTUyRDI0NzE4QzAxM0E5RDAwMDAwMDVD").to.be.true;
258
+ done();
259
+ }, 100);
260
260
  });
261
261
 
262
262
 
@@ -264,7 +264,7 @@ describe('Tests of the various aspects of the response protocol functionality',
264
264
  DQ.byId("cmd_eval").click();
265
265
  /*js full submit form, coming from the integration tests*/
266
266
  window.document.body.innerHTML = `<form id="j_id__v_0" name="j_id__v_0" method="post" action="/IntegrationJSTest/integrationtestsjasmine/test7-eventtest.jsf"
267
- enctype="application/x-www-form-urlencoded"><span id="updatePanel">hello world</span><a href="#"
267
+ ><span id="updatePanel">hello world</span><a href="#"
268
268
  onclick="return faces.util.chain(this, event,'return false;', 'return myfaces.ab(\'j_id_1l\',\'updateTrigger\');');"
269
269
  id="updateTrigger"
270
270
  name="updateTrigger"
@@ -280,20 +280,20 @@ describe('Tests of the various aspects of the response protocol functionality',
280
280
 
281
281
  // language=XML
282
282
  this.respond(`<?xml version="1.0" encoding="UTF-8"?>
283
- <partial-response id="j_id__v_0">
284
- <changes>
285
- <update id="updatePanel"><![CDATA[<span id="updatePanel">hello world</span>]]></update>
286
- <update id="j_id__v_0:jakarta.faces.ViewState:1"><![CDATA[RTUyRDI0NzE4QzAxM0E5RDAwMDAwMDVD]]><!--
283
+ <partial-response id="j_id__v_0">
284
+ <changes>
285
+ <update id="updatePanel"><![CDATA[<span id="updatePanel">hello world</span>]]></update>
286
+ <update id="j_id__v_0:jakarta.faces.ViewState:1"><![CDATA[RTUyRDI0NzE4QzAxM0E5RDAwMDAwMDVD]]><!--
287
287
  Some random junk which is sent by the server
288
288
  --></update>
289
- </changes>
290
- </partial-response>`);
289
+ </changes>
290
+ </partial-response>`);
291
291
 
292
292
 
293
- expect(DQ.byId("jakarta.faces.ViewState").isAbsent()).to.be.false;
293
+ expect(DQ$("[name*='jakarta.faces.ViewState']").isAbsent()).to.be.false;
294
294
 
295
- expect((<HTMLInputElement>document.getElementById("jakarta.faces.ViewState")).value == "RTUyRDI0NzE4QzAxM0E5RDAwMDAwMDVD").to.be.true;
296
- expect(DQ.byId("jakarta.faces.ViewState").inputValue.value == "RTUyRDI0NzE4QzAxM0E5RDAwMDAwMDVD").to.be.true;
295
+ // expect((<HTMLInputElement>document.getElementsByName("jakarta.faces.ViewState")[0]).value == "RTUyRDI0NzE4QzAxM0E5RDAwMDAwMDVD").to.be.true;
296
+ expect(DQ$("[name*='jakarta.faces.ViewState']").inputValue.value == "RTUyRDI0NzE4QzAxM0E5RDAwMDAwMDVD").to.be.true;
297
297
  });
298
298
 
299
299
 
@@ -357,8 +357,7 @@ describe('Tests of the various aspects of the response protocol functionality',
357
357
  });
358
358
 
359
359
 
360
-
361
- it("must handle simple resource responses properly", function(done) {
360
+ it("must handle simple resource responses properly", function (done) {
362
361
 
363
362
  // we need to fake the response as well to see whether the server has loaded the addedViewHead code and has interpreted it
364
363
  //(window as any)["test"] = "booga";
@@ -373,10 +372,10 @@ describe('Tests of the various aspects of the response protocol functionality',
373
372
  })
374
373
 
375
374
 
376
- it("only single resources are allowed", function(done) {
375
+ it("only single resources are allowed", function (done) {
377
376
  // we need to fake the response as well to see whether the server has loaded the addedViewHead code and has interpreted it
378
377
  //(window as any)["test"] = "booga";
379
- for(let cnt = 0; cnt < 10; cnt++) {
378
+ for (let cnt = 0; cnt < 10; cnt++) {
380
379
  DQ.byId("cmd_simple_resource").click();
381
380
  this.respond(XmlResponses.MULTIPLE_RESOURCE_RESPONSE);
382
381
  }
@@ -390,7 +389,7 @@ describe('Tests of the various aspects of the response protocol functionality',
390
389
  })
391
390
 
392
391
  //TODO implement secondary response mockup
393
- it("must handle complex resource responses properly", function(done) {
392
+ it("must handle complex resource responses properly", function (done) {
394
393
  DQ.byId("cmd_complex_resource").click();
395
394
  this.respond(XmlResponses.MULTIPLE_RESOURCE_RESPONSE);
396
395
 
@@ -403,14 +402,62 @@ describe('Tests of the various aspects of the response protocol functionality',
403
402
  .catch(done);
404
403
  })
405
404
 
406
- it("embedded scripts must be evaled", function(done) {
405
+ it("embedded scripts must be evaled", function (done) {
407
406
 
408
407
  DQ.byId("cmd_complex_resource2").click();
409
408
  this.respond(XmlResponses.EMBEDDED_SCRIPTS_RESOURCE_RESPONSE);
410
- // this.respond("debugger; document.getElementById('resource_area_1').innerHTML = 'true3'", {'Content-Type': 'text/javascript'});
409
+ // this.respond("debugger; document.getElementById('resource_area_1').innerHTML = 'true3'", {'Content-Type': 'text/javascript'});
411
410
  let headHTML = document.head.innerHTML;
412
411
  expect(headHTML.indexOf("../../../xhrCore/fixtures/addedViewHead3.js")).not.eq(-1);
413
- expect(headHTML.indexOf("rel=\"../../../xhrCore/fixtures/addedViewHead2.css\"")).not.eq(-1);
412
+ expect(headHTML.indexOf("href=\"../../../xhrCore/fixtures/addedViewHead2.css\"")).not.eq(-1);
413
+ expect(DQ$("head link[rel='stylesheet'][href='../../../xhrCore/fixtures/addedViewHead2.css']").length).to.eq(1);
414
+ setTimeout(() => {
415
+ let evalAreaHtml = DQ.byId('resource_area_1').innerHTML;
416
+ //last one must be the last item, order must be preserved
417
+ expect(evalAreaHtml).to.eq("booga");
418
+ done();
419
+ }, 800)
420
+
421
+ })
422
+
423
+
424
+ it("head replacement must work (https://issues.apache.org/jira/browse/MYFACES-4498 and TCK Issue 4345IT)", function (done) {
425
+
426
+ DQ.byId("cmd_complex_resource2").click();
427
+ this.respond(XmlResponses.HEAD_REPLACE);
428
+ let headHTML = document.head.innerHTML;
429
+
430
+ //failing now, no elements in the html head after respond!!!
431
+ expect(headHTML.indexOf("href=\"../../../xhrCore/fixtures/addedViewHead2.css\"")).not.eq(-1);
432
+ expect(DQ$("head link[rel='stylesheet'][href='../../../xhrCore/fixtures/addedViewHead2.css']").length).to.eq(1);
433
+
434
+ expect(headHTML.indexOf("../../../xhrCore/fixtures/addedViewHead3.js")).not.eq(-1);
435
+ setTimeout(() => {
436
+ let evalAreaHtml = DQ.byId('resource_area_1').innerHTML;
437
+ //last one must be the last item, order must be preserved
438
+ expect(evalAreaHtml).to.eq("booga");
439
+ done();
440
+ }, 800)
441
+
442
+ })
443
+
444
+
445
+ it("complex head replacement must work", function (done) {
446
+
447
+ DQ.byId("cmd_complex_resource2").click();
448
+ this.respond(XmlResponses.HEAD_REPLACE2);
449
+ let headHTML = document.head.innerHTML;
450
+
451
+ //failing now, no elements in the html head after respond!!!
452
+ expect(headHTML.indexOf("href=\"../../../xhrCore/fixtures/addedViewHead2.css\"")).not.eq(-1);
453
+ expect(DQ$("head link[rel='stylesheet'][href='../../../xhrCore/fixtures/addedViewHead2.css']").length).to.eq(1);
454
+
455
+ let metas = DQ$("head meta");
456
+ expect(metas.length).to.eq(5);
457
+ expect(metas.get(0).attr("charSet").value == "UTF-8");
458
+ expect(metas.get(4).attr("author").value == "Whoever");
459
+
460
+ expect(headHTML.indexOf("../../../xhrCore/fixtures/addedViewHead3.js")).not.eq(-1);
414
461
  setTimeout(() => {
415
462
  let evalAreaHtml = DQ.byId('resource_area_1').innerHTML;
416
463
  //last one must be the last item, order must be preserved
@@ -419,5 +466,296 @@ describe('Tests of the various aspects of the response protocol functionality',
419
466
  }, 800)
420
467
 
421
468
  })
469
+ const INNER_HTML_MULIT_VIEW = `
470
+ <div id="viewroot_1">
471
+ <form id="viewroot_1:form1">
472
+ <button type="submit" id="viewroot_1:submit_1"></button>
473
+ <input type="hidden" id="viewroot_1:form1:jakarta.faces.ViewState:1" name="jakarta.faces.ViewState" value="booga"></input>
474
+ </form>
475
+ <form id="viewroot_1:form2">
476
+ <button type="submit" id="viewroot_1:submit_2"></button>
477
+ </form>
478
+ </div>
479
+
480
+ <div id="viewroot_2">
481
+ <form id="viewroot_2:form1">
482
+ <button type="submit" id="viewroot_1:submit_2"></button>
483
+ </form>
484
+ </div>
485
+ `;
486
+ it("must handle multiple view roots", function (done) {
487
+
488
+
489
+ const RESPONSE_1 = `<?xml version="1.0" encoding="UTF-8"?>
490
+ <partial-response id='viewroot_1'>
491
+ <changes>
492
+ <update id='viewroot_1:jakarta.faces.ViewState:1'><![CDATA[updatedVST]]></update>
493
+ </changes>
494
+ </partial-response>`
495
+
496
+ window.document.body.innerHTML = INNER_HTML_MULIT_VIEW;
497
+
498
+ faces.ajax.request(window.document.getElementById("viewroot_1:submit_1"), null, {
499
+ "javax.faces.behavior.event": "change",
500
+ execute: "submit_1",
501
+ render: "form1"
502
+ });
503
+ this.respond(RESPONSE_1);
504
+ expect(DQ$("#viewroot_1\\:form2 [name='jakarta.faces.ViewState']").isAbsent()).to.be.true;
505
+ expect(DQ$("#viewroot_1\\:form1 [name='jakarta.faces.ViewState']").isPresent()).to.be.true;
506
+ expect(DQ$("#viewroot_1\\:form1 [name='jakarta.faces.ViewState']").val).to.be.eq("updatedVST");
507
+
508
+ done();
509
+ })
510
+
511
+ it("must handle multiple view roots multi forms", function (done) {
512
+ const RESPONSE_1 = `<?xml version="1.0" encoding="UTF-8"?>
513
+ <partial-response id='viewroot_1'>
514
+ <changes>
515
+ <update id='viewroot_1:jakarta.faces.ViewState:1'><![CDATA[updatedVST]]></update>
516
+ </changes>
517
+ </partial-response>`
518
+
519
+ window.document.body.innerHTML = INNER_HTML_MULIT_VIEW;
520
+ global["debug4"] = true;
521
+ faces.ajax.request(window.document.getElementById("viewroot_1:submit_1"), null, {
522
+ "javax.faces.behavior.event": "change",
523
+ execute: "submit_1",
524
+ render: "viewroot_1:form1 submit_2"
525
+ });
526
+ this.respond(RESPONSE_1);
527
+ expect(DQ$("#viewroot_1\\:form2 [name*='jakarta.faces.ViewState']").isPresent()).to.be.true;
528
+ expect(DQ$("#viewroot_1\\:form1 [name*='jakarta.faces.ViewState']").isPresent()).to.be.true;
529
+ expect(DQ$("#viewroot_2\\:form1\\:form1 [name*='jakarta.faces.ViewState']").isAbsent()).to.be.true;
530
+
531
+ expect(faces.getViewState(DQ$("#viewroot_1\\:form2").getAsElem(0).value).indexOf("jakarta.faces.ViewState=updatedVST") != -1).to.be.true;
532
+ expect(faces.getViewState("viewroot_1:form1").indexOf("jakarta.faces.ViewState=updatedVST") != -1).to.be.true;
533
+
534
+ done();
535
+ })
536
+
537
+
538
+ it("must handle multiple view roots with ClientWindow ids", function (done) {
539
+
540
+
541
+ const RESPONSE_1 = `<?xml version="1.0" encoding="UTF-8"?>
542
+ <partial-response id='viewroot_1'>
543
+ <changes>
544
+ <update id='viewroot_1:jakarta.faces.ClientWindow:1'><![CDATA[updatedViewId]]></update>
545
+ </changes>
546
+ </partial-response>`
547
+
548
+ window.document.body.innerHTML = INNER_HTML_MULIT_VIEW;
549
+
550
+ faces.ajax.request(window.document.getElementById("viewroot_1:submit_1"), null, {
551
+ "javax.faces.behavior.event": "change",
552
+ execute: "submit_1",
553
+ render: "viewroot_1:form1"
554
+ });
555
+ this.respond(RESPONSE_1);
556
+ expect(DQ$("#viewroot_1\\:form2 [name*='jakarta.faces.ClientWindow']").isAbsent()).to.be.true;
557
+ expect(DQ$("#viewroot_1\\:form1 [name*='jakarta.faces.ClientWindow']").isPresent()).to.be.true;
558
+ expect(DQ$("#viewroot_1\\:form1 [name*='jakarta.faces.ClientWindow']").val).to.be.eq("updatedViewId");
559
+
560
+ done();
561
+ })
562
+
563
+ it("must handle multiple view roots multi forms with ClientWindow ids", function (done) {
564
+ const RESPONSE_1 = `<?xml version="1.0" encoding="UTF-8"?>
565
+ <partial-response id='viewroot_1'>
566
+ <changes>
567
+ <update id='viewroot_1:jakarta.faces.ClientWindow:1'><![CDATA[updatedViewId]]></update>
568
+ </changes>
569
+ </partial-response>`
570
+
571
+ window.document.body.innerHTML = INNER_HTML_MULIT_VIEW;
572
+
573
+ faces.ajax.request(window.document.getElementById("viewroot_1:submit_1"), null, {
574
+ "javax.faces.behavior.event": "change",
575
+ execute: "submit_1",
576
+ render: "viewroot_1:form1 :submit_2"
577
+ });
578
+ this.respond(RESPONSE_1);
579
+ expect(DQ$("#viewroot_1\\:form2 [name*='jakarta.faces.ClientWindow']").isPresent()).to.be.true;
580
+ expect(DQ$("#viewroot_1\\:form1 [name*='jakarta.faces.ClientWindow']").isPresent()).to.be.true;
581
+ expect(DQ$("#viewroot_2\\:form1\\:form1 [name*='jakarta.faces.ClientWindow']").isAbsent()).to.be.true;
582
+ expect(DQ$("#viewroot_1\\:form2 [name*='jakarta.faces.ClientWindow']").val).to.be.eq("updatedViewId");
583
+ expect(DQ$("#viewroot_1\\:form1 [name*='jakarta.faces.ClientWindow']").val).to.be.eq("updatedViewId");
584
+
585
+ done();
586
+ })
587
+
588
+ const TCK_790_MARKUP = `
589
+ <div id="panel1">
590
+ <form id="form1" name="form1" method="post"
591
+ action="booga"
592
+ ><input id="form1:button" name="form1:button" type="submit"
593
+ value="submit form1 via ajax">
594
+ <input type="hidden" name="jakarta.faces.ViewState"
595
+ id="viewroot_1:jakarta.faces.ViewState:1"
596
+ value="beforeUpdate">
597
+ </form>
598
+ </div>
599
+ <div id="panel2">
600
+ <form id="form2" name="form2" method="post" action="booga2"
601
+ ><a href="#" id="form2:link" name="form2:link"></a>
602
+ </form>
603
+ </div>
604
+ <div id="panel3">
605
+ <form id="form3" name="form3" method="post" action="booga3"
606
+ ><a href="#" id="form3:link" name="form3:link"></a>
607
+ </form>
608
+ </div>
609
+ `;
610
+
611
+
612
+ const TCK_790_NAV_MARKUP = `
613
+ <form id="form1x" name="form1" method="post"
614
+ action="booga"
615
+ ><input id="form1x:button" name="form1x:button" type="submit"
616
+ value="submit form1 via ajax">
617
+ <input type="hidden" name="jakarta.faces.ViewState"
618
+ id="viewroot_1:jakarta.faces.ViewState:1"
619
+ value="beforeUpdate">
620
+ </form>
621
+ `;
622
+
623
+ /**
624
+ * Similar to TCK 790
625
+ */
626
+ it("must handle a more complex replace with several forms and one issuing form and a viewstate and a viewroot id in response but viewroot is not present in page", function (done) { //special case, viewid given but no viewid in page special result all render and executes must be updated
627
+
628
+ document.body.innerHTML = TCK_790_MARKUP;
629
+
630
+ const RESPONSE_1 = `<partial-response id="viewroot_1">
631
+ <changes>
632
+ <update id="panel2"><![CDATA[
633
+ <div id="panel2">
634
+ after update
635
+ <form id="form2" name="form2" method="post" action="booga2"
636
+ ><a href="#" id="form2:link" name="form2:link"></a>
637
+ <input type="hidden" name="form2_SUBMIT" value="1"/></form>
638
+ </div>
639
+ ]]>
640
+ </update>
641
+ <update id="panel3"><![CDATA[
642
+ <div id="panel3">
643
+ after update
644
+ <form id="form3" name="form3" method="post" action="booga3"
645
+ ><a href="#" id="form3:link" name="form3:link"></a>
646
+ </form>
647
+ </div>
648
+ ]]>
649
+ </update>
650
+ <update id="viewroot_1:jakarta.faces.ViewState:1"><![CDATA[booga_after_update]]></update>
651
+ </changes>
652
+ </partial-response>`;
653
+ faces.ajax.request(window.document.getElementById("form1:button"), null, {
654
+ "javax.faces.behavior.event": "click",
655
+ execute: "form1",
656
+ render: "form2 form3"
657
+ });
658
+
659
+ this.respond(RESPONSE_1);
660
+ // all forms in execute and render must receive the latest viewstate
661
+ expect(DQ$("#form1 [name*='jakarta.faces.ViewState']").val).to.eq("booga_after_update");
662
+ expect(DQ$("#form2 [name*='jakarta.faces.ViewState']").val).to.eq("booga_after_update");
663
+ expect(DQ$("#form2 [name*='jakarta.faces.ViewState']").val).to.eq("booga_after_update");
664
+ done();
665
+ })
666
+
667
+ it("must handle a complex navigation response (TCK Spec790)", function (done) {
668
+ /*we start from a simple form which triggers a an internal navigation*/
669
+ document.body.innerHTML = TCK_790_NAV_MARKUP;
670
+
671
+ faces.ajax.request(window.document.getElementById("form1x:button"), null, {
672
+ "javax.faces.behavior.event": "click",
673
+ execute: "@form",
674
+ render: ":form1x:button"
675
+ });
676
+
677
+ //TODO xhr stubbing, to check if the viewId is prepended in render!
678
+
679
+ this.respond(`<?xml version="1.0" encoding="UTF-8"?>
680
+ <partial-response id="viewroot_1">
681
+ <changes>
682
+ <update id="jakarta.faces.ViewRoot"><![CDATA[<!DOCTYPE html>
683
+ <html xmlns="http://www.w3.org/1999/xhtml">
684
+ <head>
685
+ <title>Spec 790</title>
686
+ <script src="/jakarta.faces.resource/faces.js.xhtml?ln=jakarta.faces;stage=Development"></script>
687
+ </head>
688
+ <body>
689
+ <div id="panel1">
690
+ <form id="form1" name="form1" method="post"
691
+ action="booga"
692
+ ><input id="form1:button" name="form1:button" type="submit"
693
+ value="submit form1 via ajax">
694
+ </form>
695
+ </div>
696
+ <div id="panel2">
697
+ after update
698
+ <form id="form2" name="form2" method="post" action="booga2"
699
+ ><a href="#" id="form2:link" name="form2:link"></a>
700
+ <input type="hidden" name="form2_SUBMIT" value="1"/></form>
701
+ </div>
702
+ <div id="panel3">
703
+ after update
704
+ <form id="form3" name="form3" method="post" action="booga3"
705
+ ><a href="#" id="form3:link" name="form3:link"></a>
706
+ </form>
707
+ </div>
708
+ </body>
709
+ </html>
710
+ ]]>
711
+ </update>
712
+ <update id="viewroot_1:jakarta.faces.ViewState:1"><![CDATA[booga_after_update]]></update>
713
+ </changes>
714
+ </partial-response>
715
+ `)
716
+ expect(DQ$("#form1 [name*='jakarta.faces.ViewState']").val).to.eq("booga_after_update");
717
+ expect(DQ$("#form2 [name*='jakarta.faces.ViewState']").val).to.eq("booga_after_update");
718
+ expect(DQ$("#form3 [name*='jakarta.faces.ViewState']").val).to.eq("booga_after_update");
719
+
720
+ expect(DQ$("#form1 [name*='jakarta.faces.ViewState']").id.value.indexOf("viewroot_1:jakarta.faces.ViewState:0") === 0).to.be.true;
721
+ expect(DQ$("#form2 [name*='jakarta.faces.ViewState']").id.value.indexOf("viewroot_1:jakarta.faces.ViewState:1") === 0).to.be.true;
722
+ expect(DQ$("#form3 [name*='jakarta.faces.ViewState']").id.value.indexOf("viewroot_1:jakarta.faces.ViewState:2") === 0).to.be.true;
723
+
724
+ done();
725
+ });
726
+
727
+ it('must handle a ViewExpired Error correctly, and only once in a listener', function (done) {
728
+
729
+ document.body.innerHTML = TCK_790_NAV_MARKUP;
730
+
731
+ let errorCalled = 0;
732
+ faces.ajax.addOnError((error)=> {
733
+ expect(error.errorName).to.eq("jakarta.faces.application.ViewExpiredException");
734
+ expect(error.errorMessage).to.eq("serverError: View \"/testhmtl.xhtml\" could not be restored.");
735
+ expect(error.source.id).to.eq("form1x:button");
736
+ errorCalled++;
737
+ });
738
+
739
+ faces.ajax.request(window.document.getElementById("form1x:button"), null, {
740
+ "javax.faces.behavior.event": "click",
741
+ execute: "@form",
742
+ render: ":form1x:button"
743
+ });
744
+
745
+ this.respond(`<?xml version="1.0" encoding="UTF-8"?>
746
+ <partial-response><error>
747
+ <error-name>jakarta.faces.application.ViewExpiredException</error-name>
748
+ <error-message><![CDATA[View "/testhmtl.xhtml" could not be restored.]]></error-message>
749
+ </error>
750
+ </partial-response>`)
751
+
752
+ expect(errorCalled).to.eq(1);
753
+
754
+ done();
755
+
756
+ });
757
+
758
+
759
+
422
760
 
423
761
  });
@@ -22,8 +22,10 @@ import * as sinon from "sinon";
22
22
  import {XmlResponses} from "../frameworkBase/_ext/shared/XmlResponses";
23
23
  import {expect} from "chai";
24
24
  import protocolPage = StandardInits.protocolPage;
25
- import {DQ} from "mona-dish";
25
+ import {DQ, DQ$} from "mona-dish";
26
26
  import {$nsp} from "../../impl/core/Const";
27
+ import STD_XML = StandardInits.STD_XML;
28
+ import HTML_PREFIX_EMBEDDED_BODY = StandardInits.HTML_PREFIX_EMBEDDED_BODY;
27
29
 
28
30
 
29
31
  declare var jsf: any;
@@ -226,7 +228,7 @@ describe('Tests of the various aspects of the response protocol functionality',
226
228
 
227
229
  });
228
230
 
229
- it("must have updated the viewstates properly", function () {
231
+ it("must have updated the viewstates properly 2.3", function () {
230
232
  DQ.byId("cmd_eval").click();
231
233
  /*js full submit form, coming from the integration tests*/
232
234
  window.document.body.innerHTML = `<form id="j_id__v_0" name="j_id__v_0" method="post" action="/IntegrationJSTest/integrationtestsjasmine/test7-eventtest.jsf"
@@ -254,14 +256,14 @@ describe('Tests of the various aspects of the response protocol functionality',
254
256
  </partial-response>`);
255
257
 
256
258
 
257
- expect(DQ.byId("javax.faces.ViewState").isAbsent()).to.be.false;
259
+ expect(DQ$("[name*='javax.faces.ViewState']").isAbsent()).to.be.false;
258
260
 
259
- expect((<HTMLInputElement>document.getElementsByName("javax.faces.ViewState")[0]).value == "RTUyRDI0NzE4QzAxM0E5RDAwMDAwMDVD").to.be.true;
260
- expect(DQ.byId("javax.faces.ViewState").inputValue.value == "RTUyRDI0NzE4QzAxM0E5RDAwMDAwMDVD").to.be.true;
261
+ //expect((<HTMLInputElement>document.getElementsByName("javax.faces.ViewState")[0]).value == "RTUyRDI0NzE4QzAxM0E5RDAwMDAwMDVD").to.be.true;
262
+ expect(DQ$("[name*='javax.faces.ViewState']").val == "RTUyRDI0NzE4QzAxM0E5RDAwMDAwMDVD").to.be.true;
261
263
  });
262
264
 
263
265
 
264
- it("must have updated the viewstates properly with lenient update block", function () {
266
+ it("must have updated the viewstates properly with lenient update block 2.3", function () {
265
267
  DQ.byId("cmd_eval").click();
266
268
  /*js full submit form, coming from the integration tests*/
267
269
  window.document.body.innerHTML = `<form id="j_id__v_0" name="j_id__v_0" method="post" action="/IntegrationJSTest/integrationtestsjasmine/test7-eventtest.jsf"
@@ -291,10 +293,10 @@ describe('Tests of the various aspects of the response protocol functionality',
291
293
  </partial-response>`);
292
294
 
293
295
 
294
- expect(DQ.byId("javax.faces.ViewState").isAbsent()).to.be.false;
296
+ expect(DQ$("[name*='javax.faces.ViewState']").isAbsent()).to.be.false;
295
297
 
296
- expect((<HTMLInputElement>document.getElementById("javax.faces.ViewState")).value == "RTUyRDI0NzE4QzAxM0E5RDAwMDAwMDVD").to.be.true;
297
- expect(DQ.byId("javax.faces.ViewState").inputValue.value == "RTUyRDI0NzE4QzAxM0E5RDAwMDAwMDVD").to.be.true;
298
+ //expect((<HTMLInputElement>document.getElementsByName("javax.faces.ViewState")[0]).value == "RTUyRDI0NzE4QzAxM0E5RDAwMDAwMDVD").to.be.true;
299
+ expect(DQ$("[name*='javax.faces.ViewState']").inputValue.value == "RTUyRDI0NzE4QzAxM0E5RDAwMDAwMDVD").to.be.true;
298
300
  });
299
301
 
300
302
 
@@ -357,6 +359,38 @@ describe('Tests of the various aspects of the response protocol functionality',
357
359
  expect(DQ.byId("j_id__v_0:javax.faces.ClientWindow:1").isAbsent()).to.be.false;
358
360
  });
359
361
 
362
+
363
+ it("must pass named params properly (tobago testcase)", function(done) {
364
+ window.document.body.innerHTML = HTML_PREFIX_EMBEDDED_BODY;
365
+ try {
366
+
367
+ let event = {
368
+ isTrusted: true,
369
+ type: 'change',
370
+ target: document.getElementById("page:input::field"),
371
+ currentTarget: document.getElementById("page:input::field")
372
+ };
373
+ jsf.ajax.request(document.getElementById("page:input"), event as any, {
374
+ render: "page:output",
375
+ execute: "page:input",
376
+ params: {
377
+ "booga2.xxx": "yyy",
378
+ "javax.faces.behavior.event": "change",
379
+ "booga": "bla"
380
+ }
381
+ });
382
+ } catch (err) {
383
+ console.error(err);
384
+ expect(false).to.eq(true);
385
+ }
386
+
387
+ const requestBody = this.requests[0].requestBody;
388
+ expect(requestBody.indexOf("javax.faces.behavior.event")).to.not.eq(-1);
389
+ expect(requestBody.indexOf("javax.faces.behavior.event=change")).to.not.eq(-1);
390
+ expect(requestBody.indexOf("page%3Ainput=input_value")).to.not.eq(-1);
391
+ done();
392
+
393
+ });
360
394
 
361
395
 
362
396
  });