jsf.js_next_gen 4.0.1-beta.5 → 4.0.1-beta.7

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 (188) hide show
  1. package/dist/docs/assets/style.css +4 -5
  2. package/dist/window/faces-development.js +111 -91
  3. package/dist/window/faces-development.js.br +0 -0
  4. package/dist/window/faces-development.js.gz +0 -0
  5. package/dist/window/faces-development.js.map +1 -1
  6. package/dist/window/faces.js +1 -1
  7. package/dist/window/faces.js.br +0 -0
  8. package/dist/window/faces.js.gz +0 -0
  9. package/dist/window/faces.js.map +1 -1
  10. package/dist/window/jsf-development.js +111 -91
  11. package/dist/window/jsf-development.js.br +0 -0
  12. package/dist/window/jsf-development.js.gz +0 -0
  13. package/dist/window/jsf-development.js.map +1 -1
  14. package/dist/window/jsf.js +1 -1
  15. package/dist/window/jsf.js.br +0 -0
  16. package/dist/window/jsf.js.gz +0 -0
  17. package/dist/window/jsf.js.map +1 -1
  18. package/package.json +10 -10
  19. package/src/main/typescript/impl/util/XhrQueueController.ts +3 -17
  20. package/src/main/typescript/impl/xhrCore/XhrRequest.ts +94 -51
  21. package/src/main/typescript/test/frameworkBase/_ext/monadish/DomQueryTest.spec.ts +1 -1
  22. package/src/main/typescript/test/frameworkBase/_ext/shared/StandardInits.ts +126 -0
  23. package/src/main/typescript/test/frameworkBase/_ext/shared/XmlResponses.ts +60 -0
  24. package/src/main/typescript/test/frameworkBase/_ext/shared/fixtures/css/bootstrap-icons.css +15 -0
  25. package/src/main/typescript/test/frameworkBase/_ext/shared/fixtures/css/tobago.css +15 -0
  26. package/src/main/typescript/test/frameworkBase/_ext/shared/fixtures/js/tobago.js +15 -0
  27. package/src/main/typescript/test/myfaces/{OnLoadSpec.ts → OnLoad.spec.ts} +2 -2
  28. package/src/main/typescript/test/xhrCore/ErrorChainTest.spec.ts +136 -0
  29. package/src/main/typescript/test/xhrCore/NamespacesRequestTest.spec.ts +9 -12
  30. package/src/main/typescript/test/xhrCore/RequestParamsTest.spec.ts +1 -1
  31. package/src/main/typescript/test/xhrCore/ResponseTest23.spec.ts +18 -0
  32. package/target/AssocArray.js +281 -0
  33. package/target/AssocArray.js.map +1 -0
  34. package/target/Config.js +235 -0
  35. package/target/Config.js.map +1 -0
  36. package/target/CryptoExtensions.js +112 -0
  37. package/target/CryptoExtensions.js.map +1 -0
  38. package/target/DomQuery.js +1963 -0
  39. package/target/DomQuery.js.map +1 -0
  40. package/target/Es2019Array.js +117 -0
  41. package/target/Es2019Array.js.map +1 -0
  42. package/target/Global.js +38 -0
  43. package/target/Global.js.map +1 -0
  44. package/target/IDomQuery.js +3 -0
  45. package/target/IDomQuery.js.map +1 -0
  46. package/target/Lang.js +183 -0
  47. package/target/Lang.js.map +1 -0
  48. package/target/Messaging.js +645 -0
  49. package/target/Messaging.js.map +1 -0
  50. package/target/Monad.js +330 -0
  51. package/target/Monad.js.map +1 -0
  52. package/target/Promise.js +296 -0
  53. package/target/Promise.js.map +1 -0
  54. package/target/PromiseShim.js +30 -0
  55. package/target/PromiseShim.js.map +1 -0
  56. package/target/SourcesCollectors.js +444 -0
  57. package/target/SourcesCollectors.js.map +1 -0
  58. package/target/Stream.js +562 -0
  59. package/target/Stream.js.map +1 -0
  60. package/target/TagBuilder.js +178 -0
  61. package/target/TagBuilder.js.map +1 -0
  62. package/target/XmlQuery.js +84 -0
  63. package/target/XmlQuery.js.map +1 -0
  64. package/target/impl/util/XhrQueueController.js +3 -18
  65. package/target/impl/util/XhrQueueController.js.map +1 -1
  66. package/target/impl/xhrCore/XhrRequest.js +89 -45
  67. package/target/impl/xhrCore/XhrRequest.js.map +1 -1
  68. package/target/index.js +80 -0
  69. package/target/index.js.map +1 -0
  70. package/target/index_core.js +76 -0
  71. package/target/index_core.js.map +1 -0
  72. package/target/test/frameworkBase/_ext/monadish/DomQueryTest.spec.js +1 -1
  73. package/target/test/frameworkBase/_ext/shared/StandardInits.js +124 -0
  74. package/target/test/frameworkBase/_ext/shared/StandardInits.js.map +1 -1
  75. package/target/test/frameworkBase/_ext/shared/XmlResponses.js +57 -1
  76. package/target/test/frameworkBase/_ext/shared/XmlResponses.js.map +1 -1
  77. package/target/test/myfaces/OnLoad.spec.js +57 -0
  78. package/target/test/myfaces/OnLoad.spec.js.map +1 -0
  79. package/target/test/myfaces/OnLoadSpec.js +2 -2
  80. package/target/test/myfaces/OnLoadSpec.js.map +1 -1
  81. package/target/test/xhrCore/ErrorChainTest.spec.js +156 -0
  82. package/target/test/xhrCore/ErrorChainTest.spec.js.map +1 -0
  83. package/target/test/xhrCore/NamespacesRequestTest.spec.js +8 -5
  84. package/target/test/xhrCore/NamespacesRequestTest.spec.js.map +1 -1
  85. package/target/test/xhrCore/RequestParamsTest.spec.js.map +1 -1
  86. package/target/test/xhrCore/ResponseTest23.spec.js +13 -0
  87. package/target/test/xhrCore/ResponseTest23.spec.js.map +1 -1
  88. package/target/types/main/typescript/AssocArray.d.ts +86 -0
  89. package/target/types/main/typescript/Config.d.ts +94 -0
  90. package/target/types/main/typescript/CryptoExtensions.d.ts +87 -0
  91. package/target/types/main/typescript/DomQuery.d.ts +587 -0
  92. package/target/types/main/typescript/Es2019Array.d.ts +30 -0
  93. package/target/types/main/typescript/Global.d.ts +23 -0
  94. package/target/types/main/typescript/IDomQuery.d.ts +480 -0
  95. package/target/types/main/typescript/Lang.d.ts +97 -0
  96. package/target/types/main/typescript/Messaging.d.ts +285 -0
  97. package/target/types/main/typescript/Monad.d.ts +161 -0
  98. package/target/types/main/typescript/Promise.d.ts +58 -0
  99. package/target/types/main/typescript/PromiseShim.d.ts +22 -0
  100. package/target/types/main/typescript/SourcesCollectors.d.ts +280 -0
  101. package/target/types/main/typescript/Stream.d.ts +284 -0
  102. package/target/types/main/typescript/TagBuilder.d.ts +50 -0
  103. package/target/types/main/typescript/XmlQuery.d.ts +31 -0
  104. package/target/types/main/typescript/api/_api.d.ts +182 -0
  105. package/target/types/main/typescript/api/faces.d.ts +17 -0
  106. package/target/types/main/typescript/api/jsf.d.ts +17 -0
  107. package/target/types/main/typescript/impl/AjaxImpl.d.ts +164 -0
  108. package/target/types/main/typescript/impl/PushImpl.d.ts +38 -0
  109. package/target/types/main/typescript/impl/core/Const.d.ts +138 -0
  110. package/target/types/main/typescript/impl/core/ImplTypes.d.ts +16 -0
  111. package/target/types/main/typescript/impl/i18n/Messages.d.ts +102 -0
  112. package/target/types/main/typescript/impl/util/Assertions.d.ts +46 -0
  113. package/target/types/main/typescript/impl/util/AsyncRunnable.d.ts +112 -0
  114. package/target/types/main/typescript/impl/util/ExtDomQuery.d.ts +100 -0
  115. package/target/types/main/typescript/impl/util/FileUtils.d.ts +25 -0
  116. package/target/types/main/typescript/impl/util/HiddenInputBuilder.d.ts +37 -0
  117. package/target/types/main/typescript/impl/util/IListener.d.ts +18 -0
  118. package/target/types/main/typescript/impl/util/Lang.d.ts +138 -0
  119. package/target/types/main/typescript/impl/util/XhrQueueController.d.ts +51 -0
  120. package/target/types/main/typescript/impl/xhrCore/ErrorData.d.ts +37 -0
  121. package/target/types/main/typescript/impl/xhrCore/EventData.d.ts +25 -0
  122. package/target/types/main/typescript/impl/xhrCore/IResponseProcessor.d.ts +136 -0
  123. package/target/types/main/typescript/impl/xhrCore/RequestDataResolver.d.ts +84 -0
  124. package/target/types/main/typescript/impl/xhrCore/ResonseDataResolver.d.ts +60 -0
  125. package/target/types/main/typescript/impl/xhrCore/Response.d.ts +29 -0
  126. package/target/types/main/typescript/impl/xhrCore/ResponseProcessor.d.ts +208 -0
  127. package/target/types/main/typescript/impl/xhrCore/XhrFormData.d.ts +83 -0
  128. package/target/types/main/typescript/impl/xhrCore/XhrRequest.d.ts +102 -0
  129. package/target/types/main/typescript/index.d.ts +34 -0
  130. package/target/types/main/typescript/index_core.d.ts +29 -0
  131. package/target/types/main/typescript/myfaces/OamSubmit.d.ts +53 -0
  132. package/target/types/main/typescript/test/frameworkBase/LangTest.spec.d.ts +1 -0
  133. package/target/types/main/typescript/test/frameworkBase/_ext/monadish/DomQueryTest.spec.d.ts +1 -0
  134. package/target/types/main/typescript/test/frameworkBase/_ext/monadish/LangTest.spec.d.ts +16 -0
  135. package/target/types/main/typescript/test/frameworkBase/_ext/monadish/MappingProbes.d.ts +39 -0
  136. package/target/types/main/typescript/test/frameworkBase/_ext/monadish/MappingTest.spec.d.ts +16 -0
  137. package/target/types/main/typescript/test/frameworkBase/_ext/monadish/MonadTest.spec.d.ts +16 -0
  138. package/target/types/main/typescript/test/frameworkBase/_ext/monadish/XmlQueryTest.spec.d.ts +0 -0
  139. package/target/types/main/typescript/test/frameworkBase/_ext/monadish/markups/tobago-with-header.d.ts +1 -0
  140. package/target/types/main/typescript/test/frameworkBase/_ext/monadish/markups/tobago-without-header.d.ts +1 -0
  141. package/target/types/main/typescript/test/frameworkBase/_ext/shared/StandardInits.d.ts +63 -0
  142. package/target/types/main/typescript/test/frameworkBase/_ext/shared/XmlResponses.d.ts +23 -0
  143. package/target/types/main/typescript/test/impl/ImplTest.spec.d.ts +16 -0
  144. package/target/types/main/typescript/test/impl/ImplTest_23.spec.d.ts +16 -0
  145. package/target/types/main/typescript/test/impl/SeparatorCharsTest.spec.d.ts +16 -0
  146. package/target/types/main/typescript/test/myfaces/OamSubmit.spec.d.ts +16 -0
  147. package/target/types/main/typescript/test/myfaces/OnLoad.spec.d.ts +16 -0
  148. package/target/types/main/typescript/test/queue/AsynchronousProbe.d.ts +38 -0
  149. package/target/types/main/typescript/test/queue/AsynchronousQueueTest.spec.d.ts +16 -0
  150. package/target/types/main/typescript/test/xhrCore/ClientWindow.spec.d.ts +1 -0
  151. package/target/types/main/typescript/test/xhrCore/ErrorChainTest.spec.d.ts +16 -0
  152. package/target/types/main/typescript/test/xhrCore/EventTests.spec.d.ts +16 -0
  153. package/target/types/main/typescript/test/xhrCore/FakeWebsocket.d.ts +24 -0
  154. package/target/types/main/typescript/test/xhrCore/FileUploadTest.spec.d.ts +1 -0
  155. package/target/types/main/typescript/test/xhrCore/NamespacesRequestTest.spec.d.ts +16 -0
  156. package/target/types/main/typescript/test/xhrCore/OamSubmitTest.spec.d.ts +16 -0
  157. package/target/types/main/typescript/test/xhrCore/RequestParamsTest.spec.d.ts +1 -0
  158. package/target/types/main/typescript/test/xhrCore/RequestTest.spec.d.ts +16 -0
  159. package/target/types/main/typescript/test/xhrCore/RequestTest_23.spec.d.ts +16 -0
  160. package/target/types/main/typescript/test/xhrCore/ResponseTest.spec.d.ts +16 -0
  161. package/target/types/main/typescript/test/xhrCore/ResponseTest23.spec.d.ts +16 -0
  162. package/target/types/main/typescript/test/xhrCore/ShadowDomTest.spec.d.ts +16 -0
  163. package/target/types/main/typescript/test/xhrCore/TobagoFileUploadTest.spec.d.ts +1 -0
  164. package/target/types/main/typescript/test/xhrCore/WebsocketTest.d.ts +1 -0
  165. package/target/types/main/typescript/test/xhrCore/XhrFormDataTest.spec.d.ts +16 -0
  166. package/target/types/test/typescript/AssocArrayTest.spec.d.ts +1 -0
  167. package/target/types/test/typescript/DomQueryTest.spec.d.ts +1 -0
  168. package/target/types/test/typescript/ExtendedArrayTest.spec.d.ts +1 -0
  169. package/target/types/test/typescript/LangTest.spec.d.ts +1 -0
  170. package/target/types/test/typescript/MappingProbes.d.ts +24 -0
  171. package/target/types/test/typescript/MappingTest.spec.d.ts +1 -0
  172. package/target/types/test/typescript/MessagingTest.spec.d.ts +1 -0
  173. package/target/types/test/typescript/MonadTest.spec.d.ts +16 -0
  174. package/target/types/test/typescript/PromiseTest.spec.d.ts +1 -0
  175. package/target/types/test/typescript/StreamTest.spec.d.ts +1 -0
  176. package/target/types/test/typescript/XmlQueryTest.spec.d.ts +1 -0
  177. package/target/types/test/typescript/markups/tobago-with-header.d.ts +1 -0
  178. package/target/types/test/typescript/markups/tobago-without-header.d.ts +1 -0
  179. package/webpack.config.js +1 -1
  180. package/webpack.config.js.map +1 -1
  181. package/.nyc_output/09ca9ebc-2305-4357-8db9-48ddfc7dfde2.json +0 -1
  182. package/.nyc_output/7c496a14-166e-4aa5-85b9-47b22b055ad8.json +0 -1
  183. package/.nyc_output/processinfo/09ca9ebc-2305-4357-8db9-48ddfc7dfde2.json +0 -1
  184. package/.nyc_output/processinfo/7c496a14-166e-4aa5-85b9-47b22b055ad8.json +0 -1
  185. package/.nyc_output/processinfo/index.json +0 -1
  186. package/src/test.html +0 -75
  187. package/src/tmp/test.html +0 -16
  188. package/tmp.xml +0 -36
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "jsf.js_next_gen",
3
- "version": "4.0.1-beta.5",
3
+ "version": "4.0.1-beta.7",
4
4
  "description": "A next generation typescript reimplementation of jsf.js",
