You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@wicket.apache.org by mg...@apache.org on 2017/05/31 22:09:38 UTC
[1/2] wicket git commit: WICKET-6376: allow non-http(s) uris in ajax
redirects
Repository: wicket
Updated Branches:
refs/heads/wicket-7.x 1e4527dad -> 837b6b147
WICKET-6376: allow non-http(s) uris in ajax redirects
Add JS unit tests
(cherry picked from commit 0491709c1ad9720f120ed7ecad21d205c8be5470)
Project: http://git-wip-us.apache.org/repos/asf/wicket/repo
Commit: http://git-wip-us.apache.org/repos/asf/wicket/commit/3c9985ec
Tree: http://git-wip-us.apache.org/repos/asf/wicket/tree/3c9985ec
Diff: http://git-wip-us.apache.org/repos/asf/wicket/diff/3c9985ec
Branch: refs/heads/wicket-7.x
Commit: 3c9985ec5c2ce7526de5fe75afb959ca8849719c
Parents: 1e4527d
Author: Martin Tzvetanov Grigorov <mg...@apache.org>
Authored: Thu Jun 1 00:04:11 2017 +0200
Committer: Martin Tzvetanov Grigorov <mg...@apache.org>
Committed: Thu Jun 1 00:07:05 2017 +0200
----------------------------------------------------------------------
wicket-core/src/test/js/ajax.js | 108 +++++++++++++++++++++++++++++++++++
1 file changed, 108 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/wicket/blob/3c9985ec/wicket-core/src/test/js/ajax.js
----------------------------------------------------------------------
diff --git a/wicket-core/src/test/js/ajax.js b/wicket-core/src/test/js/ajax.js
index b124290..def9477 100644
--- a/wicket-core/src/test/js/ajax.js
+++ b/wicket-core/src/test/js/ajax.js
@@ -1392,5 +1392,113 @@ jQuery(document).ready(function() {
target.off("event1");
});
+ asyncTest('processAjaxResponse, normal HTTP case.', function () {
+
+ expect(2);
+
+ var originalProcessAjaxResponse = Wicket.Ajax.Call.prototype.processAjaxResponse,
+ originalRedirect = Wicket.Ajax.redirect;
+
+ Wicket.Ajax.Call.prototype.processAjaxResponse = function(data, textStatus, jqXHR, context) {
+ var mockJqXHR = {
+ "readyState": 4,
+ getResponseHeader: function (headerName) {
+ if ('Ajax-Location' === headerName) {
+ Wicket.Ajax.Call.prototype.processAjaxResponse = originalProcessAjaxResponse;
+ return 'http://a.b.c';
+ }
+ return jqXHR.getResponseHeader(headerName);
+ }
+ };
+ originalProcessAjaxResponse.call(Wicket.Ajax.Call.prototype, data, textStatus, mockJqXHR, context);
+ };
+
+ Wicket.Ajax.redirect = function(location) {
+ Wicket.Ajax.Call.prototype.processAjaxResponse = originalProcessAjaxResponse;
+ Wicket.Ajax.redirect = originalRedirect;
+ start();
+ equal(location, 'http://a.b.c', 'Custom HTTP address is properly handled');
+ };
+
+
+ var attrs = {
+ u: 'data/ajax/componentId.xml',
+ c: 'componentId'
+ };
+
+ execute(attrs);
+ });
+
+ asyncTest('processAjaxResponse, chrome-extensions case.', function () {
+
+ expect(2);
+
+ var originalProcessAjaxResponse = Wicket.Ajax.Call.prototype.processAjaxResponse,
+ originalRedirect = Wicket.Ajax.redirect;
+
+ Wicket.Ajax.Call.prototype.processAjaxResponse = function(data, textStatus, jqXHR, context) {
+ var mockJqXHR = {
+ "readyState": 4,
+ getResponseHeader: function (headerName) {
+ if ('Ajax-Location' === headerName) {
+ Wicket.Ajax.Call.prototype.processAjaxResponse = originalProcessAjaxResponse;
+ return 'chrome-extensions://a.b.c';
+ }
+ return jqXHR.getResponseHeader(headerName);
+ }
+ };
+ originalProcessAjaxResponse.call(Wicket.Ajax.Call.prototype, data, textStatus, mockJqXHR, context);
+ };
+
+ Wicket.Ajax.redirect = function(location) {
+ Wicket.Ajax.Call.prototype.processAjaxResponse = originalProcessAjaxResponse;
+ Wicket.Ajax.redirect = originalRedirect;
+ start();
+ equal(location, 'chrome-extensions://a.b.c', 'Custom chrome-extensions address is properly handled');
+ };
+
+ var attrs = {
+ u: 'data/ajax/componentId.xml',
+ c: 'componentId'
+ };
+
+ execute(attrs);
+ });
+
+ asyncTest('processAjaxResponse, no scheme case.', function () {
+
+ expect(2);
+
+ var originalProcessAjaxResponse = Wicket.Ajax.Call.prototype.processAjaxResponse,
+ originalRedirect = Wicket.Ajax.redirect;
+
+ Wicket.Ajax.Call.prototype.processAjaxResponse = function(data, textStatus, jqXHR, context) {
+ var mockJqXHR = {
+ "readyState": 4,
+ getResponseHeader: function (headerName) {
+ if ('Ajax-Location' === headerName) {
+ Wicket.Ajax.Call.prototype.processAjaxResponse = originalProcessAjaxResponse;
+ return 'location-without-scheme';
+ }
+ return jqXHR.getResponseHeader(headerName);
+ }
+ };
+ originalProcessAjaxResponse.call(Wicket.Ajax.Call.prototype, data, textStatus, mockJqXHR, context);
+ };
+
+ Wicket.Ajax.redirect = function(location) {
+ Wicket.Ajax.Call.prototype.processAjaxResponse = originalProcessAjaxResponse;
+ Wicket.Ajax.redirect = originalRedirect;
+ start();
+ ok(location.indexOf('location-without-scheme') > 0, 'Custom address without scheme is properly handled');
+ };
+
+ var attrs = {
+ u: 'data/ajax/componentId.xml',
+ c: 'componentId'
+ };
+
+ execute(attrs);
+ });
}
});
[2/2] wicket git commit: WICKET-6376: allow non-http(s) uris in ajax
redirects
Posted by mg...@apache.org.
WICKET-6376: allow non-http(s) uris in ajax redirects
Remove debug leftover
(cherry picked from commit 260a483561e8d8470b0dc2dcd1dcdd66c788136d)
Project: http://git-wip-us.apache.org/repos/asf/wicket/repo
Commit: http://git-wip-us.apache.org/repos/asf/wicket/commit/837b6b14
Tree: http://git-wip-us.apache.org/repos/asf/wicket/tree/837b6b14
Diff: http://git-wip-us.apache.org/repos/asf/wicket/diff/837b6b14
Branch: refs/heads/wicket-7.x
Commit: 837b6b14711a4703521f7185e84764ae19afa9cf
Parents: 3c9985e
Author: Martin Tzvetanov Grigorov <mg...@apache.org>
Authored: Thu Jun 1 00:07:13 2017 +0200
Committer: Martin Tzvetanov Grigorov <mg...@apache.org>
Committed: Thu Jun 1 00:09:30 2017 +0200
----------------------------------------------------------------------
wicket-core/src/test/js/ajax.js | 3 ---
1 file changed, 3 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/wicket/blob/837b6b14/wicket-core/src/test/js/ajax.js
----------------------------------------------------------------------
diff --git a/wicket-core/src/test/js/ajax.js b/wicket-core/src/test/js/ajax.js
index def9477..71f9fce 100644
--- a/wicket-core/src/test/js/ajax.js
+++ b/wicket-core/src/test/js/ajax.js
@@ -1404,7 +1404,6 @@ jQuery(document).ready(function() {
"readyState": 4,
getResponseHeader: function (headerName) {
if ('Ajax-Location' === headerName) {
- Wicket.Ajax.Call.prototype.processAjaxResponse = originalProcessAjaxResponse;
return 'http://a.b.c';
}
return jqXHR.getResponseHeader(headerName);
@@ -1441,7 +1440,6 @@ jQuery(document).ready(function() {
"readyState": 4,
getResponseHeader: function (headerName) {
if ('Ajax-Location' === headerName) {
- Wicket.Ajax.Call.prototype.processAjaxResponse = originalProcessAjaxResponse;
return 'chrome-extensions://a.b.c';
}
return jqXHR.getResponseHeader(headerName);
@@ -1477,7 +1475,6 @@ jQuery(document).ready(function() {
"readyState": 4,
getResponseHeader: function (headerName) {
if ('Ajax-Location' === headerName) {
- Wicket.Ajax.Call.prototype.processAjaxResponse = originalProcessAjaxResponse;
return 'location-without-scheme';
}
return jqXHR.getResponseHeader(headerName);