jsf.js_next_gen 4.0.0-RC.3 → 4.0.0-RC.31

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 (185) hide show
  1. package/dist/docs/assets/main.js +56 -52
  2. package/dist/docs/assets/style.css +23 -0
  3. package/dist/window/faces-development.js +2961 -3011
  4. package/dist/window/faces-development.js.br +0 -0
  5. package/dist/window/faces-development.js.gz +0 -0
  6. package/dist/window/faces-development.js.map +1 -1
  7. package/dist/window/faces.js +1 -1
  8. package/dist/window/faces.js.LICENSE.txt +0 -2
  9. package/dist/window/faces.js.br +0 -0
  10. package/dist/window/faces.js.gz +0 -0
  11. package/dist/window/faces.js.map +1 -1
  12. package/dist/window/jsf-development.js +2966 -3016
  13. package/dist/window/jsf-development.js.br +0 -0
  14. package/dist/window/jsf-development.js.gz +0 -0
  15. package/dist/window/jsf-development.js.map +1 -1
  16. package/dist/window/jsf.js +1 -1
  17. package/dist/window/jsf.js.LICENSE.txt +0 -2
  18. package/dist/window/jsf.js.br +0 -0
  19. package/dist/window/jsf.js.gz +0 -0
  20. package/dist/window/jsf.js.map +1 -1
  21. package/package.json +16 -16
  22. package/src/main/test.xml +23 -0
  23. package/src/main/typescript/@types/definitions/index.d.ts +12 -7
  24. package/src/main/typescript/api/_api.ts +4 -3
  25. package/src/main/typescript/impl/AjaxImpl.ts +125 -41
  26. package/src/main/typescript/impl/core/Const.ts +52 -41
  27. package/src/main/typescript/impl/util/Assertions.ts +16 -8
  28. package/src/main/typescript/impl/util/ExtDomQuery.ts +12 -4
  29. package/src/main/typescript/impl/util/FileUtils.ts +66 -0
  30. package/src/main/typescript/impl/util/HiddenInputBuilder.ts +89 -0
  31. package/src/main/typescript/impl/util/Lang.ts +9 -11
  32. package/src/main/typescript/impl/xhrCore/ErrorData.ts +15 -10
  33. package/src/main/typescript/impl/xhrCore/EventData.ts +2 -2
  34. package/src/main/typescript/impl/xhrCore/IResponseProcessor.ts +15 -1
  35. package/src/main/typescript/impl/xhrCore/RequestDataResolver.ts +69 -24
  36. package/src/main/typescript/impl/xhrCore/ResonseDataResolver.ts +4 -4
  37. package/src/main/typescript/impl/xhrCore/Response.ts +55 -38
  38. package/src/main/typescript/impl/xhrCore/ResponseProcessor.ts +173 -98
  39. package/src/main/typescript/impl/xhrCore/XhrFormData.ts +91 -168
  40. package/src/main/typescript/impl/xhrCore/XhrRequest.ts +39 -23
  41. package/src/main/typescript/myfaces/OamSubmit.ts +29 -13
  42. package/src/main/typescript/test/frameworkBase/_ext/monadish/DomQueryTest.spec.ts +1 -1
  43. package/src/main/typescript/test/frameworkBase/_ext/shared/StandardInits.ts +73 -1
  44. package/src/main/typescript/test/frameworkBase/_ext/shared/XmlResponses.ts +40 -1
  45. package/src/main/typescript/test/impl/ImplTest.spec.ts +3 -3
  46. package/src/main/typescript/test/impl/ImplTest_23.spec.ts +3 -3
  47. package/src/main/typescript/test/xhrCore/EventTests.spec.ts +1 -1
  48. package/src/main/typescript/test/xhrCore/FileUploadTest.spec.ts +5 -2
  49. package/src/main/typescript/test/xhrCore/NamespacesRequestTest.spec.ts +203 -0
  50. package/src/main/typescript/test/xhrCore/OamSubmitTest.spec.ts +177 -0
  51. package/src/main/typescript/test/xhrCore/RequestParamsTest.spec.ts +158 -17
  52. package/src/main/typescript/test/xhrCore/RequestTest.spec.ts +70 -3
  53. package/src/main/typescript/test/xhrCore/RequestTest_23.spec.ts +39 -3
  54. package/src/main/typescript/test/xhrCore/ResponseTest.spec.ts +372 -34
  55. package/src/main/typescript/test/xhrCore/ResponseTest23.spec.ts +43 -9
  56. package/src/main/typescript/test/xhrCore/XhrFormDataTest.spec.ts +67 -49
  57. package/src/main/typescript/test.xml +6 -0
  58. package/src/main/typescript/tsconfig.json +2 -2
  59. package/src/test/resources/jsf-development.js +1 -1
  60. package/src/tmp/test.html +12 -88
  61. package/target/api/_api.js +16 -29
  62. package/target/api/_api.js.map +1 -1
  63. package/target/api/faces.js +4 -4
  64. package/target/api/faces.js.map +1 -1
  65. package/target/api/jsf.js +9 -9
  66. package/target/api/jsf.js.map +1 -1
  67. package/target/classes/com/example/jsfs_js_ts/DecoratedFacesJS.class +0 -0
  68. package/target/classes/com/example/jsfs_js_ts/DecoratingResourceHandlerWrapper.class +0 -0
  69. package/target/classes/com/example/jsfs_js_ts/FacesJSMapFileResourceWrapper.class +0 -0
  70. package/target/classes/com/example/jsfs_js_ts/FacesJSMappingDecorator.class +0 -0
  71. package/target/impl/AjaxImpl.js +155 -89
  72. package/target/impl/AjaxImpl.js.map +1 -1
  73. package/target/impl/PushImpl.js +45 -48
  74. package/target/impl/PushImpl.js.map +1 -1
  75. package/target/impl/core/Const.js +52 -40
  76. package/target/impl/core/Const.js.map +1 -1
  77. package/target/impl/core/Context.js +10 -0
  78. package/target/impl/core/Context.js.map +1 -0
  79. package/target/impl/core/ImplTypes.js +9 -14
  80. package/target/impl/core/ImplTypes.js.map +1 -1
  81. package/target/impl/i18n/Messages.js +3 -4
  82. package/target/impl/i18n/Messages.js.map +1 -1
  83. package/target/impl/util/Assertions.js +20 -24
  84. package/target/impl/util/Assertions.js.map +1 -1
  85. package/target/impl/util/AsyncQueue.js +28 -36
  86. package/target/impl/util/AsyncQueue.js.map +1 -1
  87. package/target/impl/util/ExtDomQuery.js +153 -221
  88. package/target/impl/util/ExtDomQuery.js.map +1 -1
  89. package/target/impl/util/FileUtils.js +64 -0
  90. package/target/impl/util/FileUtils.js.map +1 -0
  91. package/target/impl/util/HiddenElementBuilder.js +7 -0
  92. package/target/impl/util/HiddenElementBuilder.js.map +1 -0
  93. package/target/impl/util/HiddenInputBuilder.js +79 -0
  94. package/target/impl/util/HiddenInputBuilder.js.map +1 -0
  95. package/target/impl/util/Lang.js +23 -32
  96. package/target/impl/util/Lang.js.map +1 -1
  97. package/target/impl/util/URLCodec.js +77 -0
  98. package/target/impl/util/URLCodec.js.map +1 -0
  99. package/target/impl/xhrCore/ErrorData.js +41 -64
  100. package/target/impl/xhrCore/ErrorData.js.map +1 -1
  101. package/target/impl/xhrCore/EventData.js +10 -13
  102. package/target/impl/xhrCore/EventData.js.map +1 -1
  103. package/target/impl/xhrCore/RequestContext.js +11 -0
  104. package/target/impl/xhrCore/RequestContext.js.map +1 -0
  105. package/target/impl/xhrCore/RequestDataResolver.js +71 -27
  106. package/target/impl/xhrCore/RequestDataResolver.js.map +1 -1
  107. package/target/impl/xhrCore/ResonseDataResolver.js +16 -16
  108. package/target/impl/xhrCore/ResonseDataResolver.js.map +1 -1
  109. package/target/impl/xhrCore/Response.js +43 -28
  110. package/target/impl/xhrCore/Response.js.map +1 -1
  111. package/target/impl/xhrCore/ResponseProcessor.js +217 -162
  112. package/target/impl/xhrCore/ResponseProcessor.js.map +1 -1
  113. package/target/impl/xhrCore/XhrFormData.js +92 -208
  114. package/target/impl/xhrCore/XhrFormData.js.map +1 -1
  115. package/target/impl/xhrCore/XhrRequest.js +104 -104
  116. package/target/impl/xhrCore/XhrRequest.js.map +1 -1
  117. package/target/myfaces/OamSubmit.js +33 -24
  118. package/target/myfaces/OamSubmit.js.map +1 -1
  119. package/target/test/frameworkBase/LangTest.spec.js +46 -32
  120. package/target/test/frameworkBase/LangTest.spec.js.map +1 -1
  121. package/target/test/frameworkBase/_ext/monadish/DomQueryTest.spec.js +238 -228
  122. package/target/test/frameworkBase/_ext/monadish/DomQueryTest.spec.js.map +1 -1
  123. package/target/test/frameworkBase/_ext/monadish/LangTest.spec.js +45 -31
  124. package/target/test/frameworkBase/_ext/monadish/LangTest.spec.js.map +1 -1
  125. package/target/test/frameworkBase/_ext/monadish/MappingProbes.js +24 -33
  126. package/target/test/frameworkBase/_ext/monadish/MappingProbes.js.map +1 -1
  127. package/target/test/frameworkBase/_ext/monadish/MappingTest.spec.js +8 -8
  128. package/target/test/frameworkBase/_ext/monadish/MappingTest.spec.js.map +1 -1
  129. package/target/test/frameworkBase/_ext/monadish/MonadTest.spec.js +31 -31
  130. package/target/test/frameworkBase/_ext/monadish/MonadTest.spec.js.map +1 -1
  131. package/target/test/frameworkBase/_ext/monadish/StreamTest.spec.js +50 -48
  132. package/target/test/frameworkBase/_ext/monadish/StreamTest.spec.js.map +1 -1
  133. package/target/test/frameworkBase/_ext/shared/StandardInits.js +310 -132
  134. package/target/test/frameworkBase/_ext/shared/StandardInits.js.map +1 -1
  135. package/target/test/frameworkBase/_ext/shared/XmlResponses.js +235 -22
  136. package/target/test/frameworkBase/_ext/shared/XmlResponses.js.map +1 -1
  137. package/target/test/impl/ImplTest.spec.js +32 -59
  138. package/target/test/impl/ImplTest.spec.js.map +1 -1
  139. package/target/test/impl/ImplTest_23.spec.js +32 -59
  140. package/target/test/impl/ImplTest_23.spec.js.map +1 -1
  141. package/target/test/impl/SeparatorCharsTest.spec.js +17 -17
  142. package/target/test/impl/SeparatorCharsTest.spec.js.map +1 -1
  143. package/target/test/myfaces/OamSubmit.spec.js +25 -25
  144. package/target/test/myfaces/OamSubmit.spec.js.map +1 -1
  145. package/target/test/queue/AsynchronousProbe.js +23 -29
  146. package/target/test/queue/AsynchronousProbe.js.map +1 -1
  147. package/target/test/queue/AsynchronousQueueTest.spec.js +39 -70
  148. package/target/test/queue/AsynchronousQueueTest.spec.js.map +1 -1
  149. package/target/test/xhrCore/EventTests.spec.js +43 -74
  150. package/target/test/xhrCore/EventTests.spec.js.map +1 -1
  151. package/target/test/xhrCore/FakeWebsocket.js +14 -16
  152. package/target/test/xhrCore/FakeWebsocket.js.map +1 -1
  153. package/target/test/xhrCore/FileUploadTest.spec.js +48 -78
  154. package/target/test/xhrCore/FileUploadTest.spec.js.map +1 -1
  155. package/target/test/xhrCore/NamespacesRequestTest.spec.js +204 -0
  156. package/target/test/xhrCore/NamespacesRequestTest.spec.js.map +1 -0
  157. package/target/test/xhrCore/OamSubmitTest.spec.js +180 -0
  158. package/target/test/xhrCore/OamSubmitTest.spec.js.map +1 -0
  159. package/target/test/xhrCore/RequestParamsTest.spec.js +174 -73
  160. package/target/test/xhrCore/RequestParamsTest.spec.js.map +1 -1
  161. package/target/test/xhrCore/RequestTest.spec.js +173 -149
  162. package/target/test/xhrCore/RequestTest.spec.js.map +1 -1
  163. package/target/test/xhrCore/RequestTest_23.spec.js +127 -142
  164. package/target/test/xhrCore/RequestTest_23.spec.js.map +1 -1
  165. package/target/test/xhrCore/ResponseTest.spec.js +415 -100
  166. package/target/test/xhrCore/ResponseTest.spec.js.map +1 -1
  167. package/target/test/xhrCore/ResponseTest23.spec.js +152 -91
  168. package/target/test/xhrCore/ResponseTest23.spec.js.map +1 -1
  169. package/target/test/xhrCore/ShadowDomTest.spec.js +30 -61
  170. package/target/test/xhrCore/ShadowDomTest.spec.js.map +1 -1
  171. package/target/test/xhrCore/WebsocketTest.js +60 -93
  172. package/target/test/xhrCore/WebsocketTest.js.map +1 -1
  173. package/target/test/xhrCore/XhrFormDataTest.spec.js +79 -30
  174. package/target/test/xhrCore/XhrFormDataTest.spec.js.map +1 -1
  175. package/target/test-classes/.gz +0 -0
  176. package/target/test-classes/com/example/jsfs_js_ts/JsfsJsTsApplicationTests.class +0 -0
  177. package/target/test-classes/fileuploadtest.html +24 -0
  178. package/target/test-classes/jsf-development.js +3559 -0
  179. package/target/test-classes/jsf-development.js.br +0 -0
  180. package/target/test-classes/jsf-development.js.gz +0 -0
  181. package/target/test-classes/jsf-development.js.map +1 -0
  182. package/target/test-classes/jsf.js +3 -0
  183. package/target/test-classes/jsf.js.br +0 -0
  184. package/target/test-classes/jsf.js.gz +0 -0
  185. package/tmp.xml +36 -0