5
5
  "main": "dist/window/faces.js",
6
6
  "scripts": {
@@ -23,7 +23,7 @@
23
23
  "@istanbuljs/nyc-config-typescript": "^1.0.2",
24
24
  "@types/chai": "^4.3.4",
25
25
  "@types/mocha": "^10.0.1",
26
- "@types/node": "^18.14.6",
26
+ "@types/node": "^18.15.5",
27
27
  "@types/sinon": "^10.0.13",
28
28
  "babel-plugin-syntax-dynamic-import": "^6.18.0",
29
29
  "chai": "^4.3.7",
@@ -31,24 +31,24 @@
31
31
  "cross-env": "^7.0.3",
32
32
  "html-webpack-plugin": "^5.5.0",
33
33
  "http-server": "^14.1.1",
34
- "jsdom": "^21.1.0",
34
+ "jsdom": "^21.1.1",
35
35
  "jsdom-global": "^3.0.2",
36
36
  "mocha": "^10.2.0",
37
- "npm-check-updates": "^16.7.10",
37
+ "npm-check-updates": "^16.7.13",
38
38
  "nyc": "^15.1.0",
39
39
  "replace-in-file": "^6.3.5",
40
40
  "rxjs": "^7.8.0",
41
- "sinon": "^15.0.1",
41
+ "sinon": "^15.0.2",
42
42
  "terser-webpack-plugin": "^5.3.7",
43
43
  "ts-loader": "^9.4.2",
44
44
  "ts-node": "^10.9.1",
45
- "typedoc": "^0.23.26",
46
- "typescript": "^4.9.5",
47
- "webpack": "^5.76.0",
45
+ "typedoc": "^0.23.28",
46
+ "typescript": "^5.0.2",
47
+ "webpack": "^5.76.2",
48
48
  "webpack-cli": "^5.0.1",
49
- "webpack-dev-server": "^4.11.1"
49
+ "webpack-dev-server": "^4.13.1"
50
50
  },
