jsf.js_next_gen 4.0.0-beta-18 → 4.0.0-beta-20

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 (101) hide show
  1. package/dist/docs/functions/faces.ajax.addOnError.html +1 -1
  2. package/dist/docs/functions/faces.ajax.addOnEvent.html +1 -1
  3. package/dist/docs/functions/faces.ajax.request.html +1 -1
  4. package/dist/docs/functions/faces.ajax.response.html +1 -1
  5. package/dist/docs/functions/faces.getClientWindow.html +1 -1
  6. package/dist/docs/functions/faces.getProjectStage.html +1 -1
  7. package/dist/docs/functions/faces.getViewState.html +1 -1
  8. package/dist/docs/functions/faces.push.close.html +1 -1
  9. package/dist/docs/functions/faces.push.init.html +1 -1
  10. package/dist/docs/functions/faces.push.open.html +1 -1
  11. package/dist/docs/functions/faces.util.chain.html +1 -1
  12. package/dist/docs/functions/myfaces.ab.html +1 -1
  13. package/dist/docs/index.html +1 -1
  14. package/dist/docs/modules/faces.ajax.html +1 -1
  15. package/dist/docs/modules/faces.html +1 -1
  16. package/dist/docs/modules/faces.push.html +1 -1
  17. package/dist/docs/modules/faces.util.html +1 -1
  18. package/dist/docs/modules/myfaces.html +1 -1
  19. package/dist/docs/modules.html +1 -1
  20. package/dist/docs/variables/faces.contextpath.html +1 -1
  21. package/dist/docs/variables/faces.implversion.html +1 -1
  22. package/dist/docs/variables/faces.separatorchar.html +1 -1
  23. package/dist/docs/variables/faces.specversion.html +1 -1
  24. package/dist/docs/variables/myfaces.oam.html +1 -1
  25. package/dist/window/faces-development.js +208 -19
  26. package/dist/window/faces-development.js.br +0 -0
  27. package/dist/window/faces-development.js.gz +0 -0
  28. package/dist/window/faces-development.js.map +1 -1
  29. package/dist/window/faces.js +1 -1
  30. package/dist/window/faces.js.br +0 -0
  31. package/dist/window/faces.js.gz +0 -0
  32. package/dist/window/faces.js.map +1 -1
  33. package/dist/window/jsf-development.js +208 -19
  34. package/dist/window/jsf-development.js.br +0 -0
  35. package/dist/window/jsf-development.js.gz +0 -0
  36. package/dist/window/jsf-development.js.map +1 -1
  37. package/dist/window/jsf.js +1 -1
  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 +6 -6
  42. package/src/main/typescript/@types/definitions/index.d.ts +14 -40
  43. package/src/main/typescript/impl/core/Const.ts +6 -0
  44. package/src/main/typescript/impl/util/ExtDomQuery.ts +11 -2
  45. package/src/main/typescript/impl/xhrCore/IResponseProcessor.ts +8 -0
  46. package/src/main/typescript/impl/xhrCore/ResonseDataResolver.ts +3 -1
  47. package/src/main/typescript/impl/xhrCore/Response.ts +6 -2
  48. package/src/main/typescript/impl/xhrCore/ResponseProcessor.ts +48 -4
  49. package/src/main/typescript/test/frameworkBase/_ext/shared/StandardInits.ts +6 -0
  50. package/src/main/typescript/test/frameworkBase/_ext/shared/XmlResponses.ts +32 -0
  51. package/src/main/typescript/test/impl/ImplTest.spec.ts +3 -8
  52. package/src/main/typescript/test/impl/ImplTest_23.spec.ts +3 -9
  53. package/src/main/typescript/test/impl/SeparatorCharsTest.spec.ts +0 -2
  54. package/src/main/typescript/test/xhrCore/EventTests.spec.ts +8 -16
  55. package/src/main/typescript/test/xhrCore/FakeWebsocket.ts +2 -2
  56. package/src/main/typescript/test/xhrCore/FileUploadTest.spec.ts +0 -25
  57. package/src/main/typescript/test/xhrCore/RequestParamsTest.spec.ts +1 -22
  58. package/src/main/typescript/test/xhrCore/RequestTest_23.spec.ts +4 -5
  59. package/src/main/typescript/test/xhrCore/ResponseTest.spec.ts +29 -17
  60. package/src/main/typescript/test/xhrCore/ResponseTest23.spec.ts +7 -17
  61. package/src/main/typescript/test/xhrCore/ShadowDomTest.spec.ts +0 -1
  62. package/src/main/typescript/test/xhrCore/WebsocketTest.ts +4 -4
  63. package/src/test.html +75 -0
  64. package/target/impl/core/Const.js +7 -3
  65. package/target/impl/core/Const.js.map +1 -1
  66. package/target/impl/util/ExtDomQuery.js +5 -2
  67. package/target/impl/util/ExtDomQuery.js.map +1 -1
  68. package/target/impl/xhrCore/ResonseDataResolver.js +1 -0
  69. package/target/impl/xhrCore/ResonseDataResolver.js.map +1 -1
  70. package/target/impl/xhrCore/Response.js +3 -0
  71. package/target/impl/xhrCore/Response.js.map +1 -1
  72. package/target/impl/xhrCore/ResponseProcessor.js +40 -3
  73. package/target/impl/xhrCore/ResponseProcessor.js.map +1 -1
  74. package/target/test/frameworkBase/_ext/shared/StandardInits.js +6 -0
  75. package/target/test/frameworkBase/_ext/shared/StandardInits.js.map +1 -1
  76. package/target/test/frameworkBase/_ext/shared/XmlResponses.js +30 -0
  77. package/target/test/frameworkBase/_ext/shared/XmlResponses.js.map +1 -1
  78. package/target/test/impl/ImplTest.spec.js +3 -5
  79. package/target/test/impl/ImplTest.spec.js.map +1 -1
  80. package/target/test/impl/ImplTest_23.spec.js +3 -6
  81. package/target/test/impl/ImplTest_23.spec.js.map +1 -1
  82. package/target/test/impl/SeparatorCharsTest.spec.js +0 -2
  83. package/target/test/impl/SeparatorCharsTest.spec.js.map +1 -1
  84. package/target/test/xhrCore/EventTests.spec.js +7 -12
  85. package/target/test/xhrCore/EventTests.spec.js.map +1 -1
  86. package/target/test/xhrCore/FakeWebsocket.js +2 -2
  87. package/target/test/xhrCore/FakeWebsocket.js.map +1 -1
  88. package/target/test/xhrCore/FileUploadTest.spec.js +0 -10
  89. package/target/test/xhrCore/FileUploadTest.spec.js.map +1 -1
  90. package/target/test/xhrCore/RequestParamsTest.spec.js +0 -18
  91. package/target/test/xhrCore/RequestParamsTest.spec.js.map +1 -1
  92. package/target/test/xhrCore/RequestTest_23.spec.js +2 -3
  93. package/target/test/xhrCore/RequestTest_23.spec.js.map +1 -1
  94. package/target/test/xhrCore/ResponseTest.spec.js +27 -9
  95. package/target/test/xhrCore/ResponseTest.spec.js.map +1 -1
  96. package/target/test/xhrCore/ResponseTest23.spec.js +6 -8
  97. package/target/test/xhrCore/ResponseTest23.spec.js.map +1 -1
  98. package/target/test/xhrCore/ShadowDomTest.spec.js +0 -1
  99. package/target/test/xhrCore/ShadowDomTest.spec.js.map +1 -1
  100. package/target/test/xhrCore/WebsocketTest.js +4 -4
  101. package/target/test/xhrCore/WebsocketTest.js.map +1 -1
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "jsf.js_next_gen",
3
- "version": "4.0.0-beta-18",
3
+ "version": "4.0.0-beta-20",
4
4
  "description": "A next generation typescript reimplementation of jsf.js",