@@ -46,40 +46,13 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
46
46
  step((generator = generator.apply(thisArg, _arguments || [])).next());
47
47
  });
48
48
  };
49
- var __generator = (this && this.__generator) || function (thisArg, body) {
50
- var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
51
- return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
52
- function verb(n) { return function (v) { return step([n, v]); }; }
53
- function step(op) {
54
- if (f) throw new TypeError("Generator is already executing.");
55
- while (_) try {
56
- if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
57
- if (y = 0, t) op = [op[0] & 2, t.value];
58
- switch (op[0]) {
59
- case 0: case 1: t = op; break;
60
- case 4: _.label++; return { value: op[1], done: false };
61
- case 5: _.label++; y = op[1]; op = [0]; continue;
62
- case 7: op = _.ops.pop(); _.trys.pop(); continue;
63
- default:
64
- if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
65
- if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
66
- if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
67
- if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
68
- if (t[2]) _.ops.pop();
69
- _.trys.pop(); continue;
70
- }
71
- op = body.call(thisArg, _);
72
- } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
73
- if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
74
- }
75
- };
76
49
  Object.defineProperty(exports, "__esModule", { value: true });
77
- var mocha_1 = require("mocha");
78
- var StandardInits_1 = require("../frameworkBase/_ext/shared/StandardInits");
79
- var sinon = __importStar(require("sinon"));
80
- var XmlResponses_1 = require("../frameworkBase/_ext/shared/XmlResponses");
81
- var chai_1 = require("chai");
82
- var mona_dish_1 = require("mona-dish");
50
+ const mocha_1 = require("mocha");
51
+ const StandardInits_1 = require("../frameworkBase/_ext/shared/StandardInits");
52
+ const sinon = __importStar(require("sinon"));
53
+ const XmlResponses_1 = require("../frameworkBase/_ext/shared/XmlResponses");
54
+ const chai_1 = require("chai");
55
+ const mona_dish_1 = require("mona-dish");
83
56
  var protocolPage = StandardInits_1.StandardInits.protocolPage;
