jsf.js_next_gen 4.0.1-beta.4 → 4.0.1-beta.6
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.
- package/dist/window/faces-development.js +97 -68
- package/dist/window/faces-development.js.br +0 -0
- package/dist/window/faces-development.js.gz +0 -0
- package/dist/window/faces-development.js.map +1 -1
- package/dist/window/faces.js +1 -1
- package/dist/window/faces.js.br +0 -0
- package/dist/window/faces.js.gz +0 -0
- package/dist/window/faces.js.map +1 -1
- package/dist/window/jsf-development.js +97 -68
- package/dist/window/jsf-development.js.br +0 -0
- package/dist/window/jsf-development.js.gz +0 -0
- package/dist/window/jsf-development.js.map +1 -1
- package/dist/window/jsf.js +1 -1
- package/dist/window/jsf.js.br +0 -0
- package/dist/window/jsf.js.gz +0 -0
- package/dist/window/jsf.js.map +1 -1
- package/package.json +1 -1
- package/src/main/typescript/impl/util/FileUtils.ts +1 -1
- package/src/main/typescript/impl/util/XhrQueueController.ts +3 -17
- package/src/main/typescript/impl/xhrCore/ResponseProcessor.ts +4 -4
- package/src/main/typescript/impl/xhrCore/XhrRequest.ts +95 -52
- package/src/main/typescript/test/frameworkBase/_ext/monadish/DomQueryTest.spec.ts +1 -1
- package/src/main/typescript/test/frameworkBase/_ext/monadish/fixtures/blank.css +15 -0
- package/src/main/typescript/test/frameworkBase/_ext/monadish/fixtures/test.js +15 -0
- package/src/main/typescript/test/frameworkBase/_ext/monadish/fixtures/test2.js +15 -0
- package/src/main/typescript/test/frameworkBase/_ext/shared/StandardInits.ts +40 -0
- package/src/main/typescript/test/frameworkBase/_ext/shared/XmlResponses.ts +7 -0
- package/src/main/typescript/test/frameworkBase/_ext/shared/fixtures/jakarta.faces.resource/faces.js.jsf +15 -0
- package/src/main/typescript/test/myfaces/{OnLoadSpec.ts → OnLoad.spec.ts} +2 -2
- package/src/main/typescript/test/xhrCore/ErrorChainTest.spec.ts +113 -0
- package/src/main/typescript/test/xhrCore/NamespacesRequestTest.spec.ts +9 -12
- package/target/impl/util/FileUtils.js +1 -1
- package/target/impl/util/FileUtils.js.map +1 -1
- package/target/impl/util/XhrQueueController.js +3 -18
- package/target/impl/util/XhrQueueController.js.map +1 -1
- package/target/impl/xhrCore/ResponseProcessor.js +2 -2
- package/target/impl/xhrCore/ResponseProcessor.js.map +1 -1
- package/target/impl/xhrCore/XhrRequest.js +89 -45
- package/target/impl/xhrCore/XhrRequest.js.map +1 -1
- package/target/test/frameworkBase/_ext/monadish/DomQueryTest.spec.js +138 -138
- package/target/test/frameworkBase/_ext/monadish/DomQueryTest.spec.js.map +1 -1
- package/target/test/frameworkBase/_ext/shared/StandardInits.js +39 -0
- package/target/test/frameworkBase/_ext/shared/StandardInits.js.map +1 -1
- package/target/test/frameworkBase/_ext/shared/XmlResponses.js +4 -0
- package/target/test/frameworkBase/_ext/shared/XmlResponses.js.map +1 -1
- package/target/test/myfaces/OnLoad.spec.js +57 -0
- package/target/test/myfaces/OnLoad.spec.js.map +1 -0
- package/target/test/myfaces/OnLoadSpec.js +2 -2
- package/target/test/myfaces/OnLoadSpec.js.map +1 -1
- package/target/test/xhrCore/ErrorChainTest.spec.js +135 -0
- package/target/test/xhrCore/ErrorChainTest.spec.js.map +1 -0
- package/target/test/xhrCore/NamespacesRequestTest.spec.js +8 -5
- package/target/test/xhrCore/NamespacesRequestTest.spec.js.map +1 -1
package/package.json
CHANGED
|
@@ -104,5 +104,5 @@ function resolveViewState(parentItem: DomQuery): string[][] | [string, File][] {
|
|
|
104
104
|
export function getFormInputsAsArr(parentItem: DomQuery): string[][] | [string, File][] {
|
|
105
105
|
const standardInputs: any = resolveViewState(parentItem);
|
|
106
106
|
const fileInputs = resolveFiles(parentItem);
|
|
107
|
-
return standardInputs.concat(
|
|
107
|
+
return standardInputs.concat(fileInputs)
|
|
108
108
|
}
|
|
@@ -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
|
-
|
|
76
|
-
|
|
77
|
-
|
|
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
|
}
|
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
* limitations under the License.
|
|
15
15
|
*/
|
|
16
16
|
|
|
17
|
-
import {Config, DomQuery,
|
|
17
|
+
import {Config, DomQuery, DQ, DQ$, Lang, XMLQuery} from "mona-dish";
|
|
18
18
|
import {Implementation} from "../AjaxImpl";
|
|
19
19
|
import {Assertions} from "../util/Assertions";
|
|
20
20
|
import {IResponseProcessor} from "./IResponseProcessor";
|
|
@@ -115,8 +115,8 @@ export class ResponseProcessor implements IResponseProcessor {
|
|
|
115
115
|
const nodesToAdd = (shadowHead.tagName.value === "HEAD") ? shadowHead.childNodes : shadowHead;
|
|
116
116
|
// this is stored for "post" processing
|
|
117
117
|
// after the rest of the "physical build up", head before body
|
|
118
|
-
const scriptElements = nodesToAdd.
|
|
119
|
-
.filter(item => scriptTags.indexOf(item.tagName.orElse("").value) != -1)
|
|
118
|
+
const scriptElements = new DomQuery(...nodesToAdd.asArray
|
|
119
|
+
.filter(item => scriptTags.indexOf(item.tagName.orElse("").value) != -1));
|
|
120
120
|
|
|
121
121
|
this.addToHeadDeferred(scriptElements);
|
|
122
122
|
}
|
|
@@ -366,7 +366,7 @@ export class ResponseProcessor implements IResponseProcessor {
|
|
|
366
366
|
* is done.
|
|
367
367
|
*/
|
|
368
368
|
fixClientWindow() {
|
|
369
|
-
|
|
369
|
+
ofAssoc(this.internalContext.getIf(APPLIED_CLIENT_WINDOW).orElse({}).value)
|
|
370
370
|
.forEach(([, value]) => {
|
|
371
371
|
const namingContainerId = this.internalContext.getIf(NAMING_CONTAINER_ID);
|
|
372
372
|
const namedViewRoot = !!this.internalContext.getIf(NAMED_VIEWROOT).value;
|
|
@@ -41,7 +41,7 @@ import {
|
|
|
41
41
|
STATE_EVT_TIMEOUT,
|
|
42
42
|
STD_ACCEPT,
|
|
43
43
|
URL_ENCODED,
|
|
44
|
-
VAL_AJAX, IDENT_NONE, CTX_PARAM_SRC_FRM_ID, CTX_PARAM_SRC_CTL_ID, CTX_PARAM_PPS
|
|
44
|
+
VAL_AJAX, IDENT_NONE, CTX_PARAM_SRC_FRM_ID, CTX_PARAM_SRC_CTL_ID, CTX_PARAM_PPS, SERVER_ERROR
|
|
45
45
|
} from "../core/Const";
|
|
46
46
|
import {
|
|
47
47
|
resolveFinalUrl,
|
|
@@ -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
|
-
//
|
|
185
|
-
|
|
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.
|
|
223
|
+
this.onResponseReceived(resolve)
|
|
220
224
|
};
|
|
221
225
|
xhrObject.onloadend = () => {
|
|
222
|
-
this.
|
|
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
|
-
|
|
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.
|
|
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
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
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
|
-
|
|
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
|
-
|
|
293
|
+
this.handleGenericError(resolve);
|
|
266
294
|
}
|
|
267
295
|
|
|
268
|
-
|
|
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
|
-
|
|
273
|
-
|
|
274
|
-
if (!this?.xhrObject?.responseXML) {
|
|
275
|
-
|
|
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
|
|
319
|
+
private handleGenericError(resolveOrReject: Function) {
|
|
283
320
|
this.stopProgress = true;
|
|
284
321
|
const errorData = {
|
|
285
322
|
type: ERROR,
|
|
286
323
|
status: MALFORMEDXML,
|
|
287
|
-
responseCode:
|
|
288
|
-
responseText: this.xhrObject?.responseText,
|
|
289
|
-
source:
|
|
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
|
|
331
|
+
// we issue a resolveOrReject in this case to allow the system to recover
|
|
295
332
|
// reject would clean up the queue
|
|
296
|
-
resolve
|
|
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
|
-
|
|
302
|
-
|
|
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
|
-
*
|
|
352
|
+
* normal case, cleanup == next item if possible
|
|
316
353
|
*/
|
|
317
|
-
|
|
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
|
|
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);
|
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
import {expect} from 'chai';
|
|
18
18
|
import {describe, it} from 'mocha';
|
|
19
19
|
import {from} from "rxjs";
|
|
20
|
-
import {ArrayCollector, Config, DomQuery, DomQueryCollector, Lang, LazyStream, Stream} from "mona-dish";
|
|
20
|
+
import {ArrayCollector, Config, DomQuery, DomQueryCollector, Lang, LazyStream, Stream} from "mona-dish/dist/js/umd";
|
|
21
21
|
import {tobagoSheetWithHeader} from "./markups/tobago-with-header";
|
|
22
22
|
import {tobagoSheetWithoutHeader} from "./markups/tobago-without-header";
|
|
23
23
|
|
|
@@ -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
|
+
*/
|
|
@@ -1 +1,16 @@
|
|
|
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
|
+
*/
|
|
1
16
|
document.getElementById('id_1').innerHTML = "hello world";
|
|
@@ -1 +1,16 @@
|
|
|
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
|
+
*/
|
|
1
16
|
document.getElementById('id_1').innerHTML = "hello world";
|
|
@@ -236,6 +236,42 @@ export module StandardInits {
|
|
|
236
236
|
`;
|
|
237
237
|
}
|
|
238
238
|
|
|
239
|
+
export const ERROR_CHAIN_PAGE = `
|
|
240
|
+
<!DOCTYPE html>
|
|
241
|
+
<html lang="en">
|
|
242
|
+
<head>
|
|
243
|
+
<meta charset="UTF-8">
|
|
244
|
+
<title>Title</title>
|
|
245
|
+
</head>
|
|
246
|
+
<body>
|
|
247
|
+
<h2>Error Chain Testcase</h2>
|
|
248
|
+
<script type="text/javascript">
|
|
249
|
+
/**
|
|
250
|
+
* code identical to mojarra test, both stem from me
|
|
251
|
+
* so mojarras side EPL here ASL2!
|
|
252
|
+
*
|
|
253
|
+
* @param event
|
|
254
|
+
*/
|
|
255
|
+
function triggerRequestChain(event) {
|
|
256
|
+
for(let cnt = 0; cnt < 5; cnt++) {
|
|
257
|
+
faces.ajax.request(event.target, "click", {
|
|
258
|
+
render:"form1",
|
|
259
|
+
onerror: function() {
|
|
260
|
+
document.getElementById("errorCalled").innerHTML = "1";
|
|
261
|
+
}
|
|
262
|
+
})
|
|
263
|
+
}
|
|
264
|
+
}
|
|
265
|
+
</script>
|
|
266
|
+
<div id="errorCalled"></div>
|
|
267
|
+
<form id="form1">
|
|
268
|
+
<div id="form1:out1">0</div>
|
|
269
|
+
<input type="button" id="form1:button1" onclick="triggerRequestChain(event)">
|
|
270
|
+
</form>
|
|
271
|
+
</body>
|
|
272
|
+
</html>
|
|
273
|
+
`;
|
|
274
|
+
|
|
239
275
|
/**
|
|
240
276
|
* This is a standardized small page mockup
|
|
241
277
|
* testing the various aspects of the protocol
|
|
@@ -405,6 +441,10 @@ export module StandardInits {
|
|
|
405
441
|
return <any>init((IS_40) ? PROTOCOL_PAGE : PROTOCOL_PAGE.replace(/jakarta/gi,"javax"), withJsf, IS_40);
|
|
406
442
|
}
|
|
407
443
|
|
|
444
|
+
export function errorChainPage(withJsf = true, IS_40 = true): Promise<() => void> {
|
|
445
|
+
return <any>init((IS_40) ? ERROR_CHAIN_PAGE : ERROR_CHAIN_PAGE.replace(/jakarta/gi,"javax"), withJsf, IS_40);
|
|
446
|
+
}
|
|
447
|
+
|
|
408
448
|
export function prefixEmbeddedPage(withJsf = true, IS_40 = true): Promise<() => void> {
|
|
409
449
|
return <any>init((IS_40) ? HTML_FORM_PREFIXED_EMBEDDED : HTML_FORM_PREFIXED_EMBEDDED.replace(/jakarta/gi,"javax"), withJsf, IS_40);
|
|
410
450
|
}
|
|
@@ -250,4 +250,11 @@ export class XmlResponses {
|
|
|
250
250
|
`;
|
|
251
251
|
|
|
252
252
|
static ILLEGAL_RESP = `>>>> xxxx >YYYY-!->>>`;
|
|
253
|
+
|
|
254
|
+
|
|
255
|
+
static ERROR_CHAIN_RESPOND_OK = (cnt: number): string => {
|
|
256
|
+
return `<partial-response><changes><update id='form1:out1'><![CDATA[<div id="form1:out1">${cnt}</div>]]>
|
|
257
|
+
</update></changes></partial-response>`;
|
|
258
|
+
}
|
|
259
|
+
|
|
253
260
|
}
|
|
@@ -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(
|
|
36
|
+
it("must be present", async function() {
|
|
37
37
|
await defaultMyFaces();
|
|
38
38
|
expect(myfaces?.onDomReady).to.exist;
|
|
39
|
-
|
|
39
|
+
return true;
|
|
40
40
|
});
|
|
41
41
|
|
|
42
42
|
it("must be called on onDocumentReady", async function(done) {
|
|
@@ -0,0 +1,113 @@
|
|
|
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
|
+
|
|
18
|
+
import {describe} from "mocha";
|
|
19
|
+
import * as sinon from "sinon";
|
|
20
|
+
import {$nsp} from "../../impl/core/Const";
|
|
21
|
+
import {StandardInits} from "../frameworkBase/_ext/shared/StandardInits";
|
|
22
|
+
import {XmlResponses} from "../frameworkBase/_ext/shared/XmlResponses";
|
|
23
|
+
import {expect} from "chai";
|
|
24
|
+
import {Implementation} from "../../impl/AjaxImpl";
|
|
25
|
+
import errorChainPage = StandardInits.errorChainPage;
|
|
26
|
+
import {DQ} from "mona-dish";
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* Tests for error recover if an error is triggered mid chain
|
|
30
|
+
*/
|
|
31
|
+
describe('Tests of the various aspects of the response protocol functionality', function () {
|
|
32
|
+
|
|
33
|
+
beforeEach(async function () {
|
|
34
|
+
let waitForResult = errorChainPage(true);
|
|
35
|
+
return waitForResult.then((close) => {
|
|
36
|
+
|
|
37
|
+
this.xhr = sinon.useFakeXMLHttpRequest();
|
|
38
|
+
this.requests = [];
|
|
39
|
+
|
|
40
|
+
this.respond = (response: string): XMLHttpRequest => {
|
|
41
|
+
response = $nsp(response);
|
|
42
|
+
let xhrReq = this.requests.shift();
|
|
43
|
+
xhrReq.responsetype = "text/xml";
|
|
44
|
+
xhrReq.respond(200, {'Content-Type': 'text/xml'}, response);
|
|
45
|
+
return xhrReq;
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
this.respond403 = (response: string): XMLHttpRequest => {
|
|
49
|
+
let xhrReq = this.requests.shift();
|
|
50
|
+
xhrReq.responsetype = "text/html";
|
|
51
|
+
xhrReq.respond(403, {'Content-Type': 'text/html'}, "server error");
|
|
52
|
+
return xhrReq;
|
|
53
|
+
};
|
|
54
|
+
|
|
55
|
+
this.xhr.onCreate = (xhr) => {
|
|
56
|
+
this.requests.push(xhr);
|
|
57
|
+
};
|
|
58
|
+
(<any>global).XMLHttpRequest = this.xhr;
|
|
59
|
+
window.XMLHttpRequest = this.xhr;
|
|
60
|
+
|
|
61
|
+
this.closeIt = () => {
|
|
62
|
+
(<any>global).XMLHttpRequest = window.XMLHttpRequest = this.xhr.restore();
|
|
63
|
+
Implementation.reset();
|
|
64
|
+
close();
|
|
65
|
+
}
|
|
66
|
+
});
|
|
67
|
+
});
|
|
68
|
+
|
|
69
|
+
afterEach(function () {
|
|
70
|
+
this.closeIt();
|
|
71
|
+
});
|
|
72
|
+
|
|
73
|
+
it("No Error Case", function (done) {
|
|
74
|
+
DQ.byId("form1:button1").click();
|
|
75
|
+
expect(Implementation.requestQueue.queue.length >= 4).to.be.true;
|
|
76
|
+
for (let cnt = 1; cnt <= 5; cnt++) {
|
|
77
|
+
if(!Implementation.requestQueue.queue.length) {
|
|
78
|
+
//the last non queued element waits for another response
|
|
79
|
+
this.respond(XmlResponses.ERROR_CHAIN_RESPOND_OK(cnt));
|
|
80
|
+
break;
|
|
81
|
+
}
|
|
82
|
+
this.respond(XmlResponses.ERROR_CHAIN_RESPOND_OK(cnt))
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
|
|
86
|
+
expect(DQ.byId("errorCalled").innerHTML).to.eq("");
|
|
87
|
+
expect(DQ.byId("form1:out1").innerHTML).to.eq("5");
|
|
88
|
+
done();
|
|
89
|
+
})
|
|
90
|
+
|
|
91
|
+
it("must process the error chain properly", function (done) {
|
|
92
|
+
DQ.byId("form1:button1").click();
|
|
93
|
+
expect(Implementation.requestQueue.queue.length >= 4).to.be.true;
|
|
94
|
+
|
|
95
|
+
for (let cnt = 1; cnt <= 5; cnt++) {
|
|
96
|
+
if(!Implementation.requestQueue.queue.length) {
|
|
97
|
+
this.respond(XmlResponses.ERROR_CHAIN_RESPOND_OK(cnt));
|
|
98
|
+
break;
|
|
99
|
+
}
|
|
100
|
+
if (cnt == 3) {
|
|
101
|
+
//any error suffices
|
|
102
|
+
this.respond403();
|
|
103
|
+
} else {
|
|
104
|
+
this.respond(XmlResponses.ERROR_CHAIN_RESPOND_OK(cnt))
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
expect(Implementation.requestQueue.queue.length).to.eq(0);
|
|
108
|
+
expect(DQ.byId("errorCalled").innerHTML).to.eq("1");
|
|
109
|
+
expect(DQ.byId("form1:out1").innerHTML).to.eq("5");
|
|
110
|
+
done();
|
|
111
|
+
})
|
|
112
|
+
});
|
|
113
|
+
|
|
@@ -18,22 +18,19 @@ import {describe, it} from "mocha";
|
|
|
18
18
|
import * as sinon from "sinon";
|
|
19
19
|
import {expect} from "chai";
|
|
20
20
|
import {StandardInits} from "../frameworkBase/_ext/shared/StandardInits";
|
|
21
|
-
import {_Es2019Array,
|
|
21
|
+
import {_Es2019Array, DQ$} from "mona-dish";
|
|
22
22
|
import {
|
|
23
|
-
$nsp,
|
|
24
|
-
COMPLETE,
|
|
25
23
|
P_AJAX,
|
|
26
24
|
P_EXECUTE,
|
|
27
25
|
P_AJAX_SOURCE,
|
|
28
26
|
P_RENDER,
|
|
29
27
|
P_VIEWSTATE,
|
|
30
|
-
P_WINDOW_ID
|
|
31
|
-
SUCCESS
|
|
28
|
+
P_WINDOW_ID
|
|
32
29
|
} from "../../impl/core/Const";
|
|
33
|
-
import defaultMyFaces = StandardInits.defaultMyFaces;
|
|
34
|
-
import STD_XML = StandardInits.STD_XML;
|
|
35
30
|
import defaultMyFacesNamespaces = StandardInits.defaultMyFacesNamespaces;
|
|
36
31
|
import {escape} from "querystring";
|
|
32
|
+
import {ExtLang} from "../../impl/util/Lang";
|
|
33
|
+
import ofAssoc = ExtLang.ofAssoc;
|
|
37
34
|
|
|
38
35
|
declare var faces: any;
|
|
39
36
|
declare var Implementation: any;
|
|
@@ -190,13 +187,13 @@ describe('Namespacing tests', function () {
|
|
|
190
187
|
expect(!!resultsMap["render"]).to.be.false;
|
|
191
188
|
expect(!!resultsMap["execute"]).to.be.false;
|
|
192
189
|
|
|
193
|
-
let hasWindowdId =
|
|
194
|
-
let hasViewState =
|
|
190
|
+
let hasWindowdId = ofAssoc(resultsMap).filter(data => data[0].indexOf(P_WINDOW_ID) != -1)?.[0];
|
|
191
|
+
let hasViewState = ofAssoc(resultsMap).filter(data => data[0].indexOf(P_VIEWSTATE) != -1)?.[0];
|
|
195
192
|
|
|
196
|
-
expect(hasWindowdId).to.be.false;
|
|
197
|
-
expect(hasViewState).to.be.true;
|
|
193
|
+
expect(!!hasWindowdId).to.be.false;
|
|
194
|
+
expect(!!hasViewState).to.be.true;
|
|
198
195
|
|
|
199
|
-
let viewState =
|
|
196
|
+
let viewState = ofAssoc(resultsMap).filter(data => data[0].indexOf(P_VIEWSTATE) != -1).map(item => item[1])?.[0];
|
|
200
197
|
|
|
201
198
|
expect(viewState).to.eq("booga");
|
|
202
199
|
expect(resultsMap[NAMING_CONTAINER_PREF + P_AJAX_SOURCE]).to.eq("jd_0:input_2");
|