jsf.js_next_gen 4.0.0-RC.2 → 4.0.0-RC.21
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/docs/assets/main.js +56 -52
- package/dist/docs/assets/style.css +23 -0
- package/dist/docs/functions/myfaces.ab.html +2 -2
- package/dist/window/faces-development.js +789 -306
- 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.LICENSE.txt +0 -2
- 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 +789 -306
- 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.LICENSE.txt +0 -2
- 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 +16 -16
- package/src/main/test.xml +23 -0
- package/src/main/typescript/@types/definitions/index.d.ts +19 -2
- package/src/main/typescript/api/_api.ts +5 -4
- package/src/main/typescript/impl/AjaxImpl.ts +109 -37
- package/src/main/typescript/impl/core/Const.ts +48 -38
- package/src/main/typescript/impl/util/Assertions.ts +16 -8
- package/src/main/typescript/impl/util/AsyncQueue.ts +1 -1
- package/src/main/typescript/impl/util/ExtDomQuery.ts +12 -4
- package/src/main/typescript/impl/util/HiddenInputBuilder.ts +78 -0
- package/src/main/typescript/impl/util/Lang.ts +9 -11
- package/src/main/typescript/impl/xhrCore/ErrorData.ts +15 -10
- package/src/main/typescript/impl/xhrCore/EventData.ts +2 -2
- package/src/main/typescript/impl/xhrCore/IResponseProcessor.ts +8 -1
- package/src/main/typescript/impl/xhrCore/RequestDataResolver.ts +40 -22
- package/src/main/typescript/impl/xhrCore/ResonseDataResolver.ts +4 -4
- package/src/main/typescript/impl/xhrCore/Response.ts +25 -25
- package/src/main/typescript/impl/xhrCore/ResponseProcessor.ts +157 -98
- package/src/main/typescript/impl/xhrCore/XhrFormData.ts +4 -2
- package/src/main/typescript/impl/xhrCore/XhrRequest.ts +24 -14
- package/src/main/typescript/myfaces/OamSubmit.ts +29 -13
- package/src/main/typescript/test/frameworkBase/_ext/monadish/DomQueryTest.spec.ts +1 -1
- package/src/main/typescript/test/frameworkBase/_ext/shared/StandardInits.ts +72 -0
- package/src/main/typescript/test/frameworkBase/_ext/shared/XmlResponses.ts +40 -1
- package/src/main/typescript/test/impl/ImplTest.spec.ts +3 -3
- package/src/main/typescript/test/impl/ImplTest_23.spec.ts +3 -3
- package/src/main/typescript/test/xhrCore/EventTests.spec.ts +1 -1
- package/src/main/typescript/test/xhrCore/NamespacesRequestTest.spec.ts +203 -0
- package/src/main/typescript/test/xhrCore/OamSubmitTest.spec.ts +177 -0
- package/src/main/typescript/test/xhrCore/RequestParamsTest.spec.ts +116 -9
- package/src/main/typescript/test/xhrCore/RequestTest.spec.ts +236 -11
- package/src/main/typescript/test/xhrCore/RequestTest_23.spec.ts +39 -3
- package/src/main/typescript/test/xhrCore/ResponseTest.spec.ts +368 -31
- package/src/main/typescript/test/xhrCore/ResponseTest23.spec.ts +41 -7
- package/src/main/typescript/test.xml +6 -0
- package/src/main/typescript/tsconfig.json +1 -1
- package/src/tmp/test.html +12 -88
- package/target/api/_api.js +5 -4
- package/target/api/_api.js.map +1 -1
- package/target/impl/AjaxImpl.js +97 -26
- package/target/impl/AjaxImpl.js.map +1 -1
- package/target/impl/core/Const.js +48 -37
- package/target/impl/core/Const.js.map +1 -1
- package/target/impl/core/Context.js +10 -0
- package/target/impl/core/Context.js.map +1 -0
- package/target/impl/util/Assertions.js +12 -7
- package/target/impl/util/Assertions.js.map +1 -1
- package/target/impl/util/AsyncQueue.js.map +1 -1
- package/target/impl/util/ExtDomQuery.js +9 -2
- package/target/impl/util/ExtDomQuery.js.map +1 -1
- package/target/impl/util/HiddenElementBuilder.js +7 -0
- package/target/impl/util/HiddenElementBuilder.js.map +1 -0
- package/target/impl/util/HiddenInputBuilder.js +69 -0
- package/target/impl/util/HiddenInputBuilder.js.map +1 -0
- package/target/impl/util/Lang.js +8 -10
- package/target/impl/util/Lang.js.map +1 -1
- package/target/impl/xhrCore/ErrorData.js +10 -8
- package/target/impl/xhrCore/ErrorData.js.map +1 -1
- package/target/impl/xhrCore/EventData.js +1 -1
- package/target/impl/xhrCore/EventData.js.map +1 -1
- package/target/impl/xhrCore/RequestContext.js +11 -0
- package/target/impl/xhrCore/RequestContext.js.map +1 -0
- package/target/impl/xhrCore/RequestDataResolver.js +34 -15
- package/target/impl/xhrCore/RequestDataResolver.js.map +1 -1
- package/target/impl/xhrCore/ResonseDataResolver.js +3 -3
- package/target/impl/xhrCore/ResonseDataResolver.js.map +1 -1
- package/target/impl/xhrCore/Response.js +13 -13
- package/target/impl/xhrCore/Response.js.map +1 -1
- package/target/impl/xhrCore/ResponseProcessor.js +136 -82
- package/target/impl/xhrCore/ResponseProcessor.js.map +1 -1
- package/target/impl/xhrCore/XhrFormData.js +4 -2
- package/target/impl/xhrCore/XhrFormData.js.map +1 -1
- package/target/impl/xhrCore/XhrRequest.js +20 -11
- package/target/impl/xhrCore/XhrRequest.js.map +1 -1
- package/target/myfaces/OamSubmit.js +23 -14
- package/target/myfaces/OamSubmit.js.map +1 -1
- package/target/test/frameworkBase/_ext/monadish/DomQueryTest.spec.js +1 -1
- package/target/test/frameworkBase/_ext/monadish/DomQueryTest.spec.js.map +1 -1
- package/target/test/frameworkBase/_ext/shared/StandardInits.js +63 -0
- package/target/test/frameworkBase/_ext/shared/StandardInits.js.map +1 -1
- package/target/test/frameworkBase/_ext/shared/XmlResponses.js +37 -1
- package/target/test/frameworkBase/_ext/shared/XmlResponses.js.map +1 -1
- package/target/test/impl/ImplTest.spec.js +2 -2
- package/target/test/impl/ImplTest.spec.js.map +1 -1
- package/target/test/impl/ImplTest_23.spec.js +2 -2
- package/target/test/impl/ImplTest_23.spec.js.map +1 -1
- package/target/test/xhrCore/EventTests.spec.js +1 -1
- package/target/test/xhrCore/EventTests.spec.js.map +1 -1
- package/target/test/xhrCore/NamespacesRequestTest.spec.js +203 -0
- package/target/test/xhrCore/NamespacesRequestTest.spec.js.map +1 -0
- package/target/test/xhrCore/OamSubmitTest.spec.js +180 -0
- package/target/test/xhrCore/OamSubmitTest.spec.js.map +1 -0
- package/target/test/xhrCore/RequestParamsTest.spec.js +101 -4
- package/target/test/xhrCore/RequestParamsTest.spec.js.map +1 -1
- package/target/test/xhrCore/RequestTest.spec.js +212 -9
- package/target/test/xhrCore/RequestTest.spec.js.map +1 -1
- package/target/test/xhrCore/RequestTest_23.spec.js +34 -2
- package/target/test/xhrCore/RequestTest_23.spec.js.map +1 -1
- package/target/test/xhrCore/ResponseTest.spec.js +303 -22
- package/target/test/xhrCore/ResponseTest.spec.js.map +1 -1
- package/target/test/xhrCore/ResponseTest23.spec.js +36 -6
- package/target/test/xhrCore/ResponseTest23.spec.js.map +1 -1
- package/tmp.xml +36 -0
- package/target/maven-status/maven-compiler-plugin/compile/default-compile/createdFiles.lst +0 -4
- package/target/maven-status/maven-compiler-plugin/compile/default-compile/inputFiles.lst +0 -4
- package/target/maven-status/maven-compiler-plugin/testCompile/default-testCompile/createdFiles.lst +0 -1
- package/target/maven-status/maven-compiler-plugin/testCompile/default-testCompile/inputFiles.lst +0 -1
- package/target/surefire-reports/TEST-com.example.jsfs_js_ts.JsfsJsTsApplicationTests.xml +0 -78
- package/target/surefire-reports/com.example.jsfs_js_ts.JsfsJsTsApplicationTests.txt +0 -7
|
@@ -20,7 +20,11 @@ import {StandardInits} from "../frameworkBase/_ext/shared/StandardInits";
|
|
|
20
20
|
import protocolPage = StandardInits.protocolPage;
|
|
21
21
|
import {DQ} from "mona-dish";
|
|
22
22
|
import {XhrFormData} from "../../impl/xhrCore/XhrFormData";
|
|
23
|
-
import {
|
|
23
|
+
import {expect} from "chai";
|
|
24
|
+
import prefixPage = StandardInits.prefixEmbeddedPage;
|
|
25
|
+
import prefixEmbeddedPage = StandardInits.prefixEmbeddedPage;
|
|
26
|
+
import HTML_PREFIX_EMBEDDED_BODY = StandardInits.HTML_PREFIX_EMBEDDED_BODY;
|
|
27
|
+
import {it} from "mocha";
|
|
24
28
|
|
|
25
29
|
describe("test for proper request param patterns identical to the old implementation", function () {
|
|
26
30
|
const UPDATE_INSERT_2 = {
|
|
@@ -35,12 +39,12 @@ describe("test for proper request param patterns identical to the old implementa
|
|
|
35
39
|
/**
|
|
36
40
|
* matches two maps for absolute identicality
|
|
37
41
|
*/
|
|
38
|
-
let matches = (item1: {[key: string]: any}, item2: {[key: string]: any}): boolean => {
|
|
39
|
-
if(Object.keys(item1).length != Object.keys(item2).length) {
|
|
42
|
+
let matches = (item1: { [key: string]: any }, item2: { [key: string]: any }): boolean => {
|
|
43
|
+
if (Object.keys(item1).length != Object.keys(item2).length) {
|
|
40
44
|
return false;
|
|
41
45
|
}
|
|
42
|
-
for(let key in item1) {
|
|
43
|
-
if((!(key in item2)) || item1[key] != item2[key]) {
|
|
46
|
+
for (let key in item1) {
|
|
47
|
+
if ((!(key in item2)) || item1[key] != item2[key]) {
|
|
44
48
|
return false;
|
|
45
49
|
}
|
|
46
50
|
}
|
|
@@ -77,7 +81,7 @@ describe("test for proper request param patterns identical to the old implementa
|
|
|
77
81
|
this.closeIt();
|
|
78
82
|
});
|
|
79
83
|
|
|
80
|
-
it("must pass updateinsert2 with proper parameters", function() {
|
|
84
|
+
it("must pass updateinsert2 with proper parameters", function () {
|
|
81
85
|
DQ.byId("cmd_update_insert2").click();
|
|
82
86
|
|
|
83
87
|
let requestBody = this.requests[0].requestBody;
|
|
@@ -88,7 +92,7 @@ describe("test for proper request param patterns identical to the old implementa
|
|
|
88
92
|
});
|
|
89
93
|
|
|
90
94
|
|
|
91
|
-
it("must handle base64 encoded strings properly as request data", function() {
|
|
95
|
+
it("must handle base64 encoded strings properly as request data", function () {
|
|
92
96
|
let probe = "YWFhYWFhc1Rlc3RpdCDDpGtvNDU5NjczMDA9PSsrNDU5MGV3b3UkJiUmLyQmJQ==";
|
|
93
97
|
DQ.byId("jakarta.faces.ViewState").inputValue.value = probe;
|
|
94
98
|
DQ.byId("cmd_update_insert2").click();
|
|
@@ -100,7 +104,7 @@ describe("test for proper request param patterns identical to the old implementa
|
|
|
100
104
|
});
|
|
101
105
|
|
|
102
106
|
|
|
103
|
-
it("must handle empty parameters properly", function() {
|
|
107
|
+
it("must handle empty parameters properly", function () {
|
|
104
108
|
let probe = "";
|
|
105
109
|
DQ.byId("jakarta.faces.ViewState").inputValue.value = probe;
|
|
106
110
|
DQ.byId("cmd_update_insert2").click();
|
|
@@ -113,7 +117,7 @@ describe("test for proper request param patterns identical to the old implementa
|
|
|
113
117
|
|
|
114
118
|
//KssbpZfCe+0lwDhgMRQ44wRFkaM1o1lbMMUO3lini5YhXWm6
|
|
115
119
|
|
|
116
|
-
it("must handle base64 special cases properly (+ in encoding)", function() {
|
|
120
|
+
it("must handle base64 special cases properly (+ in encoding)", function () {
|
|
117
121
|
let probe = "KssbpZfCe+0lwDhgMRQ44wRFkaM1o1lbMMUO3lini5YhXWm6";
|
|
118
122
|
DQ.byId("jakarta.faces.ViewState").inputValue.value = probe;
|
|
119
123
|
DQ.byId("cmd_update_insert2").click();
|
|
@@ -123,4 +127,107 @@ describe("test for proper request param patterns identical to the old implementa
|
|
|
123
127
|
|
|
124
128
|
expect(decodeURIComponent(formData.getIf("jakarta.faces.ViewState").value) == probe).to.be.true;
|
|
125
129
|
});
|
|
130
|
+
|
|
131
|
+
it("must handle prefixed inputs properly (prefixes must be present) faces4", function (done) {
|
|
132
|
+
window.document.body.innerHTML = HTML_PREFIX_EMBEDDED_BODY;
|
|
133
|
+
|
|
134
|
+
//we now run the tests here
|
|
135
|
+
try {
|
|
136
|
+
|
|
137
|
+
let event = {
|
|
138
|
+
isTrusted: true,
|
|
139
|
+
type: 'change',
|
|
140
|
+
target: document.getElementById("page:input::field"),
|
|
141
|
+
currentTarget: document.getElementById("page:input::field")
|
|
142
|
+
};
|
|
143
|
+
faces.ajax.request(document.getElementById("page:input"), event as any, {
|
|
144
|
+
render: "page:output",
|
|
145
|
+
execute: "page:input",
|
|
146
|
+
params: {
|
|
147
|
+
"booga2.xxx": "yyy",
|
|
148
|
+
"javax.faces.behavior.event": "change",
|
|
149
|
+
"booga": "bla"
|
|
150
|
+
},
|
|
151
|
+
});
|
|
152
|
+
} catch (err) {
|
|
153
|
+
console.error(err);
|
|
154
|
+
expect(false).to.eq(true);
|
|
155
|
+
}
|
|
156
|
+
const requestBody = this.requests[0].requestBody;
|
|
157
|
+
//We check if the base64 encoded string matches the original
|
|
158
|
+
expect(requestBody.indexOf("javax.faces.behavior.event")).to.not.eq(-1);
|
|
159
|
+
expect(requestBody.indexOf("javax.faces.behavior.event=change")).to.not.eq(-1);
|
|
160
|
+
expect(requestBody.indexOf("page%3Ainput=input_value")).to.not.eq(-1);
|
|
161
|
+
done();
|
|
162
|
+
});
|
|
163
|
+
|
|
164
|
+
|
|
165
|
+
|
|
166
|
+
|
|
167
|
+
/**
|
|
168
|
+
* This test is based on Tobago 6 (Jakarte EE 9).
|
|
169
|
+
*/
|
|
170
|
+
it("must handle ':' in IDs properly", function (done) {
|
|
171
|
+
window.document.body.innerHTML = `
|
|
172
|
+
|
|
173
|
+
<tobago-page locale="en" class="container-fluid" id="page" focus-on-error="true" wait-overlay-delay-full="1000" wait-overlay-delay-ajax="1000">
|
|
174
|
+
<form action="/content/010-input/10-in/In.xhtml?jfwid=q6qbeuqed" id="page::form" method="post" accept-charset="UTF-8" data-tobago-context-path="">
|
|
175
|
+
<input type="hidden" name="jakarta.faces.source" id="jakarta.faces.source" disabled="disabled">
|
|
176
|
+
<tobago-focus id="page::lastFocusId">
|
|
177
|
+
<input type="hidden" name="page::lastFocusId" id="page::lastFocusId::field">
|
|
178
|
+
</tobago-focus>
|
|
179
|
+
<input type="hidden" name="org.apache.myfaces.tobago.webapp.Secret" id="org.apache.myfaces.tobago.webapp.Secret" value="secretValue">
|
|
180
|
+
<tobago-in id="page:input" class="tobago-auto-spacing">
|
|
181
|
+
<input type="text" name="page:input" id="page:input::field" class="form-control" value="Bob">
|
|
182
|
+
<tobago-behavior event="change" client-id="page:input" field-id="page:input::field" execute="page:input" render="page:output"></tobago-behavior>
|
|
183
|
+
</tobago-in>
|
|
184
|
+
<tobago-out id="page:output" class="tobago-auto-spacing">
|
|
185
|
+
<span class="form-control-plaintext"></span>
|
|
186
|
+
</tobago-out>
|
|
187
|
+
<div class="tobago-page-menuStore">
|
|
188
|
+
</div>
|
|
189
|
+
<span id="page::faces-state-container">
|
|
190
|
+
<input type="hidden" name="jakarta.faces.ViewState" id="j_id__v_0:jakarta.faces.ViewState:1" value="viewStateValue" autocomplete="off">
|
|
191
|
+
<input type="hidden" name="jakarta.faces.RenderKitId" value="tobago">
|
|
192
|
+
<input type="hidden" id="j_id__v_0:jakarta.faces.ClientWindow:1" name="jakarta.faces.ClientWindow" value="clientWindowValue">
|
|
193
|
+
</span>
|
|
194
|
+
</form>
|
|
195
|
+
</tobago-page>
|
|
196
|
+
`;
|
|
197
|
+
|
|
198
|
+
//we now run the tests here
|
|
199
|
+
try {
|
|
200
|
+
|
|
201
|
+
let event = {
|
|
202
|
+
isTrusted: true,
|
|
203
|
+
type: 'change',
|
|
204
|
+
target: document.getElementById("page:input::field"),
|
|
205
|
+
currentTarget: document.getElementById("page:input::field")
|
|
206
|
+
};
|
|
207
|
+
global.debug2 = true;
|
|
208
|
+
faces.ajax.request(document.getElementById("page:input"), event as any, {
|
|
209
|
+
"jakarta.faces.behavior.event": 'change',
|
|
210
|
+
execute: "page:input",
|
|
211
|
+
render: "page:output"
|
|
212
|
+
});
|
|
213
|
+
} catch (err) {
|
|
214
|
+
console.error(err);
|
|
215
|
+
expect(false).to.eq(true);
|
|
216
|
+
}
|
|
217
|
+
const requestBody = this.requests[0].requestBody;
|
|
218
|
+
expect(requestBody.indexOf("org.apache.myfaces.tobago.webapp.Secret=secretValue")).to.not.eq(-1);
|
|
219
|
+
expect(requestBody.indexOf("page%3Ainput=Bob")).to.not.eq(-1);
|
|
220
|
+
expect(requestBody.indexOf("jakarta.faces.ViewState=viewStateValue")).to.not.eq(-1);
|
|
221
|
+
expect(requestBody.indexOf("jakarta.faces.RenderKitId=tobago")).to.not.eq(-1);
|
|
222
|
+
expect(requestBody.indexOf("jakarta.faces.ClientWindow=clientWindowValue")).to.not.eq(-1);
|
|
223
|
+
expect(requestBody.indexOf("jakarta.faces.behavior.event=change")).to.not.eq(-1);
|
|
224
|
+
expect(requestBody.indexOf("jakarta.faces.partial.event=change")).to.not.eq(-1);
|
|
225
|
+
expect(requestBody.indexOf("jakarta.faces.source=page%3Ainput")).to.not.eq(-1);
|
|
226
|
+
expect(requestBody.indexOf("jakarta.faces.partial.ajax=true")).to.not.eq(-1);
|
|
227
|
+
expect(requestBody.indexOf("page%3A%3Aform=page%3A%3Aform")).to.not.eq(-1);
|
|
228
|
+
expect(requestBody.indexOf("jakarta.faces.partial.execute=page%3Ainput")).to.not.eq(-1);
|
|
229
|
+
expect(requestBody.indexOf("jakarta.faces.partial.render=page%3Aoutput")).to.not.eq(-1);
|
|
230
|
+
done();
|
|
231
|
+
});
|
|
232
|
+
|
|
126
233
|
});
|
|
@@ -20,7 +20,7 @@ import {expect} from "chai";
|
|
|
20
20
|
import {StandardInits} from "../frameworkBase/_ext/shared/StandardInits";
|
|
21
21
|
import {DomQuery} from "mona-dish";
|
|
22
22
|
import {
|
|
23
|
-
COMPLETE,
|
|
23
|
+
COMPLETE, EMPTY_STR,
|
|
24
24
|
P_AJAX,
|
|
25
25
|
P_EXECUTE,
|
|
26
26
|
P_PARTIAL_SOURCE,
|
|
@@ -39,8 +39,10 @@ let issueStdReq = function (element) {
|
|
|
39
39
|
faces.ajax.request(element, null, {
|
|
40
40
|
execute: "input_1",
|
|
41
41
|
render: "@form",
|
|
42
|
-
|
|
43
|
-
|
|
42
|
+
params: {
|
|
43
|
+
pass1: "pass1",
|
|
44
|
+
pass2: "pass2"
|
|
45
|
+
}
|
|
44
46
|
});
|
|
45
47
|
};
|
|
46
48
|
/**
|
|
@@ -103,7 +105,6 @@ describe('Tests on the xhr core when it starts to call the request', function ()
|
|
|
103
105
|
});
|
|
104
106
|
|
|
105
107
|
it('it must have the pass through values properly passed', function (done) {
|
|
106
|
-
|
|
107
108
|
let send = sinon.spy(XMLHttpRequest.prototype, "send");
|
|
108
109
|
try {
|
|
109
110
|
let element = DomQuery.byId("input_2").getAsElem(0).value;
|
|
@@ -135,6 +136,35 @@ describe('Tests on the xhr core when it starts to call the request', function ()
|
|
|
135
136
|
done();
|
|
136
137
|
});
|
|
137
138
|
|
|
139
|
+
it('it must handle resetValues properly', function (done) {
|
|
140
|
+
let send = sinon.spy(XMLHttpRequest.prototype, "send");
|
|
141
|
+
try {
|
|
142
|
+
let element = DomQuery.byId("input_2").getAsElem(0).value;
|
|
143
|
+
faces.ajax.request(element, null, {
|
|
144
|
+
execute: "input_1",
|
|
145
|
+
resetValues: true,
|
|
146
|
+
render: "@form",
|
|
147
|
+
params: {
|
|
148
|
+
pass1: "pass1",
|
|
149
|
+
pass2: "pass2"
|
|
150
|
+
}
|
|
151
|
+
});
|
|
152
|
+
|
|
153
|
+
expect(send.called).to.be.true;
|
|
154
|
+
let argsVal: any = send.args[0][0];
|
|
155
|
+
let arsArr = argsVal.split("&");
|
|
156
|
+
let resultsMap = {};
|
|
157
|
+
for (let val of arsArr) {
|
|
158
|
+
let keyVal = val.split("=");
|
|
159
|
+
resultsMap[keyVal[0]] = keyVal[1];
|
|
160
|
+
}
|
|
161
|
+
expect(resultsMap["jakarta.faces.partial.resetValues"]).to.eq("true");
|
|
162
|
+
} finally {
|
|
163
|
+
send.restore();
|
|
164
|
+
}
|
|
165
|
+
done();
|
|
166
|
+
});
|
|
167
|
+
|
|
138
168
|
it('it must have the proper target type', function (done) {
|
|
139
169
|
let send = sinon.spy(XMLHttpRequest.prototype, "send");
|
|
140
170
|
try {
|
|
@@ -196,8 +226,10 @@ describe('Tests after core when it hits response', function () {
|
|
|
196
226
|
faces.ajax.request(element, null, {
|
|
197
227
|
execute: "input_1",
|
|
198
228
|
render: "@form",
|
|
199
|
-
|
|
200
|
-
|
|
229
|
+
params: {
|
|
230
|
+
pass1: "pass1",
|
|
231
|
+
pass2: "pass2"
|
|
232
|
+
},
|
|
201
233
|
message: "Hello World",
|
|
202
234
|
onevent: (evt: any) => {
|
|
203
235
|
localCnt++;
|
|
@@ -226,7 +258,8 @@ describe('Tests after core when it hits response', function () {
|
|
|
226
258
|
|
|
227
259
|
});
|
|
228
260
|
|
|
229
|
-
it('it must have called request and the pass through values must be properly transferred
|
|
261
|
+
it('it must have called request and the pass through values must be properly transferred ' +
|
|
262
|
+
'into the context, via the old non spec conform behavior', function (done) {
|
|
230
263
|
let send = sinon.spy(XMLHttpRequest.prototype, "send");
|
|
231
264
|
let globalCnt = 0;
|
|
232
265
|
let localCnt = 0;
|
|
@@ -279,6 +312,67 @@ describe('Tests after core when it hits response', function () {
|
|
|
279
312
|
xhrReq.respond(200, {'Content-Type': 'text/xml'}, STD_XML);
|
|
280
313
|
|
|
281
314
|
|
|
315
|
+
} catch (e) {
|
|
316
|
+
console.error(e);
|
|
317
|
+
|
|
318
|
+
} finally {
|
|
319
|
+
send.restore();
|
|
320
|
+
}
|
|
321
|
+
});
|
|
322
|
+
|
|
323
|
+
it('it must have allow array key value pairs as passthroughs', function (done) {
|
|
324
|
+
let send = sinon.spy(XMLHttpRequest.prototype, "send");
|
|
325
|
+
let globalCnt = 0;
|
|
326
|
+
let localCnt = 0;
|
|
327
|
+
let xhrReq = null;
|
|
328
|
+
|
|
329
|
+
try {
|
|
330
|
+
let element = DomQuery.byId("input_2").getAsElem(0).value;
|
|
331
|
+
faces.ajax.addOnEvent(() => {
|
|
332
|
+
globalCnt++;
|
|
333
|
+
});
|
|
334
|
+
|
|
335
|
+
|
|
336
|
+
faces.ajax.request(element, null, {
|
|
337
|
+
execute: "input_1",
|
|
338
|
+
render: "@form",
|
|
339
|
+
params: [["pass1", "pass1"],
|
|
340
|
+
["pass2", "pass2"]],
|
|
341
|
+
|
|
342
|
+
onevent: (evt: any) => {
|
|
343
|
+
localCnt++;
|
|
344
|
+
if (evt.status == COMPLETE) {
|
|
345
|
+
expect(!!xhrReq.responseXML).to.be.true;
|
|
346
|
+
}
|
|
347
|
+
if (evt.status == SUCCESS) {
|
|
348
|
+
expect(this.jsfAjaxResponse.callCount).to.eq(1);
|
|
349
|
+
|
|
350
|
+
expect(this.jsfAjaxResponse.firstCall.args[0] instanceof XMLHttpRequest).to.be.true;
|
|
351
|
+
let lastArg = this.jsfAjaxResponse.firstCall.args[1];
|
|
352
|
+
expect(lastArg.onevent != null).to.be.true;
|
|
353
|
+
expect(lastArg.onevent instanceof Function).to.be.true;
|
|
354
|
+
expect(!!lastArg.onError).to.be.false;
|
|
355
|
+
expect(lastArg.pass1 == "pass1").to.be.true;
|
|
356
|
+
expect(lastArg.pass2 == "pass2").to.be.true;
|
|
357
|
+
expect(!!lastArg[P_PARTIAL_SOURCE]).to.be.true;
|
|
358
|
+
expect(!!lastArg[P_AJAX]).to.be.true;
|
|
359
|
+
expect(!!lastArg[P_EXECUTE]).to.be.true;
|
|
360
|
+
expect(!!lastArg[P_RENDER]).to.be.true;
|
|
361
|
+
|
|
362
|
+
expect(this.jsfAjaxResponse.firstCall.args.length).to.eq(2);
|
|
363
|
+
|
|
364
|
+
expect(globalCnt == 2).to.eq(true); //local before global
|
|
365
|
+
expect(localCnt == 3).to.eq(true);
|
|
366
|
+
|
|
367
|
+
done();
|
|
368
|
+
}
|
|
369
|
+
}
|
|
370
|
+
});
|
|
371
|
+
|
|
372
|
+
xhrReq = this.requests[0];
|
|
373
|
+
xhrReq.responsetype = "text/xml";
|
|
374
|
+
xhrReq.respond(200, {'Content-Type': 'text/xml'}, STD_XML);
|
|
375
|
+
|
|
282
376
|
|
|
283
377
|
} catch (e) {
|
|
284
378
|
console.error(e);
|
|
@@ -288,6 +382,68 @@ describe('Tests after core when it hits response', function () {
|
|
|
288
382
|
}
|
|
289
383
|
});
|
|
290
384
|
|
|
385
|
+
it('it must have called request and the pass through values must be properly transferred into the context', function (done) {
|
|
386
|
+
let send = sinon.spy(XMLHttpRequest.prototype, "send");
|
|
387
|
+
let globalCnt = 0;
|
|
388
|
+
let localCnt = 0;
|
|
389
|
+
let xhrReq = null;
|
|
390
|
+
|
|
391
|
+
try {
|
|
392
|
+
let element = DomQuery.byId("input_2").getAsElem(0).value;
|
|
393
|
+
faces.ajax.addOnEvent(() => {
|
|
394
|
+
globalCnt++;
|
|
395
|
+
});
|
|
396
|
+
|
|
397
|
+
|
|
398
|
+
faces.ajax.request(element, null, {
|
|
399
|
+
execute: "input_1",
|
|
400
|
+
render: "@form",
|
|
401
|
+
params: {
|
|
402
|
+
pass1: "pass1",
|
|
403
|
+
pass2: "pass2",
|
|
404
|
+
},
|
|
405
|
+
onevent: (evt: any) => {
|
|
406
|
+
localCnt++;
|
|
407
|
+
if (evt.status == COMPLETE) {
|
|
408
|
+
expect(!!xhrReq.responseXML).to.be.true;
|
|
409
|
+
}
|
|
410
|
+
if (evt.status == SUCCESS) {
|
|
411
|
+
expect(this.jsfAjaxResponse.callCount).to.eq(1);
|
|
412
|
+
|
|
413
|
+
expect(this.jsfAjaxResponse.firstCall.args[0] instanceof XMLHttpRequest).to.be.true;
|
|
414
|
+
let lastArg = this.jsfAjaxResponse.firstCall.args[1];
|
|
415
|
+
expect(lastArg.onevent != null).to.be.true;
|
|
416
|
+
expect(lastArg.onevent instanceof Function).to.be.true;
|
|
417
|
+
expect(!!lastArg.onError).to.be.false;
|
|
418
|
+
expect(lastArg.pass1 == "pass1").to.be.true;
|
|
419
|
+
expect(lastArg.pass2 == "pass2").to.be.true;
|
|
420
|
+
expect(!!lastArg[P_PARTIAL_SOURCE]).to.be.true;
|
|
421
|
+
expect(!!lastArg[P_AJAX]).to.be.true;
|
|
422
|
+
expect(!!lastArg[P_EXECUTE]).to.be.true;
|
|
423
|
+
expect(!!lastArg[P_RENDER]).to.be.true;
|
|
424
|
+
|
|
425
|
+
expect(this.jsfAjaxResponse.firstCall.args.length).to.eq(2);
|
|
426
|
+
|
|
427
|
+
expect(globalCnt == 2).to.eq(true); //local before global
|
|
428
|
+
expect(localCnt == 3).to.eq(true);
|
|
429
|
+
|
|
430
|
+
done();
|
|
431
|
+
}
|
|
432
|
+
}
|
|
433
|
+
});
|
|
434
|
+
|
|
435
|
+
xhrReq = this.requests[0];
|
|
436
|
+
xhrReq.responsetype = "text/xml";
|
|
437
|
+
xhrReq.respond(200, {'Content-Type': 'text/xml'}, STD_XML);
|
|
438
|
+
|
|
439
|
+
|
|
440
|
+
} catch (e) {
|
|
441
|
+
console.error(e);
|
|
442
|
+
|
|
443
|
+
} finally {
|
|
444
|
+
send.restore();
|
|
445
|
+
}
|
|
446
|
+
});
|
|
291
447
|
|
|
292
448
|
|
|
293
449
|
it('it must have called onError in the error case', function (done) {
|
|
@@ -302,13 +458,15 @@ describe('Tests after core when it hits response', function () {
|
|
|
302
458
|
faces.ajax.request(element, null, {
|
|
303
459
|
execute: "input_1",
|
|
304
460
|
render: "@form",
|
|
305
|
-
|
|
306
|
-
|
|
461
|
+
params: {
|
|
462
|
+
pass1: "pass1",
|
|
463
|
+
pass2: "pass2",
|
|
464
|
+
},
|
|
307
465
|
onerror: (error: any) => {
|
|
308
466
|
expect(error.type).to.eq("error");
|
|
309
|
-
expect(
|
|
467
|
+
expect(error.status).to.eq(EMPTY_STR);
|
|
310
468
|
expect(!!error.message).to.eq(true);
|
|
311
|
-
expect(!!error.source).to.eq(true);
|
|
469
|
+
expect(!!error.source?.id).to.eq(true);
|
|
312
470
|
expect(!!error.responseCode).to.eq(true);
|
|
313
471
|
expect(!!error.responseText).to.eq(true);
|
|
314
472
|
expect(!error.responseXML).to.eq(true);
|
|
@@ -333,5 +491,72 @@ describe('Tests after core when it hits response', function () {
|
|
|
333
491
|
}
|
|
334
492
|
|
|
335
493
|
});
|
|
494
|
+
|
|
495
|
+
// We can cover this TCK issue in a simple code unit test, the case is simple enough
|
|
496
|
+
it("must throw an error on invalid delays (MYFACES-4499, TCK_ISSUE320IT )", (done) => {
|
|
497
|
+
|
|
498
|
+
let element = DomQuery.byId("input_2").getAsElem(0).value;
|
|
499
|
+
try {
|
|
500
|
+
faces.ajax.request(element, null, {
|
|
501
|
+
execute: "input_1",
|
|
502
|
+
render: "@form",
|
|
503
|
+
delay: NaN,
|
|
504
|
+
params: {
|
|
505
|
+
pass1: "pass1",
|
|
506
|
+
pass2: "pass2",
|
|
507
|
+
}
|
|
508
|
+
});
|
|
509
|
+
} catch (e) {
|
|
510
|
+
expect(e.message.indexOf("NaN") > 0).to.eq(true, "Invalid NaN in message");
|
|
511
|
+
done();
|
|
512
|
+
return;
|
|
513
|
+
}
|
|
514
|
+
done("Expecting a client error to be thrown")
|
|
515
|
+
});
|
|
516
|
+
|
|
517
|
+
it("must throw an error on invalid delays (MYFACES-4499, TCK_ISSUE320IT ) - 2", (done) => {
|
|
518
|
+
|
|
519
|
+
let element = DomQuery.byId("input_2").getAsElem(0).value;
|
|
520
|
+
try {
|
|
521
|
+
faces.ajax.request(element, null, {
|
|
522
|
+
execute: "input_1",
|
|
523
|
+
render: "@form",
|
|
524
|
+
delay: -1,
|
|
525
|
+
params: {
|
|
526
|
+
pass1: "pass1",
|
|
527
|
+
pass2: "pass2",
|
|
528
|
+
}
|
|
529
|
+
});
|
|
530
|
+
} catch (e) {
|
|
531
|
+
expect(e.message.indexOf("-1") > 0).to
|
|
532
|
+
.eq(true, "Invalid integer value in message");
|
|
533
|
+
done();
|
|
534
|
+
return;
|
|
535
|
+
}
|
|
536
|
+
done("Expecting a client error to be thrown")
|
|
537
|
+
});
|
|
538
|
+
it("must throw an error on invalid delays (MYFACES-4499, TCK_ISSUE320IT ) - 3", (done) => {
|
|
539
|
+
|
|
540
|
+
let element = DomQuery.byId("input_2").getAsElem(0).value;
|
|
541
|
+
try {
|
|
542
|
+
faces.ajax.request(element, null, {
|
|
543
|
+
execute: "input_1",
|
|
544
|
+
render: "@form",
|
|
545
|
+
delay: "booga",
|
|
546
|
+
params: {
|
|
547
|
+
pass1: "pass1",
|
|
548
|
+
pass2: "pass2",
|
|
549
|
+
}
|
|
550
|
+
});
|
|
551
|
+
} catch (e) {
|
|
552
|
+
expect(e.message.indexOf("booga") > 0).to.be
|
|
553
|
+
.eq(true, "Invalid string value in message");
|
|
554
|
+
done();
|
|
555
|
+
return;
|
|
556
|
+
}
|
|
557
|
+
done("Expecting a client error to be thrown")
|
|
558
|
+
});
|
|
559
|
+
|
|
560
|
+
|
|
336
561
|
});
|
|
337
562
|
|
|
@@ -24,7 +24,7 @@ import {expect} from "chai";
|
|
|
24
24
|
import {StandardInits} from "../frameworkBase/_ext/shared/StandardInits";
|
|
25
25
|
import {DomQuery} from "mona-dish";
|
|
26
26
|
import {
|
|
27
|
-
COMPLETE,
|
|
27
|
+
COMPLETE, EMPTY_STR,
|
|
28
28
|
SUCCESS
|
|
29
29
|
} from "../../impl/core/Const";
|
|
30
30
|
;
|
|
@@ -65,6 +65,7 @@ let {
|
|
|
65
65
|
|
|
66
66
|
import STD_XML = StandardInits.STD_XML;
|
|
67
67
|
import defaultMyFaces23 = StandardInits.defaultMyFaces23;
|
|
68
|
+
import HTML_PREFIX_EMBEDDED_BODY = StandardInits.HTML_PREFIX_EMBEDDED_BODY;
|
|
68
69
|
|
|
69
70
|
declare var jsf: any;
|
|
70
71
|
declare var Implementation: any;
|
|
@@ -333,9 +334,9 @@ describe('Tests after core when it hits response', function () {
|
|
|
333
334
|
pass2: "pass2",
|
|
334
335
|
onerror: (error: any) => {
|
|
335
336
|
expect(error.type).to.eq("error");
|
|
336
|
-
expect(
|
|
337
|
+
expect(error.status).to.eq(EMPTY_STR);
|
|
337
338
|
expect(!!error.message).to.eq(true);
|
|
338
|
-
expect(!!error.source).to.eq(true);
|
|
339
|
+
expect(!!error.source.id).to.eq(true);
|
|
339
340
|
expect(!!error.responseCode).to.eq(true);
|
|
340
341
|
expect(!!error.responseText).to.eq(true);
|
|
341
342
|
expect(!error.responseXML).to.eq(true);
|
|
@@ -360,5 +361,40 @@ describe('Tests after core when it hits response', function () {
|
|
|
360
361
|
}
|
|
361
362
|
|
|
362
363
|
});
|
|
364
|
+
|
|
365
|
+
it("must handle prefixed inputs properly (prefixes must be present)", function (done) {
|
|
366
|
+
window.document.body.innerHTML = HTML_PREFIX_EMBEDDED_BODY;
|
|
367
|
+
|
|
368
|
+
//we now run the tests here
|
|
369
|
+
try {
|
|
370
|
+
|
|
371
|
+
let event = {
|
|
372
|
+
isTrusted: true,
|
|
373
|
+
type: 'change',
|
|
374
|
+
target: document.getElementById("page:input::field"),
|
|
375
|
+
currentTarget: document.getElementById("page:input::field")
|
|
376
|
+
};
|
|
377
|
+
jsf.ajax.request(document.getElementById("page:input"), event as any, {
|
|
378
|
+
render: "page:output",
|
|
379
|
+
execute: "page:input",
|
|
380
|
+
params: {
|
|
381
|
+
"booga2.xxx": "yyy",
|
|
382
|
+
"javax.faces.behavior.event": "change",
|
|
383
|
+
"booga": "bla"
|
|
384
|
+
},
|
|
385
|
+
});
|
|
386
|
+
} catch (err) {
|
|
387
|
+
console.error(err);
|
|
388
|
+
expect(false).to.eq(true);
|
|
389
|
+
}
|
|
390
|
+
const requestBody = this.requests[0].requestBody;
|
|
391
|
+
//We check if the base64 encoded string matches the original
|
|
392
|
+
expect(requestBody.indexOf("javax.faces.behavior.event")).to.not.eq(-1);
|
|
393
|
+
expect(requestBody.indexOf("javax.faces.behavior.event=change")).to.not.eq(-1);
|
|
394
|
+
expect(requestBody.indexOf("page%3Ainput=input_value")).to.not.eq(-1);
|
|
395
|
+
done();
|
|
396
|
+
});
|
|
397
|
+
|
|
398
|
+
|
|
363
399
|
});
|
|
364
400
|
|