51
51
  "dependencies": {
52
- "mona-dish": "0.28.3"
52
+ "mona-dish": "0.28.7"
53
53
  }
54
54
  }
@@ -72,13 +72,9 @@ export class XhrQueueController<T extends IAsyncRunnable<any>> {
72
72
  * and clear the queue (theoretically this
73
73
  * would work with any promise)
74
74
  */
75
- try {
76
- return asyncRunnable
77
- .then(() => this.next())
78
- .catch((e) => this.handleError(e));
79
- } catch (e) {
80
- this.handleError(e);
81
- }
75
+ return asyncRunnable
76
+ .then(() => this.next())
77
+ .catch(() => this.clear());
82
78
  }
83
79
 
84
80
 
@@ -99,14 +95,4 @@ export class XhrQueueController<T extends IAsyncRunnable<any>> {
99
95
  this.taskRunning = !this.isEmpty;
100
96
  }
101
97
 
102
- /**
103
- * standard error handling
104
- * we clear the queue and then bomb out
105
- * @param e
106
- * @private
107
- */
108
- private handleError(e) {
109
- this.clear();
110
- throw e;
111
- }
112
98
  }
@@ -74,6 +74,7 @@ export class XhrRequest extends AsyncRunnable<XMLHttpRequest> {
74
74
 
75
75
 
76
76
  private xhrObject = new XMLHttpRequest();
77
+
77
78
  /**
78
79
  * Required Parameters
79
80
  *
@@ -167,7 +168,7 @@ export class XhrRequest extends AsyncRunnable<XMLHttpRequest> {
167
168
  // a bug in the xhr stub library prevents the setRequestHeader to be properly executed on fake xhr objects
168
169
  // normal browsers should resolve this
169
170
  // tests can quietly fail on this one
170
- if(this.contentType != "undefined") {
171
+ if (this.contentType != "undefined") {
171
172
  ignoreErr(() => xhrObject.setRequestHeader(CONTENT_TYPE, `${this.contentType}; charset=utf-8`));
172
173
  }
173
174
 
@@ -181,12 +182,16 @@ export class XhrRequest extends AsyncRunnable<XMLHttpRequest> {
181
182
  this.sendEvent(BEGIN);
182
183
  this.sendRequest(formData);
183
184
  } catch (e) {
184
- // _onError
185
- this.handleError(e);
185
+ // this happens usually in a client side condition, hence we have to deal in with it in a client
186
+ // side manner
187
+ this.handleErrorAndClearQueue(e);
188
+ throw e;
186
189
  }
187
190
  return this;
188
191
  }
189
192
 
193
+
194
+
190
195
  cancel() {
191
196
  try {
192
197
  // this causes onError to be called where the error
@@ -198,7 +203,6 @@ export class XhrRequest extends AsyncRunnable<XMLHttpRequest> {
198
203
  }
199
204
 
200
205
 
201
-
202
206
  /**
203
207
  * attaches the internal event and processing
204
208
  * callback within the promise to our xhr object
@@ -210,111 +214,144 @@ export class XhrRequest extends AsyncRunnable<XMLHttpRequest> {
210
214
  const xhrObject = this.xhrObject;
211
215
 
212
216
  xhrObject.onabort = () => {
213
- this.onAbort(reject);
217
+ this.onAbort(resolve, reject);
214
218
  };
215
219
  xhrObject.ontimeout = () => {
216
- this.onTimeout(reject);
220
+ this.onTimeout(resolve, reject);
217
221
  };
218
222
  xhrObject.onload = () => {
219
- this.onSuccess(resolve)
223
+ this.onResponseReceived(resolve)
220
224
  };
221
225
  xhrObject.onloadend = () => {
222
- this.onDone(this.xhrObject, resolve);
226
+ this.onResponseProcessed(this.xhrObject, resolve);
223
227
  };
224
228
  xhrObject.onerror = (errorData: any) => {
225
-
226
- // some browsers trigger an error when cancelling a request internally, or when
227
- // cancel is called from outside
229
+ // Safari in rare cases triggers an error when cancelling a request internally, or when
228
230
  // in this case we simply ignore the request and clear up the queue, because
229
231
  // it is not safe anymore to proceed with the current queue
232
+
230
233
  // This bypasses a Safari issue where it keeps requests hanging after page unload
231
234
  // and then triggers a cancel error on then instead of just stopping
232
235
  // and clearing the code
233
- if(this.isCancelledResponse(this.xhrObject)) {
236
+ // in a page unload case it is safe to clear the queue
237
+ // in the exact safari case any request after this one in the queue is invalid
238
+ // because the queue references xhr requests to a page which already is gone!
239
+ if (this.isCancelledResponse(this.xhrObject)) {
234
240
  /*
235
241
  * this triggers the catch chain and after that finally
236
242
  */
237
- reject();
238
243
  this.stopProgress = true;
244
+ reject();
245
+ return;
246
+ }
247
+ // error already processed somewhere else
248
+ if (this.stopProgress) {
239
249
  return;
240
250
  }
