jsf.js_next_gen 4.0.0-beta-4 → 4.0.0-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.
Files changed (134) hide show
  1. package/dist/window/faces-development.js +1952 -2468
  2. package/dist/window/faces-development.js.br +0 -0
  3. package/dist/window/faces-development.js.gz +0 -0
  4. package/dist/window/faces-development.js.map +1 -1
  5. package/dist/window/faces.js +1 -1
  6. package/dist/window/faces.js.br +0 -0
  7. package/dist/window/faces.js.gz +0 -0
  8. package/dist/window/faces.js.map +1 -1
  9. package/dist/window/jsf-development.js +1926 -2469
  10. package/dist/window/jsf-development.js.br +0 -0
  11. package/dist/window/jsf-development.js.gz +0 -0
  12. package/dist/window/jsf-development.js.map +1 -1
  13. package/dist/window/jsf.js +1 -1
  14. package/dist/window/jsf.js.br +0 -0
  15. package/dist/window/jsf.js.gz +0 -0
  16. package/dist/window/jsf.js.map +1 -1
  17. package/package.json +2 -2
  18. package/src/main/typescript/api/_api.ts +258 -0
  19. package/src/main/typescript/api/faces.ts +17 -245
  20. package/src/main/typescript/api/jsf.ts +24 -7
  21. package/src/main/typescript/impl/AjaxImpl.ts +1 -0
  22. package/src/main/typescript/impl/core/Const.ts +10 -29
  23. package/src/main/typescript/impl/util/ExtDomQuery.ts +89 -16
  24. package/src/main/typescript/impl/xhrCore/RequestDataResolver.ts +4 -4
  25. package/src/main/typescript/impl/xhrCore/ResonseDataResolver.ts +5 -3
  26. package/src/main/typescript/impl/xhrCore/Response.ts +8 -6
  27. package/src/main/typescript/impl/xhrCore/ResponseProcessor.ts +14 -13
  28. package/src/main/typescript/impl/xhrCore/XhrFormData.ts +2 -1
  29. package/src/main/typescript/myfaces/OamSubmit.ts +6 -5
  30. package/src/main/typescript/test/frameworkBase/_ext/shared/StandardInits.ts +6 -4
  31. package/src/main/typescript/test/myfaces/OamSubmit.spec.ts +14 -23
  32. package/src/main/typescript/test/xhrCore/RequestTest_23.spec.ts +362 -0
  33. package/src/main/typescript/test/xhrCore/ResponseTest23.spec.ts +372 -0
  34. package/src/main/typescript/tsconfig-typedoc.json +17 -1
  35. package/src/main/typescript/tsconfig.json +17 -2
  36. package/src/test/resources/jsf-development.js +1 -1
  37. package/target/api/Jsf.js +24 -10
  38. package/target/api/Jsf.js.map +1 -1
  39. package/target/api/_api.js +246 -0
  40. package/target/api/_api.js.map +1 -0
  41. package/target/api/_faces.js +251 -0
  42. package/target/api/_faces.js.map +1 -0
  43. package/target/api/faces.js +20 -247
  44. package/target/api/faces.js.map +1 -1
  45. package/target/impl/AjaxImpl.js +53 -61
  46. package/target/impl/AjaxImpl.js.map +1 -1
  47. package/target/impl/PushImpl.js +38 -41
  48. package/target/impl/PushImpl.js.map +1 -1
  49. package/target/impl/core/Const.js +10 -33
  50. package/target/impl/core/Const.js.map +1 -1
  51. package/target/impl/core/ImplTypes.js +9 -14
  52. package/target/impl/core/ImplTypes.js.map +1 -1
  53. package/target/impl/i18n/Messages.js +3 -4
  54. package/target/impl/i18n/Messages.js.map +1 -1
  55. package/target/impl/util/Assertions.js +9 -18
  56. package/target/impl/util/Assertions.js.map +1 -1
  57. package/target/impl/util/AsyncQueue.js +28 -36
  58. package/target/impl/util/AsyncQueue.js.map +1 -1
  59. package/target/impl/util/ExtDomQuery.js +153 -133
  60. package/target/impl/util/ExtDomQuery.js.map +1 -1
  61. package/target/impl/util/Lang.js +21 -28
  62. package/target/impl/util/Lang.js.map +1 -1
  63. package/target/impl/xhrCore/ErrorData.js +36 -61
  64. package/target/impl/xhrCore/ErrorData.js.map +1 -1
  65. package/target/impl/xhrCore/EventData.js +10 -13
  66. package/target/impl/xhrCore/EventData.js.map +1 -1
  67. package/target/impl/xhrCore/RequestDataResolver.js +16 -19
  68. package/target/impl/xhrCore/RequestDataResolver.js.map +1 -1
  69. package/target/impl/xhrCore/ResonseDataResolver.js +17 -16
  70. package/target/impl/xhrCore/ResonseDataResolver.js.map +1 -1
  71. package/target/impl/xhrCore/Response.js +21 -20
  72. package/target/impl/xhrCore/Response.js.map +1 -1
  73. package/target/impl/xhrCore/ResponseProcessor.js +126 -140
  74. package/target/impl/xhrCore/ResponseProcessor.js.map +1 -1
  75. package/target/impl/xhrCore/XhrFormData.js +68 -97
  76. package/target/impl/xhrCore/XhrFormData.js.map +1 -1
  77. package/target/impl/xhrCore/XhrRequest.js +81 -91
  78. package/target/impl/xhrCore/XhrRequest.js.map +1 -1
  79. package/target/myfaces/OamSubmit.js +20 -18
  80. package/target/myfaces/OamSubmit.js.map +1 -1
  81. package/target/test/frameworkBase/LangTest.spec.js +46 -32
  82. package/target/test/frameworkBase/LangTest.spec.js.map +1 -1
  83. package/target/test/frameworkBase/_ext/monadish/DomQueryTest.spec.js +160 -82
  84. package/target/test/frameworkBase/_ext/monadish/DomQueryTest.spec.js.map +1 -1
  85. package/target/test/frameworkBase/_ext/monadish/LangTest.spec.js +45 -31
  86. package/target/test/frameworkBase/_ext/monadish/LangTest.spec.js.map +1 -1
  87. package/target/test/frameworkBase/_ext/monadish/MappingProbes.js +24 -33
  88. package/target/test/frameworkBase/_ext/monadish/MappingProbes.js.map +1 -1
  89. package/target/test/frameworkBase/_ext/monadish/MappingTest.spec.js +8 -8
  90. package/target/test/frameworkBase/_ext/monadish/MappingTest.spec.js.map +1 -1
  91. package/target/test/frameworkBase/_ext/monadish/MonadTest.spec.js +31 -31
  92. package/target/test/frameworkBase/_ext/monadish/MonadTest.spec.js.map +1 -1
  93. package/target/test/frameworkBase/_ext/monadish/StreamTest.spec.js +50 -48
  94. package/target/test/frameworkBase/_ext/monadish/StreamTest.spec.js.map +1 -1
  95. package/target/test/frameworkBase/_ext/shared/StandardInits.js +235 -132
  96. package/target/test/frameworkBase/_ext/shared/StandardInits.js.map +1 -1
  97. package/target/test/frameworkBase/_ext/shared/XmlResponses.js +162 -18
  98. package/target/test/frameworkBase/_ext/shared/XmlResponses.js.map +1 -1
  99. package/target/test/impl/ImplTest.spec.js +34 -61
  100. package/target/test/impl/ImplTest.spec.js.map +1 -1
  101. package/target/test/impl/ImplTest_23.spec.js +35 -64
  102. package/target/test/impl/ImplTest_23.spec.js.map +1 -1
  103. package/target/test/impl/SeparatorCharsTest.spec.js +19 -19
  104. package/target/test/impl/SeparatorCharsTest.spec.js.map +1 -1
  105. package/target/test/myfaces/OamSubmit.spec.js +34 -41
  106. package/target/test/myfaces/OamSubmit.spec.js.map +1 -1
  107. package/target/test/queue/AsynchronousProbe.js +23 -29
  108. package/target/test/queue/AsynchronousProbe.js.map +1 -1
  109. package/target/test/queue/AsynchronousQueueTest.spec.js +39 -70
  110. package/target/test/queue/AsynchronousQueueTest.spec.js.map +1 -1
  111. package/target/test/xhrCore/EventTests.spec.js +47 -78
  112. package/target/test/xhrCore/EventTests.spec.js.map +1 -1
  113. package/target/test/xhrCore/FakeWebsocket.js +14 -16
  114. package/target/test/xhrCore/FakeWebsocket.js.map +1 -1
  115. package/target/test/xhrCore/FileUploadTest.spec.js +49 -80
  116. package/target/test/xhrCore/FileUploadTest.spec.js.map +1 -1
  117. package/target/test/xhrCore/RequestParamsTest.spec.js +39 -70
  118. package/target/test/xhrCore/RequestParamsTest.spec.js.map +1 -1
  119. package/target/test/xhrCore/RequestTest.spec.js +76 -113
  120. package/target/test/xhrCore/RequestTest.spec.js.map +1 -1
  121. package/target/test/xhrCore/RequestTest_23.spec.js +332 -0
  122. package/target/test/xhrCore/RequestTest_23.spec.js.map +1 -0
  123. package/target/test/xhrCore/ResponseTest.spec.js +118 -87
  124. package/target/test/xhrCore/ResponseTest.spec.js.map +1 -1
  125. package/target/test/xhrCore/ResponseTest23.spec.js +314 -0
  126. package/target/test/xhrCore/ResponseTest23.spec.js.map +1 -0
  127. package/target/test/xhrCore/ShadowDomTest.spec.js +31 -62
  128. package/target/test/xhrCore/ShadowDomTest.spec.js.map +1 -1
  129. package/target/test/xhrCore/WebsocketTest.js +60 -93
  130. package/target/test/xhrCore/WebsocketTest.js.map +1 -1
  131. package/target/test/xhrCore/XhrFormDataTest.spec.js +41 -15
  132. package/target/test/xhrCore/XhrFormDataTest.spec.js.map +1 -1
  133. package/webpack.config.js +71 -0
  134. package/webpack.config.js.map +1 -0