5
5
  "main": "dist/window/faces.js",
6
6
  "scripts": {
@@ -23,17 +23,17 @@
23
23
  "@istanbuljs/nyc-config-typescript": "^1.0.2",
24
24
  "@types/chai": "^4.3.3",
25
25
  "@types/mocha": "^10.0.0",
26
- "@types/node": "^18.11.0",
26
+ "@types/node": "^18.11.9",
27
27
  "@types/sinon": "^10.0.13",
28
28
  "babel-plugin-syntax-dynamic-import": "^6.18.0",
29
29
  "chai": "^4.3.6",
30
30
  "compression-webpack-plugin": "^10.0.0",
31
31
  "html-webpack-plugin": "^5.5.0",
32
32
  "http-server": "^14.1.1",
33
- "jsdom": "^20.0.1",
33
+ "jsdom": "^20.0.2",
34
34
  "jsdom-global": "^3.0.2",
35
35
  "mocha": "^10.1.0",
36
- "npm-check-updates": "^16.3.13",
36
+ "npm-check-updates": "^16.3.16",
37
37
  "nyc": "^15.1.0",
38
38
  "replace-in-file": "^6.3.5",
39
39
  "rxjs": "^7.5.7",
@@ -41,13 +41,13 @@
41
41
  "terser-webpack-plugin": "^5.3.6",
42
42
  "ts-loader": "^9.4.1",
43
43
  "ts-node": "^10.9.1",
44
- "typedoc": "^0.23.17",
44
+ "typedoc": "^0.23.19",
45
45
  "typescript": "^4.8.4",
46
46
  "webpack": "^5.74.0",
47
47
  "webpack-cli": "^4.10.0",
48
48
  "webpack-dev-server": "^4.11.1"
49
49
  },