241
- this.onError(errorData, reject);
251
+ this.handleError(errorData);
242
252
  };
243
253
  }
244
254
 
245
255
  private isCancelledResponse(currentTarget: XMLHttpRequest): boolean {
246
- return currentTarget?.status === 0 && // cancelled by browser
256
+ return currentTarget?.status === 0 && // cancelled internally by browser
247
257
  currentTarget?.readyState === 4 &&
248
258
  currentTarget?.responseText === '' &&
249
259
  currentTarget?.responseXML === null;
250
260
  }
251
261
 
252
262
  /*
253
- * xhr processing callbacks
254
- *
255
- * Those methods are the callbacks called by
256
- * the xhr object depending on its own state
257
- */
258
-
259
- private onAbort(reject: Consumer<any>) {
260
- reject();
263
+ * xhr processing callbacks
264
+ *
265
+ * Those methods are the callbacks called by
266
+ * the xhr object depending on its own state
267
+ */
268
+ /**
269
+ * client side abort... also here for now we clean the queue
270
+ *
271
+ * @param resolve
272
+ * @param reject
273
+ * @private
274
+ */
275
+ private onAbort(resolve: Consumer<any>, reject: Consumer<any>) {
276
+ // reject means clear queue, in this case we abort entirely the processing
277
+ // does not happen yet, we have to probably rethink this strategy in the future
278
+ // when we introduce cancel functionality
279
+ this.handleGenericError(reject);
261
280
  }
262
281
 
263
- private onTimeout(reject: Consumer<any>) {
282
+ /**
283
+ * request timeout, this must be handled like a generic server error per spec
284
+ * unfortunately, so we have to jump to the next item (we cancelled before)
285
+ * @param resolve
286
+ * @param reject
287
+ * @private
288
+ */
289
+ private onTimeout(resolve: Consumer<any>, reject: Consumer<any>) {
290
+ // timeout also means we we probably should clear the queue,
291
+ // the state is unsafe for the next requests
264
292
  this.sendEvent(STATE_EVT_TIMEOUT);
265
- reject();
293
+ this.handleGenericError(resolve);
266
294
  }
267
295
 
268
- private onSuccess(resolve: Consumer<any>) {
296
+ /**
297
+ * the response is received and normally is a normal response
298
+ * but also can be some kind of error (http code >= 300)
299
+ * In any case the response will be resolved either as error or response
300
+ * and the next item in the queue will be processed
301
+ * @param resolve
302
+ * @private
303
+ */
304
+ private onResponseReceived(resolve: Consumer<any>) {
269
305
 
270
306
  this.sendEvent(COMPLETE);
271
-
272
- // malformed responses always result in empty response xml
273
- // per spec a valid response cannot be empty
274
- if (!this?.xhrObject?.responseXML) {
275
- this.handleMalFormedXML(resolve);
307
+ /*
308
+ * second on error path
309
+ */
310
+ if ((this.xhrObject?.status ?? 0) >= 300 || !this?.xhrObject?.responseXML) {
311
+ // all errors from the server are resolved without interfering in the queue
312
+ this.handleGenericError(resolve);
276
313
  return;
277
314
  }
278
315
 
279
316
  $faces().ajax.response(this.xhrObject, this.responseContext.value ?? {});
280
317
  }
281
318
 
282
- private handleMalFormedXML(resolve: Function) {
319
+ private handleGenericError(resolveOrReject: Function) {
283
320
  this.stopProgress = true;
284
321
  const errorData = {
285
322
  type: ERROR,
286
323
  status: MALFORMEDXML,
287
- responseCode: 200,
288
- responseText: this.xhrObject?.responseText,
289
- source: this.internalContext.getIf(CTX_PARAM_SRC_CTL_ID).value
324
+ responseCode: this.xhrObject?.status ?? 400,
325
+ responseText: this.xhrObject?.responseText ?? "Error",
326
+ source: this.internalContext.getIf(CTX_PARAM_SRC_CTL_ID).value
290
327
  };
291
328
  try {
292
329
  this.handleError(errorData, true);
293
330
  } finally {
294
- // we issue a resolve in this case to allow the system to recover
331
+ // we issue a resolveOrReject in this case to allow the system to recover
295
332
  // reject would clean up the queue
296
- resolve(errorData);
333
+ // resolve would trigger the next element in the queue to be processed
334
+ resolveOrReject(errorData);
297
335
  }
298
336
  // non blocking non clearing
299
337
  }
300
338
 
301
- private onDone(data: any, resolve: Consumer<any>) {
302
- // if stop progress a special handling including resolve is already performed
339
+ /**
340
+ * last minute cleanup, the request now either is fully done
341
+ * or not by having had a cancel or error event be
342
+ * @param data
343
+ * @param resolve
344
+ * @private
345
+ */
346
+ private onResponseProcessed(data: any, resolve: Consumer<any>) {
347
+ // if stop progress true, the cleanup already has been performed
303
348
  if (this.stopProgress) {
304
349
  return;
305
350
  }
306
- /**
307
- * now call the then chain
308
- */
309
- resolve(data);
310
- }
311
-
312
- private onError(errorData: any, reject: Consumer<any>) {
313
- this.handleError(errorData);
314
351
  /*
315
- * this triggers the catch chain and after that finally
352
+ * normal case, cleanup == next item if possible
316
353
  */
317
- reject();
354
+ resolve(data);
318
355
  }
319
356
 
320
357
  private sendRequest(formData: XhrFormData) {
@@ -343,12 +380,18 @@ export class XhrRequest extends AsyncRunnable<XMLHttpRequest> {
343
380
  Implementation.sendEvent(eventData, eventHandler);
344
381
  } catch (e) {
345
382
  e.source = e?.source ?? this.requestContext.getIf(SOURCE).value;
346
- this.handleError(e);
347
-
383
+ // this is a client error, no save state anymore for queue processing!
384
+ this.handleErrorAndClearQueue(e);
385
+ // we forward the error upward like all client side errors
348
386
  throw e;
349
387
  }
350
388
  }
351
389
 
390
+ private handleErrorAndClearQueue(e, responseFormatError: boolean = false) {
391
+ this.handleError(e, responseFormatError);
392
+ this.reject(e);
393
+ }
394
+
352
395
  private handleError(exception, responseFormatError: boolean = false) {
353
396
  const errorData = (responseFormatError) ? ErrorData.fromHttpConnection(exception.source, exception.type, exception.status, exception.responseText, exception.responseCode, exception.status) : ErrorData.fromClient(exception);
354
397
  const eventHandler = resolveHandlerFunc(this.requestContext, this.responseContext, ON_ERROR);
@@ -567,7 +567,7 @@ describe('DOMQuery tests', function () {
567
567
  expect(content.byId("third").innerHTML).to.eq("hello world");
568
568
  expect(content.byId("fourth").innerHTML).to.eq("hello world");
569
569
 
570
- expect(DomQuery.byTagName("head")
570
+ expect(DomQuery.byTagName("body")
571
571
  .querySelectorAll("link[rel='stylesheet'][href='./fixtures/blank.css']").length).to.eq(1);
572
572
  done();
573
573
 
@@ -145,6 +145,92 @@ export module StandardInits {
145
145
  </body>
146
146
  </html>`;
147
147
 
148
+ export const HTML_TOBAGO_SHEET_WITH_STYLE = `<!DOCTYPE html>
149
+ <html lang='de'>
150
+ <head>
151
+ <meta charset='UTF-8'>
152
+ <meta name='viewport' content='width=device-width, initial-scale=1.0'>
153
+ <title>Test
154
+ </title>
155
+ <link rel='stylesheet' href='./fixtures/css/tobago.css' type='text/css'>
156
+ <link rel='stylesheet' href='./fixtures/css/bootstrap-icons.css' type='text/css'>
157
+ <script src='./fixtures/jakarta.faces.resource/faces.js.jsf' type='text/javascript'></script>
158
+ <script src='./fixtures/js/tobago.js' type='module'></script>
159
+ </head>
160
+ <body>
161
+ <tobago-page locale='de' class='container-fluid' id='page' focus-on-error='true' wait-overlay-delay-full='1000'
162
+ wait-overlay-delay-ajax='1000'>
163
+ <form action='/content/080-sheet/30-event/Sheet_Event.xhtml' id='page::form' method='post'
164
+ accept-charset='UTF-8' data-tobago-context-path=''>
165
+ <input type='hidden' name='javax.faces.source' id='javax.faces.source' disabled='disabled'>
166
+ <tobago-focus id='page::lastFocusId'>
167
+ <input type='hidden' name='page::lastFocusId' id='page::lastFocusId::field'>
168
+ </tobago-focus>
169
+ <input type='hidden' name='org.apache.myfaces.tobago.webapp.Secret' id='org.apache.myfaces.tobago.webapp.Secret'
170
+ value='secretValue'>
171
+ <div class='tobago-page-menuStore'>
172
+ </div>
173
+ <span id='page::jsf-state-container'><input type='hidden' name='javax.faces.ViewState'
174
+ id='j_id__v_0:javax.faces.ViewState:1'
175
+ value='viewStateValue' autocomplete='off'><input
176
+ type='hidden' name='javax.faces.RenderKitId' value='tobago'><input type='hidden'
177
+ id='j_id__v_0:javax.faces.ClientWindow:1'
178
+ name='javax.faces.ClientWindow'
179
+ value='clientWindowValue'></span>
180
+ <button type='button' id='page:ajaxButton' name='page:ajaxButton'
181
+ class='tobago-button btn btn-secondary tobago-auto-spacing'>
182
+ <tobago-behavior event='click' client-id='page:ajaxButton' execute='page:ajaxButton'
183
+ render='page:s1'></tobago-behavior>
184
+ <span>Ajax</span></button>
185
+ <tobago-sheet id='page:s1' data-tobago-selection-mode='multi' data-tobago-first='0' rows='0' row-count='2'>
186
+ <style nonce='nonceValue' id='page:s1:j_id_4'>#page\\:s1 {
187
+ max-height: 500px;
188
+ }
189
+ </style>
190
+ <input id='page:s1::scrollPosition' name='page:s1::scrollPosition' type='hidden' value='[0,0]'>
191
+ <input id='page:s1::selected' name='page:s1::selected' type='hidden' value='[]'>
192
+ <div class='tobago-body'>
193
+ <table cellspacing='0' cellpadding='0' summary='' class='table'>
194
+ <thead>
195
+ <tr>
196
+ <th>
197
+ <span><tobago-out id='page:s1:_col0'><span class='form-control-plaintext'>Name</span></tobago-out></span>
198
+ </th>
199
+ </tr>
200
+ </thead>
201
+ <tbody>
202
+ <tr row-index='0'>
203
+ <td>
204
+ <tobago-out id='page:s1:0:t_name'><span class='form-control-plaintext'>Earth</span></tobago-out>
205
+ </td>
206
+ <td>
207
+ <div>
208
+ </div>
209
+ </td>
210
+ </tr>
211
+ <tr row-index='1'>
212
+ <td>
213
+ <tobago-out id='page:s1:1:t_name'><span class='form-control-plaintext'>Moon</span></tobago-out>
214
+ </td>
215
+ <td>
216
+ <div>
217
+ </div>
218
+ </td>
219
+ </tr>
220
+ </tbody>
221
+ </table>
222
+ </div>
223
+ </tobago-sheet>
224
+ </form>
225
+ <noscript>
226
+ <div class='tobago-page-noscript'>Diese Seite benötigt JavaScript, allerdings ist JavaScript in Ihrem Browser
227
+ derzeit deaktiviert. Um JavaScript zu aktivieren, lesen Sie ggf. die Anleitung Ihres Browsers.
228
+ </div>
229
+ </noscript>
230
+ </tobago-page>
231
+ </body>
232
+ </html>`;
233
+
148
234
  /**
149
235
  * a page simulating basically a simple faces form
150
236
  */
@@ -236,6 +322,42 @@ export module StandardInits {
236
322
  `;
237
323
  }
238
324
 
325
+ export const ERROR_CHAIN_PAGE = `
326
+ <!DOCTYPE html>
327
+ <html lang="en">
328
+ <head>
329
+ <meta charset="UTF-8">
330
+ <title>Title</title>
331
+ </head>
332
+ <body>
333
+ <h2>Error Chain Testcase</h2>
334
+ <script type="text/javascript">
335
+ /**
336
+ * code identical to mojarra test, both stem from me
337
+ * so mojarras side EPL here ASL2!
338
+ *
339
+ * @param event
340
+ */
341
+ function triggerRequestChain(event) {
342
+ for(let cnt = 0; cnt < 5; cnt++) {
343
+ faces.ajax.request(event.target, "click", {
344
+ render:"form1",
345
+ onerror: function() {
346
+ document.getElementById("errorCalled").innerHTML = "1";
347
+ }
348
+ })
349
+ }
350
+ }
351
+ </script>
352
+ <div id="errorCalled"></div>
353
+ <form id="form1">
354
+ <div id="form1:out1">0</div>
355
+ <input type="button" id="form1:button1" onclick="triggerRequestChain(event)">
356
+ </form>
357
+ </body>
358
+ </html>
359
+ `;
360
+
239
361
  /**
240
362
  * This is a standardized small page mockup
241
363
  * testing the various aspects of the protocol
@@ -405,6 +527,10 @@ export module StandardInits {
405
527
  return <any>init((IS_40) ? PROTOCOL_PAGE : PROTOCOL_PAGE.replace(/jakarta/gi,"javax"), withJsf, IS_40);
406
528
  }
407
529
 
530
+ export function errorChainPage(withJsf = true, IS_40 = true): Promise<() => void> {
531
+ return <any>init((IS_40) ? ERROR_CHAIN_PAGE : ERROR_CHAIN_PAGE.replace(/jakarta/gi,"javax"), withJsf, IS_40);
532
+ }
533
+
408
534
  export function prefixEmbeddedPage(withJsf = true, IS_40 = true): Promise<() => void> {
409
535
  return <any>init((IS_40) ? HTML_FORM_PREFIXED_EMBEDDED : HTML_FORM_PREFIXED_EMBEDDED.replace(/jakarta/gi,"javax"), withJsf, IS_40);
410
536
  }
@@ -26,6 +26,59 @@ export class XmlResponses {
26
26
  </partial-response>
27
27
  `;
28
28
 
29
+ static UPDATE_TOBAGO_SHEET_WITH_STYLE = `<?xml version="1.0" encoding="UTF-8"?>
30
+ <partial-response id='j_id__v_0'>
31
+ <changes>
32
+ <update id='page:s1'><![CDATA[
33
+ <tobago-sheet id='page:s1' data-tobago-selection-mode='multi' data-tobago-first='0' rows='0' row-count='2'>
34
+ <style nonce='nonceValue' id='page:s1:j_id_4'>#page\\:s1 {
35
+ max-height: 500px;
36
+ }
37
+ </style>
38
+ <input id='page:s1::scrollPosition' name='page:s1::scrollPosition' type='hidden' value='[0,0]'/>
39
+ <input id='page:s1::selected' name='page:s1::selected' type='hidden' value='[]'/>
40
+ <div class='tobago-body'>
41
+ <table cellspacing='0' cellpadding='0' summary='' class='table'>
42
+ <thead>
43
+ <tr>
44
+ <th>
45
+ <span><tobago-out id='page:s1:_col0'><span
46
+ class='form-control-plaintext'>Name</span></tobago-out></span>
47
+ </th>
48
+ </tr>
49
+ </thead>
50
+ <tbody>
51
+ <tr row-index='0'>
52
+ <td>
53
+ <tobago-out id='page:s1:0:t_name'><span class='form-control-plaintext'>Earth</span></tobago-out>
54
+ </td>
55
+ <td>
56
+ <div>
57
+ </div>
58
+ </td>
59
+ </tr>
60
+ <tr row-index='1'>
61
+ <td>
62
+ <tobago-out id='page:s1:1:t_name'><span class='form-control-plaintext'>Moon</span></tobago-out>
63
+ </td>
64
+ <td>
65
+ <div>
66
+ </div>
67
+ </td>
68
+ </tr>
69
+ </tbody>
70
+ </table>
71
+ </div>
72
+ </tobago-sheet>
73
+ ]]>
74
+ </update>
75
+ <update id='j_id__v_0:javax.faces.ViewState:1'><![CDATA[viewStateValue]]>
76
+ </update>
77
+ <update id='j_id__v_0:javax.faces.ClientWindow:1'><![CDATA[clientWindowValue]]>
78
+ </update>
79
+ </changes>
80
+ </partial-response>`;
81
+
29
82
  static SHADOW_DOM_UPDATE=`
30
83
  <partial-response>
31
84
  <changes><update id="shadowContent"><![CDATA[<div id="shadowContent">after update</div>]]></update></changes>
@@ -250,4 +303,11 @@ export class XmlResponses {
250
303
  `;
251
304
 
252
305
  static ILLEGAL_RESP = `>>>> xxxx >YYYY-!->>>`;
306
+
307
+
308
+ static ERROR_CHAIN_RESPOND_OK = (cnt: number): string => {
309
+ return `<partial-response><changes><update id='form1:out1'><![CDATA[<div id="form1:out1">${cnt}</div>]]>
310
+ </update></changes></partial-response>`;
311
+ }
312
+
253
313
  }
@@ -0,0 +1,15 @@
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
+ */
@@ -0,0 +1,15 @@
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
+ */
@@ -0,0 +1,15 @@
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
+ */
@@ -33,10 +33,10 @@ describe('Tests on the xhr core when it starts to call the request', function ()
33
33
  return
34
34
  });
35
35
 
36
- it("must be present", async function(done) {
36
+ it("must be present", async function() {
37
37
  await defaultMyFaces();
38
38
  expect(myfaces?.onDomReady).to.exist;
39
- done();
39
+ return true;
40
40
  });
41
41
 
42
42
  it("must be called on onDocumentReady", async function(done) {