@@ -0,0 +1,362 @@
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
+ * Request test, testing on the 2.3 namespace fallback code
19
+ *
20
+ */
21
+ import {describe, it} from "mocha";
22
+ import * as sinon from "sinon";
23
+ import {expect} from "chai";
24
+ import {StandardInits} from "../frameworkBase/_ext/shared/StandardInits";
25
+ import {DomQuery} from "mona-dish";
26
+ import {
27
+ COMPLETE,
28
+ SUCCESS
29
+ } from "../../impl/core/Const";
30
+
31
+
32
+ /**
33
+ * wherever we reference the namespaces they must be mapped to javax instead of jakarta
34
+ */
35
+ function remapNamespacesFor23() {
36
+ const P_PARTIAL_SOURCE = "javax.faces.source";
37
+ const P_VIEWSTATE = "javax.faces.ViewState";
38
+ const P_VIEWROOT = "javax.faces.ViewRoot";
39
+ const P_VIEWHEAD = "javax.faces.ViewHead";
40
+ const P_VIEWBODY = "javax.faces.ViewBody";
41
+ const P_AJAX = "javax.faces.partial.ajax";
42
+ const P_EXECUTE = "javax.faces.partial.execute";
43
+ const P_RENDER = "javax.faces.partial.render";
44
+ const P_EVT = "javax.faces.partial.event";
45
+ const P_CLIENT_WINDOW = "javax.faces.ClientWindow";
46
+ const P_RESET_VALUES = "javax.faces.partial.resetValues";
47
+ const P_WINDOW_ID = "javax.faces.windowId";
48
+ const ENCODED_URL = "javax.faces.encodedURL";
49
+ return {
50
+ P_PARTIAL_SOURCE, P_VIEWSTATE, P_VIEWROOT, P_VIEWHEAD, P_VIEWBODY,
51
+ P_AJAX, P_EXECUTE, P_RENDER, P_EVT, P_CLIENT_WINDOW, P_RESET_VALUES,
52
+ P_WINDOW_ID, ENCODED_URL
53
+ }
54
+ }
55
+
56
+
57
+
58
+ let {
59
+ P_PARTIAL_SOURCE, P_VIEWSTATE, P_VIEWROOT, P_VIEWHEAD, P_VIEWBODY,
60
+ P_AJAX, P_EXECUTE, P_RENDER, P_EVT, P_CLIENT_WINDOW, P_RESET_VALUES,
61
+ P_WINDOW_ID, ENCODED_URL
62
+ } = remapNamespacesFor23();
63
+
64
+
65
+ import STD_XML = StandardInits.STD_XML;
66
+ import defaultMyFaces23 = StandardInits.defaultMyFaces23;
67
+
68
+ declare var jsf: any;
69
+ declare var Implementation: any;
70
+
71
+ let issueStdReq = function (element) {
72
+ jsf.ajax.request(element, null, {
73
+ execute: "input_1",
74
+ render: "@form",
75
+ pass1: "pass1",
76
+ pass2: "pass2"
77
+ });
78
+ };
79
+ /**
80
+ * specialized tests testing the xhr core behavior when it hits the xmlHttpRequest object
81
+ */
82
+ describe('Tests on the xhr core when it starts to call the request', function () {
83
+
84
+ beforeEach(async function () {
85
+
86
+ let waitForResult = defaultMyFaces23();
87
+
88
+ return waitForResult.then((close) => {
89
+
90
+ this.xhr = sinon.useFakeXMLHttpRequest();
91
+ this.requests = [];
92
+ this.xhr.onCreate = (xhr) => {
93
+ this.requests.push(xhr);
94
+ };
95
+ (<any>global).XMLHttpRequest = this.xhr;
96
+ (<any>window).XMLHttpRequest = this.xhr;
97
+
98
+ this.jsfAjaxResponse = sinon.spy((<any>global).jsf.ajax, "response");
99
+
100
+ this.closeIt = () => {
101
+ (<any>global).XMLHttpRequest = (<any>window).XMLHttpRequest = this.xhr.restore();
102
+ this.jsfAjaxResponse.restore();
103
+ Implementation.reset();
104
+ close();
105
+ }
106
+ });
107
+ });
108
+
109
+ afterEach(function () {
110
+ this.closeIt();
111
+ });
112
+
113
+ it('must have the standard parameters all in', function (done) {
114
+ //issue a standard jsf.ajax.request upon the standard simple form case and check the passed parameters
115
+ //and whether send was called
116
+ let send = sinon.spy(XMLHttpRequest.prototype, "send");
117
+
118
+ try {
119
+ let element = DomQuery.byId("input_2").getAsElem(0).value;
120
+ issueStdReq(element);
121
+
122
+ expect(this.requests.length).to.eq(1);
123
+ expect(this.requests[0].method).to.eq("POST");
124
+ expect(this.requests[0].async).to.be.true;
125
+ expect(send.called).to.be.true;
126
+ expect(send.callCount).to.eq(1);
127
+
128
+ //sent params jakarta.jsf.ViewState=null&execute=input_1&render=%40form&pass1=pass1&pass2=pass2&jakarta.jsf.windowId=null&jakarta.jsf.source=input_2&jakarta.jsf.partial.ajax=input_2&blarg=blarg&jakarta.jsf.partial.execute=input_1%20input_2&jakarta.jsf.partial.render=blarg
129
+
130
+ } finally {
131
+
132
+ send.restore();
133
+ }
134
+
135
+ done();
136
+ });
137
+
138
+ it('it must have the pass through values properly passed', function (done) {
139
+ let send = sinon.spy(XMLHttpRequest.prototype, "send");
140
+ try {
141
+ let element = DomQuery.byId("input_2").getAsElem(0).value;
142
+ issueStdReq(element);
143
+
144
+ expect(send.called).to.be.true;
145
+ let argsVal: any = send.args[0][0];
146
+ let arsArr = argsVal.split("&");
147
+ let resultsMap = {};
148
+ for (let val of arsArr) {
149
+ let keyVal = val.split("=");
150
+ resultsMap[keyVal[0]] = keyVal[1];
151
+ }
152
+
153
+ expect(resultsMap["pass1"]).to.eq("pass1");
154
+ expect(resultsMap["pass2"]).to.eq("pass2");
155
+ expect(!!resultsMap["render"]).to.be.false;
156
+ expect(!!resultsMap["execute"]).to.be.false;
157
+ expect(P_WINDOW_ID in resultsMap).to.be.false;
158
+ expect(P_VIEWSTATE in resultsMap).to.be.true;
159
+ expect(resultsMap[P_PARTIAL_SOURCE]).to.eq("input_2");
160
+ expect(resultsMap[P_AJAX]).to.eq("true");
161
+ expect(resultsMap[P_RENDER]).to.eq("blarg");
162
+ expect(resultsMap[P_EXECUTE]).to.eq("input_1%20input_2");
163
+
164
+ } finally {
165
+ send.restore();
166
+ }
167
+ done();
168
+ });
169
+
170
+ it('it must have the proper target type', function (done) {
171
+ let send = sinon.spy(XMLHttpRequest.prototype, "send");
172
+ try {
173
+ let element = DomQuery.byId("input_2").getAsElem(0).value;
174
+ issueStdReq(element);
175
+
176
+ expect(this.requests[0].requestHeaders.Accept.indexOf("application/xml") != -1).to.be.true;
177
+
178
+ } finally {
179
+ send.restore();
180
+ }
181
+ done();
182
+ });
183
+
184
+ });
185
+
186
+ describe('Tests after core when it hits response', function () {
187
+
188
+ beforeEach(async function () {
189
+
190
+ let waitForResult = defaultMyFaces23();
191
+
192
+ return waitForResult.then((close) => {
193
+
194
+ this.xhr = sinon.useFakeXMLHttpRequest();
195
+ this.requests = [];
196
+ this.xhr.onCreate = (xhr) => {
197
+ this.requests.push(xhr);
198
+ };
199
+ (<any>global).XMLHttpRequest = this.xhr = sinon.useFakeXMLHttpRequest();
200
+ (<any>window).XMLHttpRequest = this.xhr = sinon.useFakeXMLHttpRequest();
201
+
202
+ this.jsfAjaxResponse = sinon.spy((<any>global).jsf.ajax, "response");
203
+
204
+ this.closeIt = () => {
205
+ (<any>global).XMLHttpRequest = (<any>window).XMLHttpRequest = this.xhr.restore();
206
+ this.jsfAjaxResponse.restore();
207
+ Implementation.reset();
208
+ close();
209
+ }
210
+ });
211
+ });
212
+
213
+ afterEach(function () {
214
+ this.closeIt();
215
+ });
216
+
217
+ it('must have passed all ajax request phase events', function (done) {
218
+
219
+ let send = sinon.spy(XMLHttpRequest.prototype, "send");
220
+ let globalCnt = 0;
221
+ let localCnt = 0;
222
+ try {
223
+ let element = DomQuery.byId("input_2").getAsElem(0).value;
224
+ jsf.ajax.addOnEvent(() => {
225
+ globalCnt++;
226
+ });
227
+ jsf.ajax.request(element, null, {
228
+ execute: "input_1",
229
+ render: "@form",
230
+ pass1: "pass1",
231
+ pass2: "pass2",
232
+ onevent: (evt: any) => {
233
+ localCnt++;
234
+ }
235
+ });
236
+
237
+ let xhrReq = this.requests[0];
238
+
239
+ xhrReq.respond(200, {'Content-Type': 'text/xml'}, STD_XML);
240
+ expect(this.jsfAjaxResponse.callCount).to.eq(1);
241
+ //success ommitted due to fake response
242
+ expect(globalCnt == 3).to.eq(true);
243
+ expect(localCnt == 3).to.eq(true);
244
+ done();
245
+ } catch (e) {
246
+ console.error(e);
247
+
248
+ } finally {
249
+ send.restore();
250
+ }
251
+
252
+ });
253
+
254
+ it('it must have called request and the pass through values must be properly transferred into the context', function (done) {
255
+ let send = sinon.spy(XMLHttpRequest.prototype, "send");
256
+ let globalCnt = 0;
257
+ let localCnt = 0;
258
+ let xhrReq = null;
259
+
260
+ try {
261
+ let element = DomQuery.byId("input_2").getAsElem(0).value;
262
+ jsf.ajax.addOnEvent(() => {
263
+ globalCnt++;
264
+ });
265
+
266
+
267
+ jsf.ajax.request(element, null, {
268
+ execute: "input_1",
269
+ render: "@form",
270
+ pass1: "pass1",
271
+ pass2: "pass2",
272
+ onevent: (evt: any) => {
273
+ localCnt++;
274
+ if (evt.status == COMPLETE) {
275
+ expect(!!xhrReq.responseXML).to.be.true;
276
+ }
277
+ if (evt.status == SUCCESS) {
278
+ expect(this.jsfAjaxResponse.callCount).to.eq(1);
279
+
280
+ expect(this.jsfAjaxResponse.firstCall.args[0] instanceof XMLHttpRequest).to.be.true;
281
+ let lastArg = this.jsfAjaxResponse.firstCall.args[1];
282
+ expect(lastArg.onevent != null).to.be.true;
283
+ expect(lastArg.onevent instanceof Function).to.be.true;
284
+ expect(!!lastArg.onError).to.be.false;
285
+ expect(lastArg.pass1 == "pass1").to.be.true;
286
+ expect(lastArg.pass2 == "pass2").to.be.true;
287
+ expect(!!lastArg[P_PARTIAL_SOURCE]).to.be.true;
288
+ expect(!!lastArg[P_AJAX]).to.be.true;
289
+ expect(!!lastArg[P_EXECUTE]).to.be.true;
290
+ expect(!!lastArg[P_RENDER]).to.be.true;
291
+
292
+ expect(this.jsfAjaxResponse.firstCall.args.length).to.eq(2);
293
+
294
+ expect(globalCnt == 2).to.eq(true); //local before global
295
+ expect(localCnt == 3).to.eq(true);
296
+
297
+ done();
298
+ }
299
+ }
300
+ });
301
+
302
+ xhrReq = this.requests[0];
303
+ xhrReq.responsetype = "text/xml";
304
+ xhrReq.respond(200, {'Content-Type': 'text/xml'}, STD_XML);
305
+
306
+
307
+
308
+ } catch (e) {
309
+ console.error(e);
310
+
311
+ } finally {
312
+ send.restore();
313
+ }
314
+ });
315
+
316
+
317
+
318
+ it('it must have called onError in the error case', function (done) {
319
+ //on hold until it is clear why sinon is not giving me the response XML as expected
320
+
321
+ let send = sinon.spy(XMLHttpRequest.prototype, "send");
322
+ let xhrReq = null;
323
+
324
+ try {
325
+ let errorCnt = 0;
326
+ let element = DomQuery.byId("input_2").getAsElem(0).value;
327
+ jsf.ajax.request(element, null, {
328
+ execute: "input_1",
329
+ render: "@form",
330
+ pass1: "pass1",
331
+ pass2: "pass2",
332
+ onerror: (error: any) => {
333
+ expect(error.type).to.eq("error");
334
+ expect(!!error.status).to.eq(true);
335
+ expect(!!error.message).to.eq(true);
336
+ expect(!!error.source).to.eq(true);
337
+ expect(!!error.responseCode).to.eq(true);
338
+ expect(!!error.responseText).to.eq(true);
339
+ expect(!error.responseXML).to.eq(true);
340
+ done();
341
+ },
342
+ onevent: (evt: any) => {
343
+ if (evt.status == COMPLETE) {
344
+ throw Error("This error is wanted, ignore the log");
345
+ }
346
+ }
347
+ });
348
+
349
+ xhrReq = this.requests[0];
350
+ xhrReq.responsetype = "text/xml";
351
+ xhrReq.respond(200, {'Content-Type': 'text/xml'}, STD_XML);
352
+
353
+ } catch (e) {
354
+ console.error(e);
355
+
356
+ } finally {
357
+ send.restore();
358
+ }
359
+
360
+ });
361
+ });
362
+