84
57
  /**
85
58
  * response test
@@ -89,31 +62,27 @@ var protocolPage = StandardInits_1.StandardInits.protocolPage;
89
62
  */
90
63
  (0, mocha_1.describe)('Tests of the various aspects of the response protocol functionality', function () {
91
64
  beforeEach(function () {
92
- return __awaiter(this, void 0, void 0, function () {
93
- var waitForResult;
94
- var _this = this;
95
- return __generator(this, function (_a) {
96
- waitForResult = protocolPage();
97
- return [2 /*return*/, waitForResult.then(function (close) {
98
- _this.xhr = sinon.useFakeXMLHttpRequest();
99
- _this.requests = [];
100
- _this.respond = function (response) {
101
- var xhrReq = _this.requests.shift();
102
- xhrReq.responsetype = "text/xml";
103
- xhrReq.respond(200, { 'Content-Type': 'text/xml' }, response);
104
- return xhrReq;
105
- };
106
- _this.xhr.onCreate = function (xhr) {
107
- _this.requests.push(xhr);
108
- };
109
- global.XMLHttpRequest = _this.xhr;
110
- window.XMLHttpRequest = _this.xhr;
111
- _this.closeIt = function () {
112
- global.XMLHttpRequest = window.XMLHttpRequest = _this.xhr.restore();
113
- Implementation.reset();
114
- close();
115
- };
116
- })];
65
+ return __awaiter(this, void 0, void 0, function* () {
66
+ let waitForResult = protocolPage();
67
+ return waitForResult.then((close) => {
68
+ this.xhr = sinon.useFakeXMLHttpRequest();
69
+ this.requests = [];
70
+ this.respond = (response) => {
71
+ let xhrReq = this.requests.shift();
72
+ xhrReq.responsetype = "text/xml";
73
+ xhrReq.respond(200, { 'Content-Type': 'text/xml' }, response);
74
+ return xhrReq;
75
+ };
76
+ this.xhr.onCreate = (xhr) => {
77
+ this.requests.push(xhr);
78
+ };
79
+ global.XMLHttpRequest = this.xhr;
80
+ window.XMLHttpRequest = this.xhr;
81
+ this.closeIt = () => {
82
+ global.XMLHttpRequest = window.XMLHttpRequest = this.xhr.restore();
83
+ Implementation.reset();
84
+ close();
85
+ };
117
86
  });
118
87
  });
119
88
  });
@@ -129,15 +98,15 @@ var protocolPage = StandardInits_1.StandardInits.protocolPage;
129
98
  .orElse("fail")
130
99
  .value.indexOf("update succeeded 1") != -1)
131
100
  .to.be.true;
132
- var pos1 = mona_dish_1.DQ.byId(document.body).html()
101
+ let pos1 = mona_dish_1.DQ.byId(document.body).html()
133
102
  .value.indexOf("insert before succeeded should display before test1");
134
- var pos3 = mona_dish_1.DQ.byId(document.body).html()
103
+ let pos3 = mona_dish_1.DQ.byId(document.body).html()
135
104
  .value.indexOf("insert after succeeded should display after test1");
136
- var pos2 = mona_dish_1.DQ.byId(document.body).html()
105
+ let pos2 = mona_dish_1.DQ.byId(document.body).html()
137
106
  .value.indexOf("update succeeded 1");
138
107
  (0, chai_1.expect)(pos1 != -1).to.be.true;
139
108
  (0, chai_1.expect)(pos1 < pos2 && pos2 < pos3).to.be.true;
140
- var pos4 = mona_dish_1.DQ.byId(document.body).html()
109
+ let pos4 = mona_dish_1.DQ.byId(document.body).html()
141
110
  .value.indexOf("embedded script at update succeed");
142
111
  (0, chai_1.expect)(pos4 != -1).to.be.true;
143
112
  done();
@@ -151,15 +120,15 @@ var protocolPage = StandardInits_1.StandardInits.protocolPage;
151
120
  .orElse("fail")
152
121
  .value.indexOf("update succeeded 2") != -1)
153
122
  .to.be.true;
154
- var pos1 = mona_dish_1.DQ.byId(document.body).html()
123
+ let pos1 = mona_dish_1.DQ.byId(document.body).html()
155
124
  .value.indexOf("insert before succeeded should display before test1");
156
- var pos3 = mona_dish_1.DQ.byId(document.body).html()
125
+ let pos3 = mona_dish_1.DQ.byId(document.body).html()
157
126
  .value.indexOf("insert after succeeded should display after test1");
158
- var pos2 = mona_dish_1.DQ.byId(document.body).html()
127
+ let pos2 = mona_dish_1.DQ.byId(document.body).html()
159
128
  .value.indexOf("update succeeded 2");
160
129
  (0, chai_1.expect)(pos1 != -1).to.be.true;
161
130
  (0, chai_1.expect)(pos1 < pos2 && pos2 < pos3).to.be.true;
162
- var pos4 = mona_dish_1.DQ.byId(document.body).html()
131
+ let pos4 = mona_dish_1.DQ.byId(document.body).html()
163
132
  .value.indexOf("embedded script at update succeed");
164
133
  (0, chai_1.expect)(pos4 != -1).to.be.true;
165
134
  done();
@@ -168,8 +137,8 @@ var protocolPage = StandardInits_1.StandardInits.protocolPage;
168
137
  mona_dish_1.DQ.byId("cmd_replace").click();
169
138
  this.respond(XmlResponses_1.XmlResponses.BODY_REPLACEMENT);
170
139
  //basic replacement
171
- var newBody = mona_dish_1.DQ.byId(document.body);
172
- var newContent = newBody.html().value;
140
+ let newBody = mona_dish_1.DQ.byId(document.body);
141
+ let newContent = newBody.html().value;
173
142
  //standard replacement successful
174
143
  (0, chai_1.expect)(newContent.indexOf("<h3>Body replacement test successful</h3>") != -1, "elements must be updated").to.be.true;
175
144
  //script eval
@@ -182,8 +151,8 @@ var protocolPage = StandardInits_1.StandardInits.protocolPage;
182
151
  mona_dish_1.DQ.byId("cmd_replace").click();
183
152
  this.respond(XmlResponses_1.XmlResponses.HEAD_REPLACEMENT);
184
153
  //basic replacement
185
- var newBody = mona_dish_1.DQ.byId(document.body);
186
- var newContent = newBody.html().value;
154
+ let newBody = mona_dish_1.DQ.byId(document.body);
155
+ let newContent = newBody.html().value;
187
156
  //standard replacement successful
188
157
  //script eval
189
158
  //modern browsers block head replacement but you still can eval
@@ -193,9 +162,9 @@ var protocolPage = StandardInits_1.StandardInits.protocolPage;
193
162
  mona_dish_1.DQ.byId("cmd_replace").click();
194
163
  this.respond(XmlResponses_1.XmlResponses.VIEW_ROOT_REPLACEMENT);
195
164
  //basic replacement
196
- var newHead = mona_dish_1.DQ.byId(document.head);
197
- var newBody = mona_dish_1.DQ.byId(document.body);
198
- var newContent = newBody.html().value;
165
+ let newHead = mona_dish_1.DQ.byId(document.head);
166
+ let newBody = mona_dish_1.DQ.byId(document.body);
167
+ let newContent = newBody.html().value;
199
168
  (0, chai_1.expect)(newHead.isPresent(), " head must exist ").to.be.true;
200
169
  //standard replacement successful
201
170
  (0, chai_1.expect)(newContent.indexOf("<h3>Body replacement test successful</h3>") != -1, "elements must be updated").to.be.true;
@@ -209,10 +178,10 @@ var protocolPage = StandardInits_1.StandardInits.protocolPage;
209
178
  //modern browsers block head replacement but you still can eval
210
179
  (0, chai_1.expect)(newContent.indexOf(">hello from embedded script in replacement head") != -1, "embedded scripts must be executed").to.be.true;
211
180
  });
212
- it("must have a viewstate update to be peformed", function () {
181
+ it("must have a viewState update to be performed", function () {
213
182
  mona_dish_1.DQ.byId("cmd_viewstate").click();
214
183
  this.respond(XmlResponses_1.XmlResponses.VIEWSTATE_1);
215
- var viewStateElem = mona_dish_1.DQ.byId('jakarta.faces.ViewState');
184
+ let viewStateElem = mona_dish_1.DQ.byId('jakarta.faces.ViewState');
216
185
  (0, chai_1.expect)(viewStateElem.inputValue.value == "hello world").to.be.true;
217
186
  });
218
187
  it("must have processed a proper delete", function () {
@@ -223,36 +192,66 @@ var protocolPage = StandardInits_1.StandardInits.protocolPage;
223
192
  it("must have processed a proper eval of a script given in the eval tag", function () {
224
193
  mona_dish_1.DQ.byId("cmd_eval").click();
225
194
  this.respond(XmlResponses_1.XmlResponses.EVAL_1);
226
- var resultHTML = mona_dish_1.DQ.byId(document.body).html().value;
195
+ let resultHTML = mona_dish_1.DQ.byId(document.body).html().value;
227
196
  (0, chai_1.expect)(resultHTML.indexOf('eval test succeeded') != -1).to.be.true;
228
197
  });
229
- it("must have updated the viewstates properly", function () {
198
+ it("must have updated the viewstates properly", function (done) {
230
199
  mona_dish_1.DQ.byId("cmd_eval").click();
231
200
  /*js full submit form, coming from the integration tests*/
232
- window.document.body.innerHTML = "<form id=\"j_id__v_0\" name=\"j_id__v_0\" method=\"post\" action=\"/IntegrationJSTest/integrationtestsjasmine/test7-eventtest.jsf\"\n enctype=\"application/x-www-form-urlencoded\"><span id=\"updatePanel\">hello world</span><a href=\"#\"\n onclick=\"return faces.util.chain(this, event,'return false;', 'return myfaces.ab('j_id_1l','updateTrigger');');\"\n id=\"updateTrigger\"\n name=\"updateTrigger\"\n class=\"updateTrigger\">[Press\n me for Update]</a><input type=\"hidden\" name=\"j_id_1l_SUBMIT\" value=\"1\">\n</form>";
201
+ window.document.body.innerHTML = `<form id="j_id__v_0" name="j_id__v_0" method="post" action="/IntegrationJSTest/integrationtestsjasmine/test7-eventtest.jsf"
202
+ ><span id="updatePanel">hello world</span><a href="#"
203
+ onclick="return faces.util.chain(this, event,'return false;', 'return myfaces.ab(\'j_id_1l\',\'updateTrigger\');');"
204
+ id="updateTrigger"
205
+ name="updateTrigger"
206
+ class="updateTrigger">[Press
207
+ me for Update]</a><input type="hidden" name="j_id_1l_SUBMIT" value="1">
208
+ </form>`;
233
209
  faces.ajax.request(window.document.getElementById("updateTrigger"), null, {
234
210
  render: "updatePanel",
235
211
  execute: "updatePanel updateTrigger"
236
212
  });
237
213
  // language=XML
238
- this.respond("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n <partial-response id=\"j_id__v_0\">\n <changes>\n <update id=\"updatePanel\"><![CDATA[<span id=\"updatePanel\">hello world</span>]]></update>\n <update id=\"j_id__v_0:jakarta.faces.ViewState:1\"><![CDATA[RTUyRDI0NzE4QzAxM0E5RDAwMDAwMDVD]]></update>\n </changes>\n </partial-response>");
239
- (0, chai_1.expect)(mona_dish_1.DQ.byId("jakarta.faces.ViewState").isAbsent()).to.be.false;
240
- (0, chai_1.expect)(document.getElementById("jakarta.faces.ViewState").value == "RTUyRDI0NzE4QzAxM0E5RDAwMDAwMDVD").to.be.true;
241
- (0, chai_1.expect)(mona_dish_1.DQ.byId("jakarta.faces.ViewState").inputValue.value == "RTUyRDI0NzE4QzAxM0E5RDAwMDAwMDVD").to.be.true;
214
+ this.respond(`<?xml version="1.0" encoding="UTF-8"?>
215
+ <partial-response id="j_id__v_0">
216
+ <changes>
217
+ <update id="updatePanel"><![CDATA[<span id="updatePanel">hello world</span>]]></update>
218
+ <update id="j_id__v_0:jakarta.faces.ViewState:1"><![CDATA[RTUyRDI0NzE4QzAxM0E5RDAwMDAwMDVD]]></update>
219
+ </changes>
220
+ </partial-response>`);
221
+ setTimeout(() => {
222
+ (0, chai_1.expect)((0, mona_dish_1.DQ$)("[name*='jakarta.faces.ViewState']").isPresent()).to.be.true;
223
+ (0, chai_1.expect)((0, mona_dish_1.DQ$)("[name*='jakarta.faces.ViewState']").val == "RTUyRDI0NzE4QzAxM0E5RDAwMDAwMDVD").to.be.true;
224
+ done();
225
+ }, 100);
242
226
  });
243
227
  it("must have updated the viewstates properly with lenient update block", function () {
244
228
  mona_dish_1.DQ.byId("cmd_eval").click();
245
229
  /*js full submit form, coming from the integration tests*/
246
- window.document.body.innerHTML = "<form id=\"j_id__v_0\" name=\"j_id__v_0\" method=\"post\" action=\"/IntegrationJSTest/integrationtestsjasmine/test7-eventtest.jsf\"\n enctype=\"application/x-www-form-urlencoded\"><span id=\"updatePanel\">hello world</span><a href=\"#\"\n onclick=\"return faces.util.chain(this, event,'return false;', 'return myfaces.ab('j_id_1l','updateTrigger');');\"\n id=\"updateTrigger\"\n name=\"updateTrigger\"\n class=\"updateTrigger\">[Press\n me for Update]</a><input type=\"hidden\" name=\"j_id_1l_SUBMIT\" value=\"1\">\n</form>";
230
+ window.document.body.innerHTML = `<form id="j_id__v_0" name="j_id__v_0" method="post" action="/IntegrationJSTest/integrationtestsjasmine/test7-eventtest.jsf"
231
+ ><span id="updatePanel">hello world</span><a href="#"
232
+ onclick="return faces.util.chain(this, event,'return false;', 'return myfaces.ab(\'j_id_1l\',\'updateTrigger\');');"
233
+ id="updateTrigger"
234
+ name="updateTrigger"
235
+ class="updateTrigger">[Press
236
+ me for Update]</a><input type="hidden" name="j_id_1l_SUBMIT" value="1">
237
+ </form>`;
247
238
  faces.ajax.request(window.document.getElementById("updateTrigger"), null, {
248
239
  render: "updatePanel",
249
240
  execute: "updatePanel updateTrigger"
250
241
  });
251
242
  // language=XML
252
- this.respond("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n <partial-response id=\"j_id__v_0\">\n <changes>\n <update id=\"updatePanel\"><![CDATA[<span id=\"updatePanel\">hello world</span>]]></update>\n <update id=\"j_id__v_0:jakarta.faces.ViewState:1\"><![CDATA[RTUyRDI0NzE4QzAxM0E5RDAwMDAwMDVD]]><!-- \n Some random junk which is sent by the server\n --></update>\n </changes>\n </partial-response>");
253
- (0, chai_1.expect)(mona_dish_1.DQ.byId("jakarta.faces.ViewState").isAbsent()).to.be.false;
254
- (0, chai_1.expect)(document.getElementById("jakarta.faces.ViewState").value == "RTUyRDI0NzE4QzAxM0E5RDAwMDAwMDVD").to.be.true;
255
- (0, chai_1.expect)(mona_dish_1.DQ.byId("jakarta.faces.ViewState").inputValue.value == "RTUyRDI0NzE4QzAxM0E5RDAwMDAwMDVD").to.be.true;
243
+ this.respond(`<?xml version="1.0" encoding="UTF-8"?>
244
+ <partial-response id="j_id__v_0">
245
+ <changes>
246
+ <update id="updatePanel"><![CDATA[<span id="updatePanel">hello world</span>]]></update>
247
+ <update id="j_id__v_0:jakarta.faces.ViewState:1"><![CDATA[RTUyRDI0NzE4QzAxM0E5RDAwMDAwMDVD]]><!--
248
+ Some random junk which is sent by the server
249
+ --></update>
250
+ </changes>
251
+ </partial-response>`);
252
+ (0, chai_1.expect)((0, mona_dish_1.DQ$)("[name*='jakarta.faces.ViewState']").isAbsent()).to.be.false;
253
+ // expect((<HTMLInputElement>document.getElementsByName("jakarta.faces.ViewState")[0]).value == "RTUyRDI0NzE4QzAxM0E5RDAwMDAwMDVD").to.be.true;
254
+ (0, chai_1.expect)((0, mona_dish_1.DQ$)("[name*='jakarta.faces.ViewState']").inputValue.value == "RTUyRDI0NzE4QzAxM0E5RDAwMDAwMDVD").to.be.true;
256
255
  });
257
256
  /**
258
257
  * The body innerHTML is based on a Tobago page. View state and client window id is rendered within a
@@ -260,7 +259,28 @@ var protocolPage = StandardInits_1.StandardInits.protocolPage;
260
259
  * Beside the tobago-out tag, the view state and the client window id must be updated properly.
261
260
  */
262
261
  it("must have updated the client window tag properly", function () {
263
- window.document.body.innerHTML = "<tobago-page locale='en' class='container-fluid' id='page'>\n <form action='/IntegrationJSTest/integrationtestsjasmine/tobago-jfwid-test.jsf' id='page::form' method='post' accept-charset='UTF-8' data-tobago-context-path=''>\n <input type='hidden' name='jakarta.faces.source' id='jakarta.faces.source' disabled='disabled'>\n <tobago-focus id='page::lastFocusId'>\n <input type='hidden' name='page::lastFocusId' id='page::lastFocusId::field'>\n </tobago-focus>\n <input type='hidden' name='org.apache.myfaces.tobago.webapp.Secret' id='org.apache.myfaces.tobago.webapp.Secret' value='SLrPlxqLEaR/oYFLSu4wgg=='>\n <tobago-in id='page:input' class='tobago-margin-bottom'>\n <input type='text' name='page:input' id='page:input::field' class='tobago-in form-control' value='Alice'>\n <tobago-behavior event='change' client-id='page:input' field-id='page:input::field' execute='page:input' render='page:output'></tobago-behavior>\n </tobago-in>\n <div id='page:output' class='tobago-margin-bottom'>\n <tobago-out class='form-control-plaintext'></tobago-out>\n </div>\n <div class='tobago-page-menuStore'></div>\n <span id='page::jsf-state-container'>\n <input type='hidden' name='jakarta.faces.ViewState' id='j_id__v_0:jakarta.faces.ViewState:1' value='RkExQ0Q1NTYzOTNCNzg0RjAwMDAwMDE4' autocomplete='off'>\n <input type='hidden' name='jakarta.faces.RenderKitId' value='tobago'>\n <input type='hidden' id='j_id__v_0:jakarta.faces.ClientWindow:1' name='jakarta.faces.ClientWindow' value='5m10kooxi'>\n </span>\n </form>\n </tobago-page>";
262
+ window.document.body.innerHTML = `<tobago-page locale='en' class='container-fluid' id='page'>
263
+ <form action='/IntegrationJSTest/integrationtestsjasmine/tobago-jfwid-test.jsf' id='page::form' method='post' accept-charset='UTF-8' data-tobago-context-path=''>
264
+ <input type='hidden' name='jakarta.faces.source' id='jakarta.faces.source' disabled='disabled'>
265
+ <tobago-focus id='page::lastFocusId'>
266
+ <input type='hidden' name='page::lastFocusId' id='page::lastFocusId::field'>
267
+ </tobago-focus>
268
+ <input type='hidden' name='org.apache.myfaces.tobago.webapp.Secret' id='org.apache.myfaces.tobago.webapp.Secret' value='SLrPlxqLEaR/oYFLSu4wgg=='>
269
+ <tobago-in id='page:input' class='tobago-margin-bottom'>
270
+ <input type='text' name='page:input' id='page:input::field' class='tobago-in form-control' value='Alice'>
271
+ <tobago-behavior event='change' client-id='page:input' field-id='page:input::field' execute='page:input' render='page:output'></tobago-behavior>
272
+ </tobago-in>
273
+ <div id='page:output' class='tobago-margin-bottom'>
274
+ <tobago-out class='form-control-plaintext'></tobago-out>
275
+ </div>
276
+ <div class='tobago-page-menuStore'></div>
277
+ <span id='page::jsf-state-container'>
278
+ <input type='hidden' name='jakarta.faces.ViewState' id='j_id__v_0:jakarta.faces.ViewState:1' value='RkExQ0Q1NTYzOTNCNzg0RjAwMDAwMDE4' autocomplete='off'>
279
+ <input type='hidden' name='jakarta.faces.RenderKitId' value='tobago'>
280
+ <input type='hidden' id='j_id__v_0:jakarta.faces.ClientWindow:1' name='jakarta.faces.ClientWindow' value='5m10kooxi'>
281
+ </span>
282
+ </form>
283
+ </tobago-page>`;
264
284
  (0, chai_1.expect)(mona_dish_1.DQ.querySelectorAll("#page\\:output tobago-out").textContent() === "").to.be.true;
265
285
  (0, chai_1.expect)(mona_dish_1.DQ.byId("j_id__v_0:jakarta.faces.ViewState:1").isAbsent()).to.be.false;
266
286
  (0, chai_1.expect)(mona_dish_1.DQ.byId("j_id__v_0:jakarta.faces.ClientWindow:1").isAbsent()).to.be.false;
@@ -269,7 +289,20 @@ var protocolPage = StandardInits_1.StandardInits.protocolPage;
269
289
  execute: "page:input",
270
290
  render: "page:output"
271
291
  });
272
- this.respond("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<partial-response id='j_id__v_0'>\n<changes>\n<update id='page:output'><![CDATA[\n<div id='page:output' class='tobago-margin-bottom'>\n<tobago-out class='form-control-plaintext'>Alice</tobago-out>\n</div>]]>\n</update>\n<update id='j_id__v_0:jakarta.faces.ViewState:1'><![CDATA[MDQwQzkxNkU0MTg0RTQxRjAwMDAwMDE3]]>\n</update>\n<update id='j_id__v_0:jakarta.faces.ClientWindow:1'><![CDATA[5m10kooxg]]>\n</update>\n</changes>\n</partial-response>");
292
+ this.respond(`<?xml version="1.0" encoding="UTF-8"?>
293
+ <partial-response id='j_id__v_0'>
294
+ <changes>
295
+ <update id='page:output'><![CDATA[
296
+ <div id='page:output' class='tobago-margin-bottom'>
297
+ <tobago-out class='form-control-plaintext'>Alice</tobago-out>
298
+ </div>]]>
299
+ </update>
300
+ <update id='j_id__v_0:jakarta.faces.ViewState:1'><![CDATA[MDQwQzkxNkU0MTg0RTQxRjAwMDAwMDE3]]>
301
+ </update>
302
+ <update id='j_id__v_0:jakarta.faces.ClientWindow:1'><![CDATA[5m10kooxg]]>
303
+ </update>
304
+ </changes>
305
+ </partial-response>`);
273
306
  (0, chai_1.expect)(mona_dish_1.DQ.querySelectorAll("#page\\:output tobago-out").textContent() === "Alice").to.be.true;
274
307
  (0, chai_1.expect)(mona_dish_1.DQ.byId("j_id__v_0:jakarta.faces.ViewState:1").isAbsent()).to.be.false;
275
308
  (0, chai_1.expect)(mona_dish_1.DQ.byId("j_id__v_0:jakarta.faces.ClientWindow:1").isAbsent()).to.be.false;
@@ -280,19 +313,19 @@ var protocolPage = StandardInits_1.StandardInits.protocolPage;
280
313
  mona_dish_1.DQ.byId("cmd_simple_resource").click();
281
314
  this.respond(XmlResponses_1.XmlResponses.SIMPLE_RESOURCE_RESPONSE);
282
315
  (0, chai_1.expect)(document.head.innerHTML.indexOf("../../../xhrCore/fixtures/addedViewHead1.js") != -1).to.be.true;
283
- mona_dish_1.DQ.byId(document.body).waitUntilDom(function () { return mona_dish_1.DQ.byId('resource_area_1').innerHTML === "true"; })
284
- .then(function () { return done(); })
316
+ mona_dish_1.DQ.byId(document.body).waitUntilDom(() => mona_dish_1.DQ.byId('resource_area_1').innerHTML === "true")
317
+ .then(() => done())
285
318
  .catch(done);
286
319
  });
287
320
  it("only single resources are allowed", function (done) {
288
321
  // we need to fake the response as well to see whether the server has loaded the addedViewHead code and has interpreted it
289
322
  //(window as any)["test"] = "booga";
290
- for (var cnt = 0; cnt < 10; cnt++) {
323
+ for (let cnt = 0; cnt < 10; cnt++) {
291
324
  mona_dish_1.DQ.byId("cmd_simple_resource").click();
292
325
  this.respond(XmlResponses_1.XmlResponses.MULTIPLE_RESOURCE_RESPONSE);
293
326
  }
294
327
  (0, chai_1.expect)(document.head.innerHTML.indexOf("../../../xhrCore/fixtures/addedViewHead2.js") != -1).to.be.true;
295
- var addedScriptsCnt = mona_dish_1.DomQuery.byId(document.head).querySelectorAll("script[src='../../../xhrCore/fixtures/addedViewHead2.js']").length;
328
+ let addedScriptsCnt = mona_dish_1.DomQuery.byId(document.head).querySelectorAll("script[src='../../../xhrCore/fixtures/addedViewHead2.js']").length;
296
329
  (0, chai_1.expect)(addedScriptsCnt).to.eq(1);
297
330
  addedScriptsCnt = mona_dish_1.DomQuery.byId(document.head).querySelectorAll("style[rel='../../../xhrCore/fixtures/addedViewHead2.css']").length;
298
331
  (0, chai_1.expect)(addedScriptsCnt).to.eq(1);
@@ -302,26 +335,308 @@ var protocolPage = StandardInits_1.StandardInits.protocolPage;
302
335
  it("must handle complex resource responses properly", function (done) {
303
336
  mona_dish_1.DQ.byId("cmd_complex_resource").click();
304
337
  this.respond(XmlResponses_1.XmlResponses.MULTIPLE_RESOURCE_RESPONSE);
305
- var headHTML = document.head.innerHTML;
338
+ let headHTML = document.head.innerHTML;
306
339
  (0, chai_1.expect)(headHTML.indexOf("../../../xhrCore/fixtures/addedViewHead2.js")).not.eq(-1);
307
340
  (0, chai_1.expect)(headHTML.indexOf("rel=\"../../../xhrCore/fixtures/addedViewHead2.css\"")).not.eq(-1);
308
- mona_dish_1.DQ.byId(document.body).waitUntilDom(function () { return mona_dish_1.DQ.byId('resource_area_2').innerHTML === "true2"; })
309
- .then(function () { return done(); })
341
+ mona_dish_1.DQ.byId(document.body).waitUntilDom(() => mona_dish_1.DQ.byId('resource_area_2').innerHTML === "true2")
342
+ .then(() => done())
310
343
  .catch(done);
311
344
  });
312
345
  it("embedded scripts must be evaled", function (done) {
313
346
  mona_dish_1.DQ.byId("cmd_complex_resource2").click();
314
347
  this.respond(XmlResponses_1.XmlResponses.EMBEDDED_SCRIPTS_RESOURCE_RESPONSE);
315
348
  // this.respond("debugger; document.getElementById('resource_area_1').innerHTML = 'true3'", {'Content-Type': 'text/javascript'});
316
- var headHTML = document.head.innerHTML;
349
+ let headHTML = document.head.innerHTML;
317
350
  (0, chai_1.expect)(headHTML.indexOf("../../../xhrCore/fixtures/addedViewHead3.js")).not.eq(-1);
318
- (0, chai_1.expect)(headHTML.indexOf("rel=\"../../../xhrCore/fixtures/addedViewHead2.css\"")).not.eq(-1);
319
- setTimeout(function () {
320
- var evalAreaHtml = mona_dish_1.DQ.byId('resource_area_1').innerHTML;
351
+ (0, chai_1.expect)(headHTML.indexOf("href=\"../../../xhrCore/fixtures/addedViewHead2.css\"")).not.eq(-1);
352
+ (0, chai_1.expect)((0, mona_dish_1.DQ$)("head link[rel='stylesheet'][href='../../../xhrCore/fixtures/addedViewHead2.css']").length).to.eq(1);
353
+ setTimeout(() => {
354
+ let evalAreaHtml = mona_dish_1.DQ.byId('resource_area_1').innerHTML;
355
+ //last one must be the last item, order must be preserved
356
+ (0, chai_1.expect)(evalAreaHtml).to.eq("booga");
357
+ done();
358
+ }, 800);
359
+ });
360
+ it("head replacement must work (https://issues.apache.org/jira/browse/MYFACES-4498 and TCK Issue 4345IT)", function (done) {
361
+ mona_dish_1.DQ.byId("cmd_complex_resource2").click();
362
+ this.respond(XmlResponses_1.XmlResponses.HEAD_REPLACE);
363
+ let headHTML = document.head.innerHTML;
364
+ //failing now, no elements in the html head after respond!!!
365
+ (0, chai_1.expect)(headHTML.indexOf("href=\"../../../xhrCore/fixtures/addedViewHead2.css\"")).not.eq(-1);
366
+ (0, chai_1.expect)((0, mona_dish_1.DQ$)("head link[rel='stylesheet'][href='../../../xhrCore/fixtures/addedViewHead2.css']").length).to.eq(1);
367
+ (0, chai_1.expect)(headHTML.indexOf("../../../xhrCore/fixtures/addedViewHead3.js")).not.eq(-1);
368
+ setTimeout(() => {
369
+ let evalAreaHtml = mona_dish_1.DQ.byId('resource_area_1').innerHTML;
321
370
  //last one must be the last item, order must be preserved
322
371
  (0, chai_1.expect)(evalAreaHtml).to.eq("booga");
323
372
  done();
324
373
  }, 800);
325
374
  });
375
+ it("complex head replacement must work", function (done) {
376
+ mona_dish_1.DQ.byId("cmd_complex_resource2").click();
377
+ this.respond(XmlResponses_1.XmlResponses.HEAD_REPLACE2);
378
+ let headHTML = document.head.innerHTML;
379
+ //failing now, no elements in the html head after respond!!!
380
+ (0, chai_1.expect)(headHTML.indexOf("href=\"../../../xhrCore/fixtures/addedViewHead2.css\"")).not.eq(-1);
381
+ (0, chai_1.expect)((0, mona_dish_1.DQ$)("head link[rel='stylesheet'][href='../../../xhrCore/fixtures/addedViewHead2.css']").length).to.eq(1);
382
+ let metas = (0, mona_dish_1.DQ$)("head meta");
383
+ (0, chai_1.expect)(metas.length).to.eq(5);
384
+ (0, chai_1.expect)(metas.get(0).attr("charSet").value == "UTF-8");
385
+ (0, chai_1.expect)(metas.get(4).attr("author").value == "Whoever");
386
+ (0, chai_1.expect)(headHTML.indexOf("../../../xhrCore/fixtures/addedViewHead3.js")).not.eq(-1);
387
+ setTimeout(() => {
388
+ let evalAreaHtml = mona_dish_1.DQ.byId('resource_area_1').innerHTML;
389
+ //last one must be the last item, order must be preserved
390
+ (0, chai_1.expect)(evalAreaHtml).to.eq("booga");
391
+ done();
392
+ }, 800);
393
+ });
394
+ const INNER_HTML_MULIT_VIEW = `
395
+ <div id="viewroot_1">
396
+ <form id="viewroot_1:form1">
397
+ <button type="submit" id="viewroot_1:submit_1"></button>
398
+ <input type="hidden" id="viewroot_1:form1:jakarta.faces.ViewState:1" name="jakarta.faces.ViewState" value="booga"></input>
399
+ </form>
400
+ <form id="viewroot_1:form2">
401
+ <button type="submit" id="viewroot_1:submit_2"></button>
402
+ </form>
403
+ </div>
404
+
405
+ <div id="viewroot_2">
406
+ <form id="viewroot_2:form1">
407
+ <button type="submit" id="viewroot_1:submit_2"></button>
408
+ </form>
409
+ </div>
410
+ `;
411
+ it("must handle multiple view roots", function (done) {
412
+ const RESPONSE_1 = `<?xml version="1.0" encoding="UTF-8"?>
413
+ <partial-response id='viewroot_1'>
414
+ <changes>
415
+ <update id='viewroot_1:jakarta.faces.ViewState:1'><![CDATA[updatedVST]]></update>
416
+ </changes>
417
+ </partial-response>`;
418
+ window.document.body.innerHTML = INNER_HTML_MULIT_VIEW;
419
+ faces.ajax.request(window.document.getElementById("viewroot_1:submit_1"), null, {
420
+ "javax.faces.behavior.event": "change",
421
+ execute: "submit_1",
422
+ render: "form1"
423
+ });
424
+ this.respond(RESPONSE_1);
425
+ (0, chai_1.expect)((0, mona_dish_1.DQ$)("#viewroot_1\\:form2 [name='jakarta.faces.ViewState']").isAbsent()).to.be.true;
426
+ (0, chai_1.expect)((0, mona_dish_1.DQ$)("#viewroot_1\\:form1 [name='jakarta.faces.ViewState']").isPresent()).to.be.true;
427
+ (0, chai_1.expect)((0, mona_dish_1.DQ$)("#viewroot_1\\:form1 [name='jakarta.faces.ViewState']").val).to.be.eq("updatedVST");
428
+ done();
429
+ });
430
+ it("must handle multiple view roots multi forms", function (done) {
431
+ const RESPONSE_1 = `<?xml version="1.0" encoding="UTF-8"?>
432
+ <partial-response id='viewroot_1'>
433
+ <changes>
434
+ <update id='viewroot_1:jakarta.faces.ViewState:1'><![CDATA[updatedVST]]></update>
435
+ </changes>
436
+ </partial-response>`;
437
+ window.document.body.innerHTML = INNER_HTML_MULIT_VIEW;
438
+ global["debug4"] = true;
439
+ faces.ajax.request(window.document.getElementById("viewroot_1:submit_1"), null, {
440
+ "javax.faces.behavior.event": "change",
441
+ execute: "submit_1",
442
+ render: "viewroot_1:form1 submit_2"
443
+ });
444
+ this.respond(RESPONSE_1);
445
+ (0, chai_1.expect)((0, mona_dish_1.DQ$)("#viewroot_1\\:form2 [name*='jakarta.faces.ViewState']").isPresent()).to.be.true;
446
+ (0, chai_1.expect)((0, mona_dish_1.DQ$)("#viewroot_1\\:form1 [name*='jakarta.faces.ViewState']").isPresent()).to.be.true;
447
+ (0, chai_1.expect)((0, mona_dish_1.DQ$)("#viewroot_2\\:form1\\:form1 [name*='jakarta.faces.ViewState']").isAbsent()).to.be.true;
448
+ (0, chai_1.expect)(faces.getViewState((0, mona_dish_1.DQ$)("#viewroot_1\\:form2").getAsElem(0).value).indexOf("jakarta.faces.ViewState=updatedVST") != -1).to.be.true;
449
+ (0, chai_1.expect)(faces.getViewState("viewroot_1:form1").indexOf("jakarta.faces.ViewState=updatedVST") != -1).to.be.true;
450
+ done();
451
+ });
452
+ it("must handle multiple view roots with ClientWindow ids", function (done) {
453
+ const RESPONSE_1 = `<?xml version="1.0" encoding="UTF-8"?>
454
+ <partial-response id='viewroot_1'>
455
+ <changes>
456
+ <update id='viewroot_1:jakarta.faces.ClientWindow:1'><![CDATA[updatedViewId]]></update>
457
+ </changes>
458
+ </partial-response>`;
459
+ window.document.body.innerHTML = INNER_HTML_MULIT_VIEW;
460
+ faces.ajax.request(window.document.getElementById("viewroot_1:submit_1"), null, {
461
+ "javax.faces.behavior.event": "change",
462
+ execute: "submit_1",
463
+ render: "viewroot_1:form1"
464
+ });
465
+ this.respond(RESPONSE_1);
466
+ (0, chai_1.expect)((0, mona_dish_1.DQ$)("#viewroot_1\\:form2 [name*='jakarta.faces.ClientWindow']").isAbsent()).to.be.true;
467
+ (0, chai_1.expect)((0, mona_dish_1.DQ$)("#viewroot_1\\:form1 [name*='jakarta.faces.ClientWindow']").isPresent()).to.be.true;
468
+ (0, chai_1.expect)((0, mona_dish_1.DQ$)("#viewroot_1\\:form1 [name*='jakarta.faces.ClientWindow']").val).to.be.eq("updatedViewId");
469
+ done();
470
+ });
471
+ it("must handle multiple view roots multi forms with ClientWindow ids", function (done) {
472
+ const RESPONSE_1 = `<?xml version="1.0" encoding="UTF-8"?>
473
+ <partial-response id='viewroot_1'>
474
+ <changes>
475
+ <update id='viewroot_1:jakarta.faces.ClientWindow:1'><![CDATA[updatedViewId]]></update>
476
+ </changes>
477
+ </partial-response>`;
478
+ window.document.body.innerHTML = INNER_HTML_MULIT_VIEW;
479
+ faces.ajax.request(window.document.getElementById("viewroot_1:submit_1"), null, {
480
+ "javax.faces.behavior.event": "change",
481
+ execute: "submit_1",
482
+ render: "viewroot_1:form1 :submit_2"
483
+ });
484
+ this.respond(RESPONSE_1);
485
+ (0, chai_1.expect)((0, mona_dish_1.DQ$)("#viewroot_1\\:form2 [name*='jakarta.faces.ClientWindow']").isPresent()).to.be.true;
486
+ (0, chai_1.expect)((0, mona_dish_1.DQ$)("#viewroot_1\\:form1 [name*='jakarta.faces.ClientWindow']").isPresent()).to.be.true;
487
+ (0, chai_1.expect)((0, mona_dish_1.DQ$)("#viewroot_2\\:form1\\:form1 [name*='jakarta.faces.ClientWindow']").isAbsent()).to.be.true;
488
+ (0, chai_1.expect)((0, mona_dish_1.DQ$)("#viewroot_1\\:form2 [name*='jakarta.faces.ClientWindow']").val).to.be.eq("updatedViewId");
489
+ (0, chai_1.expect)((0, mona_dish_1.DQ$)("#viewroot_1\\:form1 [name*='jakarta.faces.ClientWindow']").val).to.be.eq("updatedViewId");
490
+ done();
491
+ });
492
+ const TCK_790_MARKUP = `
493
+ <div id="panel1">
494
+ <form id="form1" name="form1" method="post"
495
+ action="booga"
496
+ ><input id="form1:button" name="form1:button" type="submit"
497
+ value="submit form1 via ajax">
498
+ <input type="hidden" name="jakarta.faces.ViewState"
499
+ id="viewroot_1:jakarta.faces.ViewState:1"
500
+ value="beforeUpdate">
501
+ </form>
502
+ </div>
503
+ <div id="panel2">
504
+ <form id="form2" name="form2" method="post" action="booga2"
505
+ ><a href="#" id="form2:link" name="form2:link"></a>
506
+ </form>
507
+ </div>
508
+ <div id="panel3">
509
+ <form id="form3" name="form3" method="post" action="booga3"
510
+ ><a href="#" id="form3:link" name="form3:link"></a>
511
+ </form>
512
+ </div>
513
+ `;
514
+ const TCK_790_NAV_MARKUP = `
515
+ <form id="form1x" name="form1" method="post"
516
+ action="booga"
517
+ ><input id="form1x:button" name="form1x:button" type="submit"
518
+ value="submit form1 via ajax">
519
+ <input type="hidden" name="jakarta.faces.ViewState"
520
+ id="viewroot_1:jakarta.faces.ViewState:1"
521
+ value="beforeUpdate">
522
+ </form>
523
+ `;
524
+ /**
525
+ * Similar to TCK 790
526
+ */
527
+ it("must handle a more complex replace with several forms and one issuing form and a viewstate and a viewroot id in response but viewroot is not present in page", function (done) {
528
+ document.body.innerHTML = TCK_790_MARKUP;
529
+ const RESPONSE_1 = `<partial-response id="viewroot_1">
530
+ <changes>
531
+ <update id="panel2"><![CDATA[
532
+ <div id="panel2">
533
+ after update
534
+ <form id="form2" name="form2" method="post" action="booga2"
535
+ ><a href="#" id="form2:link" name="form2:link"></a>
536
+ <input type="hidden" name="form2_SUBMIT" value="1"/></form>
537
+ </div>
538
+ ]]>
539
+ </update>
540
+ <update id="panel3"><![CDATA[
541
+ <div id="panel3">
542
+ after update
543
+ <form id="form3" name="form3" method="post" action="booga3"
544
+ ><a href="#" id="form3:link" name="form3:link"></a>
545
+ </form>
546
+ </div>
547
+ ]]>
548
+ </update>
549
+ <update id="viewroot_1:jakarta.faces.ViewState:1"><![CDATA[booga_after_update]]></update>
550
+ </changes>
551
+ </partial-response>`;
552
+ faces.ajax.request(window.document.getElementById("form1:button"), null, {
553
+ "javax.faces.behavior.event": "click",
554
+ execute: "form1",
555
+ render: "form2 form3"
556
+ });
557
+ this.respond(RESPONSE_1);
558
+ // all forms in execute and render must receive the latest viewstate
559
+ (0, chai_1.expect)((0, mona_dish_1.DQ$)("#form1 [name*='jakarta.faces.ViewState']").val).to.eq("booga_after_update");
560
+ (0, chai_1.expect)((0, mona_dish_1.DQ$)("#form2 [name*='jakarta.faces.ViewState']").val).to.eq("booga_after_update");
561
+ (0, chai_1.expect)((0, mona_dish_1.DQ$)("#form2 [name*='jakarta.faces.ViewState']").val).to.eq("booga_after_update");
562
+ done();
563
+ });
564
+ it("must handle a complex navigation response (TCK Spec790)", function (done) {
565
+ /*we start from a simple form which triggers a an internal navigation*/
566
+ document.body.innerHTML = TCK_790_NAV_MARKUP;
567
+ faces.ajax.request(window.document.getElementById("form1x:button"), null, {
568
+ "javax.faces.behavior.event": "click",
569
+ execute: "@form",
570
+ render: ":form1x:button"
571
+ });
572
+ //TODO xhr stubbing, to check if the viewId is prepended in render!
573
+ this.respond(`<?xml version="1.0" encoding="UTF-8"?>
574
+ <partial-response id="viewroot_1">
575
+ <changes>
576
+ <update id="jakarta.faces.ViewRoot"><![CDATA[<!DOCTYPE html>
577
+ <html xmlns="http://www.w3.org/1999/xhtml">
578
+ <head>
579
+ <title>Spec 790</title>
580
+ <script src="/jakarta.faces.resource/faces.js.xhtml?ln=jakarta.faces;stage=Development"></script>
581
+ </head>
582
+ <body>
583
+ <div id="panel1">
584
+ <form id="form1" name="form1" method="post"
585
+ action="booga"
586
+ ><input id="form1:button" name="form1:button" type="submit"
587
+ value="submit form1 via ajax">
588
+ </form>
589
+ </div>
590
+ <div id="panel2">
591
+ after update
592
+ <form id="form2" name="form2" method="post" action="booga2"
593
+ ><a href="#" id="form2:link" name="form2:link"></a>
594
+ <input type="hidden" name="form2_SUBMIT" value="1"/></form>
595
+ </div>
596
+ <div id="panel3">
597
+ after update
598
+ <form id="form3" name="form3" method="post" action="booga3"
599
+ ><a href="#" id="form3:link" name="form3:link"></a>
600
+ </form>
601
+ </div>
602
+ </body>
603
+ </html>
604
+ ]]>
605
+ </update>
606
+ <update id="viewroot_1:jakarta.faces.ViewState:1"><![CDATA[booga_after_update]]></update>
607
+ </changes>
608
+ </partial-response>
609
+ `);
610
+ (0, chai_1.expect)((0, mona_dish_1.DQ$)("#form1 [name*='jakarta.faces.ViewState']").val).to.eq("booga_after_update");
611
+ (0, chai_1.expect)((0, mona_dish_1.DQ$)("#form2 [name*='jakarta.faces.ViewState']").val).to.eq("booga_after_update");
612
+ (0, chai_1.expect)((0, mona_dish_1.DQ$)("#form3 [name*='jakarta.faces.ViewState']").val).to.eq("booga_after_update");
613
+ (0, chai_1.expect)((0, mona_dish_1.DQ$)("#form1 [name*='jakarta.faces.ViewState']").id.value.indexOf("viewroot_1:jakarta.faces.ViewState:0") === 0).to.be.true;
614
+ (0, chai_1.expect)((0, mona_dish_1.DQ$)("#form2 [name*='jakarta.faces.ViewState']").id.value.indexOf("viewroot_1:jakarta.faces.ViewState:1") === 0).to.be.true;
615
+ (0, chai_1.expect)((0, mona_dish_1.DQ$)("#form3 [name*='jakarta.faces.ViewState']").id.value.indexOf("viewroot_1:jakarta.faces.ViewState:2") === 0).to.be.true;
616
+ done();
617
+ });
618
+ it('must handle a ViewExpired Error correctly, and only once in a listener', function (done) {
619
+ document.body.innerHTML = TCK_790_NAV_MARKUP;
620
+ let errorCalled = 0;
621
+ faces.ajax.addOnError((error) => {
622
+ (0, chai_1.expect)(error.errorName).to.eq("jakarta.faces.application.ViewExpiredException");
623
+ (0, chai_1.expect)(error.errorMessage).to.eq("serverError: View \"/testhmtl.xhtml\" could not be restored.");
624
+ (0, chai_1.expect)(error.source.id).to.eq("form1x:button");
625
+ errorCalled++;
626
+ });
627
+ faces.ajax.request(window.document.getElementById("form1x:button"), null, {
628
+ "javax.faces.behavior.event": "click",
629
+ execute: "@form",
630
+ render: ":form1x:button"
631
+ });
632
+ this.respond(`<?xml version="1.0" encoding="UTF-8"?>
633
+ <partial-response><error>
634
+ <error-name>jakarta.faces.application.ViewExpiredException</error-name>
635
+ <error-message><![CDATA[View "/testhmtl.xhtml" could not be restored.]]></error-message>
636
+ </error>
637
+ </partial-response>`);
638
+ (0, chai_1.expect)(errorCalled).to.eq(1);
639
+ done();
640
+ });
326
641
  });
327
642
  //# sourceMappingURL=ResponseTest.spec.js.map