50
50
  "dependencies": {
51
- "mona-dish": "0.22.19"
51
+ "mona-dish": "0.22.24"
52
52
  }
53
53
  }
@@ -1,4 +1,4 @@
1
- /* Licensed to the Apache Software Foundation (ASF) under one or more
1
+ /*! Licensed to the Apache Software Foundation (ASF) under one or more
2
2
  * contributor license agreements. See the NOTICE file distributed with
3
3
  * this work for additional information regarding copyright ownership.
4
4
  * The ASF licenses this file to you under the Apache License, Version 2.0
@@ -17,29 +17,18 @@
17
17
  /**
18
18
  * Basic internal types used
19
19
  *
20
- * This file is only to eliminate various any calls into
21
- * window, jsf and myfaces and make also the calls into
22
- * the apis from a an extended window context in a type safe
23
- * way
24
- *
25
- * We use this trick to map the types into the modules
26
- * which we need to produce proper jsdoc files
20
+ * This file is only there to allow global calls into window, faces and ajax
21
+ * in a typesafe manner, hence eliminating <b>any</b> casts.
27
22
  */
28
23
  declare global {
29
24
 
30
- type Producer<T> = () => T;
31
25
  type Consumer<T> = (s?: T) => void;
32
- type Runnable = () => any;
33
- type Transformable<S, T> = (s: S) => T;
34
-
35
26
  type AssocArr<T> = { [key: string]: T };
36
-
37
27
  type EvalFuncs = Array<Function | string>;
38
28
  type Options = { [key: string]: string | Function | { [key: string]: string | Function } };
39
29
  type Context = AssocArr<any>;
40
30
  type ElemDef = Element | string;
41
31
 
42
-
43
32
  /**
44
33
  * * <ul>
45
34
  * <li> errorData.type : &quot;error&quot;</li>
@@ -58,7 +47,6 @@ declare global {
58
47
  serverErrorName: string;
59
48
  serverErrorMessage: string;
60
49
  source: any;
61
-
62
50
  responseCode: string;
63
51
  responseText: string;
64
52
  responseXML: string;
@@ -74,29 +62,8 @@ declare global {
74
62
  source: any;
75
63
  }
76
64
 
77
- /*! Licensed to the Apache Software Foundation (ASF) under one or more
78
- * contributor license agreements. See the NOTICE file distributed with
79
- * this work for additional information regarding copyright ownership.
80
- * The ASF licenses this file to you under the Apache License, Version 2.0
81
- * (the "License"); you may not use this file except in compliance with
82
- * the License. You may obtain a copy of the License at
83
- *
84
- * http://www.apache.org/licenses/LICENSE-2.0
85
- *
86
- * Unless required by applicable law or agreed to in writing, software
87
- * distributed under the License is distributed on an "AS IS" BASIS,
88
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
89
- * See the License for the specific language governing permissions and
90
- * limitations under the License.
91
- */
92
-
93
- /**
94
- * interface definitions to make the code more compiler typesafe
95
- */
96
-
97
65
  interface Ajax {
98
66
  request(element: Element, event?: Event, options?: Context): void;
99
-
100
67
  response(request: XMLHttpRequest, context?: Context): void;
101
68
  }
102
69
 
@@ -113,13 +80,10 @@ declare global {
113
80
  onclose: Function,
114
81
  behaviorScripts: any,
115
82
  autoconnect: boolean): void;
116
-
117
83
  open(socketClientId: string);
118
-
119
84
  close(socketClientId: string): void;
120
85
  }
121
86
 
122
-
123
87
  interface FacesAPI {
124
88
  contextpath: string;
125
89
  specversion: number;
@@ -155,10 +119,18 @@ declare global {
155
119
  };
156
120
  }
157
121
 
122
+ /*
123
+ * Global namespaces type definitions
124
+ */
158
125
  let myfaces: MyFacesAPI;
159
126
  let jsf: FacesAPI;
160
127
  let faces: FacesAPI;
161
- // special trick, the typscript compiler treats window as Window
128
+
129
+ // special "magic", Typescript merges whatever we have
130
+ // to window. This is a language "hack", but documented.
131
+ // see https://www.typescriptlang.org/docs/handbook/declaration-files/templates/global-modifying-module-d-ts.html
132
+ // lib.dom.d.ts declares the type Window as being type for window.
133
+ // noinspection JSUnusedGlobalSymbols
162
134
  interface Window {
163
135
  myfaces: MyFacesAPI,
164
136
  faces: FacesAPI,
@@ -167,7 +139,9 @@ declare global {
167
139
  called: { [key: string]: any }
168
140
  }
169
141
  }
