WICKET-5039 Manual invocation of FunctionsExecutor#notify() is broken

Project: http://git-wip-us.apache.org/repos/asf/wicket/repo
Commit: http://git-wip-us.apache.org/repos/asf/wicket/commit/498f445c
Tree: http://git-wip-us.apache.org/repos/asf/wicket/tree/498f445c
Diff: http://git-wip-us.apache.org/repos/asf/wicket/diff/498f445c

Branch: refs/heads/master
Commit: 498f445c8edf143bec2b311c76d1939f406841fa
Parents: 635ced5
Author: Martin Tzvetanov Grigorov <[email protected]>
Authored: Thu Feb 21 15:58:03 2013 +0200
Committer: Martin Tzvetanov Grigorov <[email protected]>
Committed: Thu Feb 21 15:58:03 2013 +0200

----------------------------------------------------------------------
 .../wicket/ajax/res/js/wicket-ajax-jquery.js       |    6 +++++-
 wicket-core/src/test/js/ajax.js                    |    2 +-
 wicket-core/src/test/js/data/ajax/evaluationId.xml |    2 +-
 .../js/data/ajax/evaluationIdentifierAndCodeId.xml |    2 +-
 4 files changed, 8 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/wicket/blob/498f445c/wicket-core/src/main/java/org/apache/wicket/ajax/res/js/wicket-ajax-jquery.js
----------------------------------------------------------------------
diff --git 
a/wicket-core/src/main/java/org/apache/wicket/ajax/res/js/wicket-ajax-jquery.js 
b/wicket-core/src/main/java/org/apache/wicket/ajax/res/js/wicket-ajax-jquery.js
index 84b9f96..664c48f 100644
--- 
a/wicket-core/src/main/java/org/apache/wicket/ajax/res/js/wicket-ajax-jquery.js
+++ 
b/wicket-core/src/main/java/org/apache/wicket/ajax/res/js/wicket-ajax-jquery.js
@@ -1029,6 +1029,10 @@
                 * @param node {XmlElement} - the <[priority-]evaluate> element 
with the script to evaluate
                 */
                processEvaluation: function (context, node) {
+
+                       // used to match evaluation scripts which manually call 
FunctionsExecuter's notify() when ready
+                       var scriptWithIdentifierR = new 
RegExp("^\\(function\\(\\)\\{([a-zA-Z_][a-zA-Z0-9_]*)\\|((.|\\n)*)?\\}\\)\\(\\);$");
+
                        context.steps.push(function (notify) {
                                // get the javascript body
                                var text = jQuery(node).text();
@@ -1042,7 +1046,7 @@
                                // test if the javascript is in form of 
identifier|code
                                // if it is, we allow for letting the 
javascript decide when the rest of processing will continue
                                // by invoking identifier();
-                               var res = text.match(new 
RegExp("^([a-z|A-Z_][a-z|A-Z|0-9_]*)\\|((.|\\n)*)$"));
+                               var res = text.match(scriptWithIdentifierR);
 
                                if (res !== null) {
                                        var f = jQuery.noop;

http://git-wip-us.apache.org/repos/asf/wicket/blob/498f445c/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 e49b5d6..fac63a4 100644
--- a/wicket-core/src/test/js/ajax.js
+++ b/wicket-core/src/test/js/ajax.js
@@ -100,7 +100,7 @@ jQuery(document).ready(function() {
                 */
                asyncTest('processEvaluation with identifier|code.', function 
() {
 
-                       expect(2);
+                       expect(3);
 
                        var attrs = {
                                u: 
'data/ajax/evaluationIdentifierAndCodeId.xml',

http://git-wip-us.apache.org/repos/asf/wicket/blob/498f445c/wicket-core/src/test/js/data/ajax/evaluationId.xml
----------------------------------------------------------------------
diff --git a/wicket-core/src/test/js/data/ajax/evaluationId.xml 
b/wicket-core/src/test/js/data/ajax/evaluationId.xml
index fb294d0..f95d077 100644
--- a/wicket-core/src/test/js/data/ajax/evaluationId.xml
+++ b/wicket-core/src/test/js/data/ajax/evaluationId.xml
@@ -15,4 +15,4 @@
    See the License for the specific language governing permissions and
    limitations under the License.
 -->
-<ajax-response><evaluate>start(); ok(true, 'Evaluation must be 
executed!');</evaluate></ajax-response>
\ No newline at end of file
+<ajax-response><evaluate>(function(){start(); ok(true, 'Evaluation must be 
executed!');})();</evaluate></ajax-response>
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/wicket/blob/498f445c/wicket-core/src/test/js/data/ajax/evaluationIdentifierAndCodeId.xml
----------------------------------------------------------------------
diff --git 
a/wicket-core/src/test/js/data/ajax/evaluationIdentifierAndCodeId.xml 
b/wicket-core/src/test/js/data/ajax/evaluationIdentifierAndCodeId.xml
index 7cb65d6..04698b2 100644
--- a/wicket-core/src/test/js/data/ajax/evaluationIdentifierAndCodeId.xml
+++ b/wicket-core/src/test/js/data/ajax/evaluationIdentifierAndCodeId.xml
@@ -15,4 +15,4 @@
    See the License for the specific language governing permissions and
    limitations under the License.
 -->
-<ajax-response><evaluate>ignored|start(); ok(true, 'Evaluation with identifier 
must be executed!'); arguments[0]();</evaluate></ajax-response>
\ No newline at end of file
+<ajax-response><evaluate>(function(){ignored|start(); ok(true, 'Evaluation 
with identifier must be executed!'); equal(typeof(ignored), 'function', 'The 
passed identifier must be a function'); 
arguments[0]();})();</evaluate></ajax-response>
\ No newline at end of file

Reply via email to