142
+
170
143
  // this is needed to tell the compiler that we have an ambient
171
144
  // module, otherwise the global overload would produce an error
145
+ // https://www.typescriptlang.org/docs/handbook/declaration-files/templates/global-modifying-module-d-ts.html
172
146
  // noinspection JSUnusedGlobalSymbols
173
147
  export var __my_faces_ambient_module_glob_;
@@ -24,6 +24,8 @@ export const P_VIEWROOT = "jakarta.faces.ViewRoot";
24
24
  export const P_VIEWHEAD = "jakarta.faces.ViewHead";
25
25
  export const P_VIEWBODY = "jakarta.faces.ViewBody";
26
26
 
27
+ export const P_RESOURCE = "jakarta.faces.Resource";
28
+
27
29
  /*some useful definitions*/
28
30
 
29
31
  export const EMPTY_FUNC = Object.freeze(() => {
@@ -156,6 +158,10 @@ export const CMD_REDIRECT = "redirect";
156
158
  export const UPDATE_FORMS = "_updateForms";
157
159
  export const UPDATE_ELEMS = "_updateElems";
158
160
 
161
+ //we want the head elements to be processed before we process the body
162
+ //but after the inner html is done
163
+ export const DEFERRED_HEAD_INSERTS = "_headElems";
164
+
159
165
  export const MYFACES = "myfaces";
160
166
 
161
167
  export const SEL_SCRIPTS_STYLES = "script, style, link";
@@ -132,6 +132,8 @@ export class ExtDomquery extends DQ {
132
132
  return null;
133
133
  }
134
134
 
135
+
136
+
135
137
  private extractNonce(curScript: DomQuery) {
136
138
  return (curScript.getAsElem(0).value as HTMLElement)?.nonce ?? curScript.attr("nonce").value;
137
139
  }
@@ -160,18 +162,24 @@ export class ExtDomquery extends DQ {
160
162
  return new ExtDomquery(super.globalEval(code, nonce ?? this.nonce));
161
163
  }
162
164
 
165
+ globalEvalSticky(code: string, nonce ?: string): DQ {
166
+ return new ExtDomquery(super.globalEvalSticky(code, nonce ?? this.nonce));
167
+ }
168
+
163
169
  /**
164
170
  * decorated run scripts which takes our jsf extensions into consideration
165
171
  * (standard DomQuery will let you pass anything)
166
172
  * @param whilteListed
167
173
  */
168
- runScripts(whilteListed?: (src: string) => boolean): DomQuery {
174
+ runScripts(sticky = false, whilteListed?: (src: string) => boolean): DomQuery {
169
175
  const whitelistFunc = (src: string): boolean => {
170
176
  return (whilteListed?.(src) ?? true) && !IS_FACES_SOURCE(src) && !IS_INTERNAL_SOURCE(src);
171
177
  };
172
- return super.runScripts(whitelistFunc);
178
+ return super.runScripts(false, whitelistFunc);
173
179
  }
174
180
 
181
+
182
+
175
183
  /**
176
184
  * byId producer
177
185
  *
@@ -183,6 +191,7 @@ export class ExtDomquery extends DQ {
183
191
  const ret = DomQuery.byId(selector, deep);
184
192
  return new ExtDomquery(ret);
185
193
  }
194
+
186
195
  }
187
196
 
188
197
  export const ExtDQ = ExtDomquery;
@@ -32,6 +32,14 @@ export interface IResponseProcessor {
32
32
  */
33
33
  replaceHead(shadowHead: XMLQuery | DQ): void;
34
34
 
35
+
36
+ /**
37
+ * adds new elements to the head
38
+ *
39
+ * @param newElements the elements which need addition
40
+ */
41
+ addToHead(newElements: XMLQuery | DQ): void;
42
+
35
43
  /**
36
44
  * replace the body
37
45
  *
@@ -27,7 +27,8 @@ import {
27
27
  SOURCE,
28
28
  TAG_FORM,
29
29
  UPDATE_ELEMS,
30
- UPDATE_FORMS
30
+ UPDATE_FORMS,
31
+ DEFERRED_HEAD_INSERTS
31
32
  } from "../core/Const";
32
33
  import {ExtConfig} from "../util/ExtDomQuery";
33
34
 
@@ -75,6 +76,7 @@ export function resolveContexts(context: { [p: string]: any }): any {
75
76
  /**
76
77
  * prepare storage for some deferred operations
77
78
  */
79
+ internalContext.assign(DEFERRED_HEAD_INSERTS).value = [];
78
80
  internalContext.assign(UPDATE_FORMS).value = [];
79
81
  internalContext.assign(UPDATE_ELEMS).value = [];
80
82
  return {externalContext, internalContext};
@@ -14,7 +14,7 @@
14
14
  * limitations under the License.
15
15
  */
16
16
 
17
- import {Config, DQ, XMLQuery} from "mona-dish";
17
+ import {DQ, XMLQuery} from "mona-dish";
18
18
  import {ResponseProcessor} from "./ResponseProcessor";
19
19
 
20
20
  import {IResponseProcessor} from "./IResponseProcessor";
@@ -28,7 +28,7 @@ import {
28
28
  CMD_EXTENSION,
29
29
  CMD_INSERT,
30
30
  CMD_REDIRECT,
31
- CMD_UPDATE,
31
+ CMD_UPDATE, P_RESOURCE,
32
32
  P_VIEWBODY,
33
33
  P_VIEWHEAD,
34
34
  P_VIEWROOT,
@@ -205,6 +205,10 @@ export module Response {
205
205
  responseProcessor.replaceBody(DQ.fromMarkup(cdataBlock));
206
206
  break;
207
207
 
208
+ case $nsp(P_RESOURCE):
209
+ responseProcessor.addToHead(DQ.fromMarkup(cdataBlock))
210
+ break;
211
+
208
212
  default://htmlItem replacement
209
213
  responseProcessor.update(node, cdataBlock);
210
214
  break;
@@ -51,7 +51,8 @@ import {
51
51
  TAG_FORM,
52
52
  TAG_HEAD,
53
53
  UPDATE_ELEMS,
54
- UPDATE_FORMS
54
+ UPDATE_FORMS,
55
+ DEFERRED_HEAD_INSERTS
55
56
  } from "../core/Const";
56
57
  import trim = Lang.trim;
57
58
  import {ExtConfig, ExtDomquery} from "../util/ExtDomQuery";
@@ -86,7 +87,7 @@ export class ResponseProcessor implements IResponseProcessor {
86
87
  return;
87
88
  }
88
89
 
89
- let oldHead = DQ.querySelectorAll(TAG_HEAD);
90
+ let oldHead = ExtDomquery.querySelectorAll(TAG_HEAD);
90
91
 
91
92
  //delete all to avoid script and style overlays
92
93
  oldHead.querySelectorAll(SEL_SCRIPTS_STYLES).delete();
@@ -95,8 +96,17 @@ export class ResponseProcessor implements IResponseProcessor {
95
96
  // eval means the scripts will get attached (eval script attach method)
96
97
  // but this is done by DomQuery not in this code
97
98
  this.storeForEval(shadowHead);
99
+ //incoming either the outer head tag or its childs
100
+ //shadowHead = (shadowHead.tagName.value === "HEAD") ? shadowHead.childNodes : shadowHead;
101
+ //this.addToHead(shadowHead);
98
102
  }
99
103
 
104
+ addToHead(newElements: XMLQuery | DQ) {
105
+ this.internalContext.assign(DEFERRED_HEAD_INSERTS).value.push(newElements);
106
+ }
107
+
108
+
109
+
100
110
  /**
101
111
  * replaces the body in the expected manner
102
112
  * which means the entire body content is refreshed
@@ -114,7 +124,7 @@ export class ResponseProcessor implements IResponseProcessor {
114
124
 
115
125
  let shadowInnerHTML: string = <string>shadowBody.html().value;
116
126
 
117
- let resultingBody = <DQ>DQ.querySelectorAll(TAG_BODY).html(shadowInnerHTML);
127
+ let resultingBody = <DQ>ExtDomquery.querySelectorAll(TAG_BODY).html(shadowInnerHTML);
118
128
  let updateForms = resultingBody.querySelectorAll(TAG_FORM);
119
129
 
120
130
  // main difference, we cannot replace the body itself, but only its content
@@ -130,7 +140,7 @@ export class ResponseProcessor implements IResponseProcessor {
130
140
  * @param node the node to eval
131
141
  */
132
142
  eval(node: XMLQuery) {
133
- DQ.globalEval(node.cDATAAsString);
143
+ ExtDomquery.globalEval(node.cDATAAsString);
134
144
  }
135
145
 
136
146
  /**
@@ -303,8 +313,14 @@ export class ResponseProcessor implements IResponseProcessor {
303
313
  * generic global eval which runs the embedded css and scripts
304
314
  */
305
315
  globalEval() {
316
+ // phase one, if we have head inserts, we build up those before going into the script eval phase
317
+ let insertHeadElems = new ExtDomquery(...this.internalContext.getIf(DEFERRED_HEAD_INSERTS).value);
318
+ this.runHeadInserts(insertHeadElems);
319
+
320
+ // phase 2 we run a script eval on all updated elements in the body
306
321
  let updateElems = new ExtDomquery(...this.internalContext.getIf(UPDATE_ELEMS).value);
307
322
  updateElems.runCss();
323
+ // phase 3, we do the same for the css
308
324
  updateElems.runScripts();
309
325
  }
310
326
 
@@ -433,6 +449,11 @@ export class ResponseProcessor implements IResponseProcessor {
433
449
  this.internalContext.assign(UPDATE_ELEMS).value.push(toBeEvaled);
434
450
  }
435
451
 
452
+ // head eval is always sticky
453
+ private storeForHeadEval(toBeEvaled: DQ, sticky) {
454
+ this.internalContext.assign(DEFERRED_HEAD_INSERTS).value.push(toBeEvaled);
455
+ }
456
+
436
457
  /**
437
458
  * check whether a given XMLQuery node is an explicit viewstate node
438
459
  *
@@ -463,4 +484,27 @@ export class ResponseProcessor implements IResponseProcessor {
463
484
  this.externalContext.getIf(ON_ERROR).orElse(this.internalContext.getIf(ON_ERROR).value).orElse(EMPTY_FUNC).value(errorData);
464
485
  }
465
486
 
487
+
488
+ /**
489
+ * adds new elements to the head as per spec, we use it in a deferred way
490
+ * to have the html buildup first then the head inserts which run the head evals
491
+ * and then the body and css evals from the markup
492
+ *
493
+ * This is only performed upon a head replacement or resource insert
494
+ *
495
+ * @param newElements the elements which need addition
496
+ */
497
+ private runHeadInserts(newElements: ExtDomquery): void {
498
+ let head = ExtDomquery.byId(document.head);
499
+ //automated nonce handling
500
+ newElements.each(element => {
501
+ if(element.tagName.value != "SCRIPT" || element.attr("src").isPresent()) {
502
+ head.append(element);
503
+ return;
504
+ }
505
+ // special corner case
506
+ // embedded script code,
507
+ element.globalEvalSticky(element.innerHTML);
508
+ });
509
+ }
466
510
  }
@@ -194,6 +194,12 @@ export module StandardInits {
194
194
 
195
195
  <input type="button" id="cmd_update_insert" value="update insert"
196
196
  onclick="emitPPR(this, ('undefined' == typeof event)? null: event, 'updateinsert1');"/>
197
+
198
+ <input type="button" id="cmd_simple_resource" value="simple resource"
199
+ onclick="emitPPR(this, ('undefined' == typeof event)? null: event, 'simpleresource');"/>
200
+
201
+ <input type="button" id="cmd_complex_resource" value="complex resource"
202
+ onclick="emitPPR(this, ('undefined' == typeof event)? null: event, 'complex_resource');"/>
197
203
 
198
204
  <input type="button" id="cmd_update_insert2" value="update insert second protocol path"
199
205
  onclick="emitPPR(this, ('undefined' == typeof event)? null: event, 'updateinsert2');"/>
@@ -170,5 +170,37 @@ export class XmlResponses {
170
170
  </partial-response>
171
171
  `;
172
172
 
173
+ static SIMPLE_RESOURCE_RESPONSE = `
174
+ <partial-response>
175
+ <changes>
176
+ <update id="jakarta.faces.Resource">
177
+ <![CDATA[<script src="/test-faces23-ajax-4466/jakarta.faces.resource/addedViaHead.js.xhtml?ln=spec1423"></script>]]>
178
+ </update>
179
+ </changes>
180
+ </partial-response>
181
+ `;
182
+ static MULTIPLE_RESOURCE_RESPONSE = `
183
+ <partial-response id="j_id__v_0"><changes><update id="jakarta.faces.Resource">
184
+ <![CDATA[
185
+ <script src="/test-faces23-ajax-4466/jakarta.faces.resource/addedViaHead.js.xhtml?ln=spec1423"></script>
186
+ <style type="text/css" rel="/test-faces23-ajax-4466/jakarta.faces.resource/addedViaHead.css.xhtml?ln=spec1423"></style>
187
+ ]]>
188
+ </update>
189
+ </changes>
190
+ </partial-response>
191
+ `
192
+
193
+ static EMBEDDED_SCRIPTS_RESOURCE_RESPONSE = `
194
+ <partial-response id="j_id__v_0"><changes><update id="jakarta.faces.Resource">
195
+ <![CDATA[
196
+ <script src="/test-faces23-ajax-4466/jakarta.faces.resource/addedViaHead.js.xhtml?ln=spec1423"></script>
197
+ <style type="text/css" rel="/test-faces23-ajax-4466/jakarta.faces.resource/addedViaHead.css.xhtml?ln=spec1423"></style>
198
+ <script type="text/javascript">document.body.innerHTML = 'booga'</script>
199
+ ]]>
200
+ </update>
201
+ </changes>
202
+ </partial-response>
203
+ `
204
+
173
205
  static ILLEGAL_RESP = `>>>> xxxx >YYYY-!->>>`;
174
206
  }
@@ -14,16 +14,14 @@
14
14
  * limitations under the License.
15
15
  */
16
16
 
17
- import {Config} from "mona-dish";
17
+ import {Config, DomQuery} from "mona-dish";
18
18
  import {describe, it} from 'mocha';
19
19
  import {expect} from 'chai';
20
20
  import * as sinon from 'sinon';
21
21
 
22
- import {DomQuery} from "mona-dish";
23
-
24
22
  import {StandardInits} from "../frameworkBase/_ext/shared/StandardInits";
25
- import defaultMyFaces = StandardInits.defaultMyFaces;
26
23
  import {P_EXECUTE, P_RENDER} from "../../impl/core/Const";
24
+ import defaultMyFaces = StandardInits.defaultMyFaces;
27
25
 
28
26
 
29
27
  sinon.reset();
@@ -48,8 +46,7 @@ describe('faces.ajax.request test suite', () => {
48
46
  //we stub the addRequestToQueue, to enable the request check only
49
47
  //without any xhr and response, both will be tested separately for
50
48
  //proper behavior
51
- const Impl = Implementation;
52
- const addRequestToQueue = sinon.stub(Impl.queueHandler, "addRequestToQueue");
49
+ const addRequestToQueue = sinon.stub(Implementation.queueHandler, "addRequestToQueue");
53
50
  //now the faces.ajax.request should trigger but should not go into
54
51
  //the asynchronous event loop.
55
52
  //lets check it out
@@ -61,8 +58,6 @@ describe('faces.ajax.request test suite', () => {
61
58
 
62
59
  expect(addRequestToQueue.called).to.be.true;
63
60
  expect(addRequestToQueue.callCount).to.eq(1);
64
-
65
- const argElement = <Config>addRequestToQueue.args[0][2];
66
61
  const context = (<Config>addRequestToQueue.args[0][2]);
67
62
 
68
63
  expect(context.getIf("passThrgh", P_RENDER).value).eq("@all");
@@ -14,13 +14,11 @@
14
14
  * limitations under the License.
15
15
  */
16
16
 
17
- import {Config} from "mona-dish";
17
+ import {Config, DomQuery} from "mona-dish";
18
18
  import {describe, it} from 'mocha';
19
19
  import {expect} from 'chai';
20
20
  import * as sinon from 'sinon';
21
21
 
22
- import {DomQuery} from "mona-dish";
23
-
24
22
  import {StandardInits} from "../frameworkBase/_ext/shared/StandardInits";
25
23
  import {P_EXECUTE, P_RENDER} from "../../impl/core/Const";
26
24
  import defaultMyFaces23 = StandardInits.defaultMyFaces23;
@@ -41,16 +39,14 @@ declare var Implementation: any;
41
39
  describe('javax.ajax.request test suite', () => {
42
40
 
43
41
  beforeEach(async () => {
44
- let ret = await defaultMyFaces23();
45
- return ret;
42
+ return await defaultMyFaces23();
46
43
  });
47
44
 
48
45
  it("jsf.ajax.request can be called", () => {
49
46
  //we stub the addRequestToQueue, to enable the request check only
50
47
  //without any xhr and response, both will be tested separately for
51
48
  //proper behavior
52
- const Impl = Implementation;
53
- const addRequestToQueue = sinon.stub(Impl.queueHandler, "addRequestToQueue");
49
+ const addRequestToQueue = sinon.stub(Implementation.queueHandler, "addRequestToQueue");
54
50
  //now the javax.ajax.request should trigger but should not go into
55
51
  //the asynchronous event loop.
56
52
  //lets check it out
@@ -62,8 +58,6 @@ describe('javax.ajax.request test suite', () => {
62
58
 
63
59
  expect(addRequestToQueue.called).to.be.true;
64
60
  expect(addRequestToQueue.callCount).to.eq(1);
65
-
66
- const argElement = <Config>addRequestToQueue.args[0][2];
67
61
  const context = (<Config>addRequestToQueue.args[0][2]);
68
62
 
69
63
  expect(context.getIf("passThrgh", P_RENDER).value).eq("@all");
@@ -21,8 +21,6 @@ import {StandardInits} from "../frameworkBase/_ext/shared/StandardInits";
21
21
  import defaultMyFaces = StandardInits.defaultMyFaces;
22
22
  import defaultSeparatorChar = StandardInits.defaultSeparatorChar;
23
23
 
24
- const jsdom = require("jsdom");
25
- const {JSDOM} = jsdom;
26
24
  sinon.reset();
27
25
 
28
26
  declare var faces: any;
@@ -28,6 +28,7 @@ declare var faces: any;
28
28
 
29
29
  describe('tests the addOnEvent and addOnError handling', function () {
30
30
 
31
+ // noinspection DuplicatedCode
31
32
  beforeEach(async function () {
32
33
  let waitForResult = protocolPage();
33
34
  return waitForResult.then((close) => {
@@ -36,7 +37,7 @@ describe('tests the addOnEvent and addOnError handling', function () {
36
37
  this.requests = [];
37
38
 
38
39
  this.respond = (response: string): XMLHttpRequest => {
39
- let xhrReq = this.requests.shift();
40
+ let xhrReq = (this.requests as Array<any>).shift();
40
41
  xhrReq.responsetype = "text/xml";
41
42
  xhrReq.respond(200, {'Content-Type': 'text/xml'}, response);
42
43
  return xhrReq;
@@ -59,13 +60,6 @@ describe('tests the addOnEvent and addOnError handling', function () {
59
60
  afterEach(function () {
60
61
  this.closeIt();
61
62
  });
62
-
63
- let allowedStati = {
64
- "begin": true,
65
- "complete": true,
66
- "success": true,
67
- };
68
-
69
63
  it("must have a global add on event call with all three phases passed", function () {
70
64
  let onEventCalled1 = 0;
71
65
  let onEventCalled2 = 0;
@@ -82,11 +76,10 @@ describe('tests the addOnEvent and addOnError handling', function () {
82
76
  throw ("Wrong status")
83
77
  }
84
78
  });
85
- faces.ajax.addOnEvent((data: any) => {
79
+ faces.ajax.addOnEvent(() => {
86
80
  onEventCalled2++;
87
-
88
81
  });
89
- let issuer = DQ.byId("cmd_update_insert").click();
82
+ DQ.byId("cmd_update_insert").click();
90
83
  this.respond(XmlResponses.UPDATE_INSERT_1);
91
84
 
92
85
  expect(onEventCalled1).to.eq(3);
@@ -104,12 +97,12 @@ describe('tests the addOnEvent and addOnError handling', function () {
104
97
  errorMessage = data.errorMessage;
105
98
  onErrorCalled1++
106
99
  });
107
- faces.ajax.addOnError((data: any) => {
100
+ faces.ajax.addOnError(() => {
108
101
  onErrorCalled2++;
109
102
  });
110
103
 
111
104
  //cmd_error_component
112
- let issuer = DQ.byId("cmd_error_component").click();
105
+ DQ.byId("cmd_error_component").click();
113
106
  this.respond(XmlResponses.ERROR_2);
114
107
 
115
108
  expect(onErrorCalled1).to.eq(1);
@@ -119,7 +112,6 @@ describe('tests the addOnEvent and addOnError handling', function () {
119
112
  });
120
113
 
121
114
  it("must have an id set if there is an emitting element", function () {
122
- let onEventCalled1 = 0;
123
115
  let onEventCalled2 = 0;
124
116
 
125
117
  let assertSourceExists = (data: any) => {
@@ -129,11 +121,11 @@ describe('tests the addOnEvent and addOnError handling', function () {
129
121
  faces.ajax.addOnEvent((data: any) => {
130
122
  assertSourceExists(data);
131
123
  });
132
- faces.ajax.addOnEvent((data: any) => {
124
+ faces.ajax.addOnEvent(() => {
133
125
  onEventCalled2++;
134
126
 
135
127
  });
136
- let issuer = DQ.byId("cmd_update_insert").click();
128
+ DQ.byId("cmd_update_insert").click();
137
129
  this.respond(XmlResponses.UPDATE_INSERT_1);
138
130
 
139
131
  });
@@ -19,14 +19,14 @@ export class FakeWebsocket {
19
19
  onmessage: Function = () => {}
20
20
  onclose: Function = () => {}
21
21
 
22
- constructor(data?: any) {
22
+ constructor() {
23
23
  setTimeout(() => {
24
24
  this.onopen();
25
25
  }, 10);
26
26
  }
27
27
 
28
28
 
29
- send(msg: any) {
29
+ send() {
30
30
  }
31
31
 
32
32
  _respond(response: any) {