From jvloothuis at codespeak.net Wed Jan 2 00:25:30 2008 From: jvloothuis at codespeak.net (jvloothuis at codespeak.net) Date: Wed, 2 Jan 2008 00:25:30 +0100 (CET) Subject: [KSS-checkins] r50246 - kukit/kss.base/branches/protocol-data-types/kss/base Message-ID: <20080101232530.B32ED1684E1@codespeak.net> Author: jvloothuis Date: Wed Jan 2 00:25:28 2008 New Revision: 50246 Modified: kukit/kss.base/branches/protocol-data-types/kss/base/commands.py Log: Ported support for global commands Changed the parameter types so that they have a specific `node` method. This is method used with a try except block in place of an instance type check (which makes the code more duck-typing aware). Modified: kukit/kss.base/branches/protocol-data-types/kss/base/commands.py ============================================================================== --- kukit/kss.base/branches/protocol-data-types/kss/base/commands.py (original) +++ kukit/kss.base/branches/protocol-data-types/kss/base/commands.py Wed Jan 2 00:25:28 2008 @@ -8,9 +8,10 @@ kss_response_footer = '' - kss_command_start = '' +kss_command_start_global = '' + kss_command_end = '' kss_param = '%(value)s' @@ -19,7 +20,8 @@ def __init__(self, value): self.value = value - def __str__(self): + def node(self): + '''Return the XML node representation of this object''' return '' % self.value.replace(']]>', ']]>') def __repr__(self): @@ -49,26 +51,32 @@ def render(self): output = [kss_response_header] for action, selector, options in self.commands: - try: - selector_type = selector.type - selector = selector.value - except AttributeError: - # It is probably a string or unicode object so we can - # let the client decide the default selector - selector_type = '' - - output.append(kss_command_start % dict( - selector=quoteattr(selector), - selector_type=quoteattr(selector_type), - action=quoteattr(action))) + if selector is None: + output.append(kss_command_start_global % dict( + action=quoteattr(action))) + else: + try: + selector_type = selector.type + selector = selector.value + except AttributeError: + # It is probably a string or unicode object so we + # can let the client decide the default selector + selector_type = '' + + output.append(kss_command_start % dict( + selector=quoteattr(selector), + selector_type=quoteattr(selector_type), + action=quoteattr(action))) for name, value in options.items(): - if isinstance(value, basestring): - value = escape(value) - else: - value = str(value) + try: + node = value.node() + except AttributeError: + # If it the value does not explicitly convert to a + # node make it a text node + node = escape(value) output.append(kss_param % dict( - name=quoteattr(name), value=value)) + name=quoteattr(name), value=node)) output.append(kss_command_end) output.append(kss_response_footer) return ''.join(output) From reebalazs at codespeak.net Wed Jan 2 22:14:39 2008 From: reebalazs at codespeak.net (reebalazs at codespeak.net) Date: Wed, 2 Jan 2008 22:14:39 +0100 (CET) Subject: [KSS-checkins] r50272 - in kukit/kukit.js/branch/ree-service-layer-and-refactoring: . tests Message-ID: <20080102211439.92477168508@codespeak.net> Author: reebalazs Date: Wed Jan 2 22:14:39 2008 New Revision: 50272 Modified: kukit/kukit.js/branch/ree-service-layer-and-refactoring/ (props changed) kukit/kukit.js/branch/ree-service-layer-and-refactoring/tests/test_interfaces.js Log: Fix typo Modified: kukit/kukit.js/branch/ree-service-layer-and-refactoring/tests/test_interfaces.js ============================================================================== --- kukit/kukit.js/branch/ree-service-layer-and-refactoring/tests/test_interfaces.js (original) +++ kukit/kukit.js/branch/ree-service-layer-and-refactoring/tests/test_interfaces.js Wed Jan 2 22:14:39 2008 @@ -383,7 +383,7 @@ iface.getAttribute('first').require({ preferredSources: ['corelib', 'extralib'], fallbackProvider: '++resource++one'}); - iface.getAttribute('seconf').require({ + iface.getAttribute('second').require({ preferredSources: ['corelib', 'extralib'], fallbackProvider: '++resource++two'}); iface.getAttribute('third').require({ From reebalazs at codespeak.net Fri Jan 4 16:07:32 2008 From: reebalazs at codespeak.net (reebalazs at codespeak.net) Date: Fri, 4 Jan 2008 16:07:32 +0100 (CET) Subject: [KSS-checkins] r50311 - kukit/kss.core/branch/finish-closures/docs Message-ID: <20080104150732.ABC00168513@codespeak.net> Author: reebalazs Date: Fri Jan 4 16:07:30 2008 New Revision: 50311 Added: kukit/kss.core/branch/finish-closures/docs/ - copied from r50168, kukit/kss.core/trunk/docs/ kukit/kss.core/branch/finish-closures/docs/HISTORY.txt - copied unchanged from r50168, kukit/kss.core/trunk/docs/HISTORY.txt kukit/kss.core/branch/finish-closures/docs/INSTALL.txt - copied unchanged from r50168, kukit/kss.core/trunk/docs/INSTALL.txt kukit/kss.core/branch/finish-closures/docs/LICENSE.GPL - copied unchanged from r50168, kukit/kss.core/trunk/docs/LICENSE.GPL kukit/kss.core/branch/finish-closures/docs/LICENSE.txt - copied unchanged from r50168, kukit/kss.core/trunk/docs/LICENSE.txt kukit/kss.core/branch/finish-closures/docs/TODO.txt - copied unchanged from r50168, kukit/kss.core/trunk/docs/TODO.txt kukit/kss.core/branch/finish-closures/docs/tutorial_part2.rst - copied unchanged from r50168, kukit/kss.core/trunk/docs/tutorial_part2.rst Log: (forgot) Add back docs where they belong, ported from trunk From reebalazs at codespeak.net Fri Jan 4 16:21:38 2008 From: reebalazs at codespeak.net (reebalazs at codespeak.net) Date: Fri, 4 Jan 2008 16:21:38 +0100 (CET) Subject: [KSS-checkins] r50312 - kukit/kss.demo/branch/finish-closures/kss/demo Message-ID: <20080104152138.0AF5F16850F@codespeak.net> Author: reebalazs Date: Fri Jan 4 16:21:38 2008 New Revision: 50312 Modified: kukit/kss.demo/branch/finish-closures/kss/demo/registry.py Log: Remove debug message that I forgot. Modified: kukit/kss.demo/branch/finish-closures/kss/demo/registry.py ============================================================================== --- kukit/kss.demo/branch/finish-closures/kss/demo/registry.py (original) +++ kukit/kss.demo/branch/finish-closures/kss/demo/registry.py Fri Jan 4 16:21:38 2008 @@ -141,8 +141,6 @@ """Add a demo collection to the registry. """ test_filenames = self._getSeleniumTestsFromPlugin(plugin) - # Sort filenames alphabetically - test_filenames.sort() for test_filename in test_filenames: self.registerSeleniumTestFile(test_filename) @@ -156,7 +154,6 @@ def registerSeleniumTestFile(self, test_filename): """Register a selenium test by absolute filename """ - print "-----", test_filename if test_filename in self.selenium_tests: raise Exception, 'The selenium test for %s has already been registered. Cannot add.' % (test_filename, ) self.selenium_tests.append(test_filename) From reebalazs at codespeak.net Fri Jan 4 17:49:09 2008 From: reebalazs at codespeak.net (reebalazs at codespeak.net) Date: Fri, 4 Jan 2008 17:49:09 +0100 (CET) Subject: [KSS-checkins] r50317 - kukit/kukit.js/branch/ree-1.4-markup-and-syntax-changes Message-ID: <20080104164909.A5F3616843F@codespeak.net> Author: reebalazs Date: Fri Jan 4 17:49:08 2008 New Revision: 50317 Added: kukit/kukit.js/branch/ree-1.4-markup-and-syntax-changes/ - copied from r50316, kukit/kukit.js/trunk/ Log: Branch off From reebalazs at codespeak.net Fri Jan 4 17:57:25 2008 From: reebalazs at codespeak.net (reebalazs at codespeak.net) Date: Fri, 4 Jan 2008 17:57:25 +0100 (CET) Subject: [KSS-checkins] r50319 - in kukit/kukit.js/branch/ree-1.4-markup-and-syntax-changes: . doc kukit Message-ID: <20080104165725.E70D4168446@codespeak.net> Author: reebalazs Date: Fri Jan 4 17:57:24 2008 New Revision: 50319 Modified: kukit/kukit.js/branch/ree-1.4-markup-and-syntax-changes/ (props changed) kukit/kukit.js/branch/ree-1.4-markup-and-syntax-changes/doc/HISTORY.txt kukit/kukit.js/branch/ree-1.4-markup-and-syntax-changes/kukit/forms.js kukit/kukit.js/branch/ree-1.4-markup-and-syntax-changes/kukit/kssparser.js kukit/kukit.js/branch/ree-1.4-markup-and-syntax-changes/kukit/oper.js kukit/kukit.js/branch/ree-1.4-markup-and-syntax-changes/kukit/providerreg.js kukit/kukit.js/branch/ree-1.4-markup-and-syntax-changes/kukit/resourcedata.js kukit/kukit.js/branch/ree-1.4-markup-and-syntax-changes/kukit/selectorreg.js Log: Refactor value provider evaluation, make 1 registry out of 3. Remove deprecated form(), currentForm() providers in normal parameters. (It would take some more code to make them working but since they are deprecated long ago, I just removed them.) Modified: kukit/kukit.js/branch/ree-1.4-markup-and-syntax-changes/doc/HISTORY.txt ============================================================================== --- kukit/kukit.js/branch/ree-1.4-markup-and-syntax-changes/doc/HISTORY.txt (original) +++ kukit/kukit.js/branch/ree-1.4-markup-and-syntax-changes/doc/HISTORY.txt Fri Jan 4 17:57:24 2008 @@ -6,6 +6,19 @@ - ... + - refactor the value provider registry to use + a single registry in place of 3. + This will enable to define value + providers that recieve non-string parameters + like a node selection. + + Remove previously deprecated form() and + currentForm() value providers from normal + action parameters (remark: they should + be used with kssSelector.) + They now give a parsing error. + [ree] + - Fix multiple selection form fields marshalling on Safari (fixes #22 in kssproject) Modified: kukit/kukit.js/branch/ree-1.4-markup-and-syntax-changes/kukit/forms.js ============================================================================== --- kukit/kukit.js/branch/ree-1.4-markup-and-syntax-changes/kukit/forms.js (original) +++ kukit/kukit.js/branch/ree-1.4-markup-and-syntax-changes/kukit/forms.js Fri Jan 4 17:57:24 2008 @@ -1,5 +1,5 @@ /* -* Copyright (c) 2005-2007 +* Copyright (c) 2005-2008 * Authors: KSS Project Contributors (see doc/CREDITS.txt) * * This program is free software; you can redistribute it and/or modify @@ -307,14 +307,14 @@ this.fieldUpdateRegistry = new _FieldUpdateRegistry(); -// Registry of the pprovider functions for kssSubmitForm - -fo.pproviderFormRegistry = new kukit.pr.ValueProviderRegistry(); - -// form, currentForm will provide identical functions to those -// in normal parameters -// except they return a tuple list, not a dictionary. +// +// form, currentForm will fetch an entire form for marshalling. // This is needed because duplications and order must be preserved. +// The returnType of them will be registered as "formquery". This +// represents a list of (key, value) tuples that need to be marshalled. +// This assures to preserve order of keys, which is important +// for multi-values. +// /* * @@ -335,7 +335,7 @@ return fo.getAllFormVars(locator, collector); } }; -fo.pproviderFormRegistry.register('form', _FormValueProvider); +kukit.pprovidersGlobalRegistry.register('form', _FormValueProvider, 'formquery'); /* * @@ -355,12 +355,7 @@ return fo.getAllFormVars(locator, collector); } }; -fo.pproviderFormRegistry.register('currentForm', _CurrentFormValueProvider); - -// If a string is given, that will look like a form lookup, -// ie. identical to form -fo.pproviderFormRegistry.register('', _FormValueProvider); - +kukit.pprovidersGlobalRegistry.register('currentForm', _CurrentFormValueProvider, 'formquery'); /* BBB. To be deprecated on 2008-06-15 */ Modified: kukit/kukit.js/branch/ree-1.4-markup-and-syntax-changes/kukit/kssparser.js ============================================================================== --- kukit/kukit.js/branch/ree-1.4-markup-and-syntax-changes/kukit/kssparser.js (original) +++ kukit/kukit.js/branch/ree-1.4-markup-and-syntax-changes/kukit/kssparser.js Fri Jan 4 17:57:24 2008 @@ -1,5 +1,5 @@ /* -* Copyright (c) 2005-2007 +* Copyright (c) 2005-2008 * Authors: KSS Project Contributors (see doc/CREDITS.txt) * * This program is free software; you can redistribute it and/or modify @@ -266,12 +266,6 @@ } kukit.kssp.Block.prototype.addActionParameter = function(action, key, value) { - var ppRegistries = { - '': kukit.pprovidersGlobalRegistry, - 'kssSelector': kukit.sr.pproviderSelRegistry, - 'kssSubmitForm': kukit.fo.pproviderFormRegistry - }; - // -: // default-: // @@ -282,22 +276,42 @@ // This will also set the value providers on the value // (from check). // - // Figure out which registry to use. - var registry = ppRegistries[key]; - if (typeof(registry) == 'undefined') { - // use default pproviders - registry = ppRegistries['']; - } - // try { // Check also sets the value provider on the value. - value.check(registry); + value.check(); } catch(e) { ;;; kukit.E = 'Error in value : ' + e + '.'; this.emitError(kukit.E); } +;;; // Check return type +;;; // strings are currently unwrapped and will have +;;; // returnType == undefined, so we check for that. +;;; var returnType = value.pprovider.returnType; +;;; if (key == 'kssSelector') { +;;; // for kssSelector, string or formquery expected +;;; if (returnType && returnType != 'string' && returnType != 'selection') { +;;; kukit.E = 'Expected string or a selection result and got [' + returnType; +;;; kukit.E += '] in the kss action parameter [kssSelector].'; +;;; this.emitError(kukit.E); +;;; } +;;; } else if (key == 'kssSubmitForm') { +;;; // for kssSelector, string or formquery expected +;;; if (returnType && returnType != 'string' && returnType != 'formquery') { +;;; kukit.E = 'Expected string or a formquery result and got [' + returnType; +;;; kukit.E += '] in the kss action parameter [kssSubmitForm].'; +;;; this.emitError(kukit.E); +;;; } +;;; } else { +;;; // for all other cases, string is expected +;;; if (returnType && returnType != 'string') { +;;; kukit.E = 'Expected string and got [' + returnType; +;;; kukit.E += '] in the action parameter [' + key + '].'; +;;; this.emitError(kukit.E); +;;; } +;;; } + // store the value action.parms[key] = value; -} +}; kukit.kssp.Block.prototype.addDeclaration = function(key, value) { // p.s. value is here a KssXxParm. In most cases we check and unwrap it. Modified: kukit/kukit.js/branch/ree-1.4-markup-and-syntax-changes/kukit/oper.js ============================================================================== --- kukit/kukit.js/branch/ree-1.4-markup-and-syntax-changes/kukit/oper.js (original) +++ kukit/kukit.js/branch/ree-1.4-markup-and-syntax-changes/kukit/oper.js Fri Jan 4 17:57:24 2008 @@ -204,18 +204,27 @@ }; kukit.op.Oper.prototype.executeServerAction = function(name) { -;;; for (key in this.kssParms) { -;;; if (key == 'kssUrl') { -;;; // Value will be evaluated. -;;; } else if (key == 'kssSubmitForm') { + for (key in this.kssParms) { + if (key == 'kssSubmitForm') { + // Value has been evaluated at this point. + var formQuery = this.kssParms[key]; + // If a string is returned: this is to support + // kssSubmitForm: "formname"; + // in this case this is evaluated as form("formname"). + if (typeof(formQuery) == 'string') { + var locator = new kukit.fo.NamedFormLocator(formQuery); + var collector = new kukit.ut.TupleCollector(); + formQuery = kukit.fo.getAllFormVars(locator, collector); + } +;;; } else if (key == 'kssUrl') { ;;; // Value will be evaluated. ;;; } else { ;;; kukit.E = 'Wrong parameter : [' + key + '] starts with "kss";'; ;;; kukit.E += ' normal parms (that do not start with kss)'; ;;; kukit.E += ' only are allowed in action-server keys.'; ;;; throw new Error(kukit.E); -;;; } -;;; } + } + } // oper will be accessible to some commands that execute in return var sa = new kukit.sa.ServerAction(name, this); }; Modified: kukit/kukit.js/branch/ree-1.4-markup-and-syntax-changes/kukit/providerreg.js ============================================================================== --- kukit/kukit.js/branch/ree-1.4-markup-and-syntax-changes/kukit/providerreg.js (original) +++ kukit/kukit.js/branch/ree-1.4-markup-and-syntax-changes/kukit/providerreg.js Fri Jan 4 17:57:24 2008 @@ -1,5 +1,5 @@ /* -* Copyright (c) 2005-2007 +* Copyright (c) 2005-2008 * Authors: KSS Project Contributors (see doc/CREDITS.txt) * * This program is free software; you can redistribute it and/or modify @@ -29,7 +29,7 @@ this.content = {}; }; -kukit.pr.ValueProviderRegistry.prototype.register = function(name, func) { +kukit.pr.ValueProviderRegistry.prototype.register = function(name, func, returnType) { if (typeof(func) == 'undefined') { ;;; kukit.E = 'func argument is mandatory when registering a parameter' ;;; kukit.E += ' provider [ValueProviderRegistry.register].'; @@ -43,6 +43,11 @@ ;;; return; ;;; } this.content[name] = func; + // Handle return type + // XXX Store it on the func's prototype. + // This is a temporary solution, the service-layer + // branch offers a proper way to do this. + func.prototype.returnType = returnType; }; kukit.pr.ValueProviderRegistry.prototype.exists = function(name) { @@ -165,43 +170,6 @@ kukit.pprovidersGlobalRegistry.register('currentFormVarFromKssAttr', kukit.pr.CurrentFormVarFromKssAttrPP); - -/* BBB. To be deprecated at 2007-08-15 */ -kukit.pr.FormPP = function() {}; -kukit.pr.FormPP.prototype = { - check: function(args) { -;;; if (args.length != 1) { -;;; throw new Error('form method needs 1 arguments [formname]'); -;;; } -;;; var msg = 'Deprecated the [form(formname)] parameter provider,'; -;;; msg += ' use [xxx-kssSubmitForm: form(formname)] instead !'; -;;; kukit.logWarning(msg); - }, - eval: function(args, node) { - return kukit.fo.getAllFormVars(new kukit.fo.NamedFormLocator(args[0]), - new kukit.ut.DictCollector()); - } -}; -kukit.pprovidersGlobalRegistry.register('form', kukit.pr.FormPP); - -/* BBB. To be deprecated at 2007-08-15 */ -kukit.pr.CurrentFormPP = function() {}; -kukit.pr.CurrentFormPP.prototype = { - check: function(args) { -;;; if (args.length != 0) { -;;; throw new Error('currentForm method needs no argument'); -;;; } -;;; var msg = 'Deprecated the [currentForm()] parameter provider,'; -;;; msg += ' use [xxx-kssSubmitForm: currentForm()] instead !'; -;;; kukit.logWarning(msg); - }, - eval: function(args, node) { - return kukit.fo.getAllFormVars(new kukit.fo.CurrentFormLocator(node), - new kukit.ut.DictCollector()); - } -}; -kukit.pprovidersGlobalRegistry.register('currentForm', kukit.pr.CurrentFormPP); - kukit.pr.NodeAttrPP = function() {}; kukit.pr.NodeAttrPP.prototype = { check: function(args) { Modified: kukit/kukit.js/branch/ree-1.4-markup-and-syntax-changes/kukit/resourcedata.js ============================================================================== --- kukit/kukit.js/branch/ree-1.4-markup-and-syntax-changes/kukit/resourcedata.js (original) +++ kukit/kukit.js/branch/ree-1.4-markup-and-syntax-changes/kukit/resourcedata.js Fri Jan 4 17:57:24 2008 @@ -1,5 +1,5 @@ /* -* Copyright (c) 2005-2007 +* Copyright (c) 2005-2008 * Authors: KSS Project Contributors (see doc/CREDITS.txt) * * This program is free software; you can redistribute it and/or modify @@ -154,9 +154,9 @@ kukit.rd.KssTextValue.prototype.isMethod = false; -kukit.rd.KssTextValue.prototype.check = function(registry) { +kukit.rd.KssTextValue.prototype.check = function() { // use the IdentityPP provider. - this.pprovider = new (registry.get(''))(); + this.pprovider = new (kukit.pprovidersGlobalRegistry.get(''))(); }; kukit.rd.KssTextValue.prototype.evaluate = @@ -179,22 +179,44 @@ kukit.rd.KssMethodValue.prototype.isMethod = true; -kukit.rd.KssMethodValue.prototype.check = function(registry) { +kukit.rd.KssMethodValue.prototype.check = function() { // Check syntax - var f = registry.get(this.methodName); + var f = kukit.pprovidersGlobalRegistry.get(this.methodName); this.pprovider = new f(); +;;; //Check the provider first. +;;; this.pprovider.check(this.args); + // After checking the provider, we check the args recursively. for(i=0; i < this.args.length; i++){ // XXX We treat text values separetly because // they are now currently wrapped as KssTextValue // (as they should). TODO var arg = this.args[i]; + // XXX this is a check for a MethodValue, since + // all text arguments are strings. -- this is fixed + // on the service-layer branch if(arg.check){ - // With the recursion we always use the global - // provider registry - arg.check(kukit.pprovidersGlobalRegistry); + arg.check(); +;;; // The page provider should have checked if the parameters +;;; // return the appropriate value type. If it has done +;;; // this check, it has set checkedArgTypes. +;;; // If a provider expects all strings +;;; // (like most value providers), it simply leaves this flag +;;; // intact, and we do the check here. +;;; if (! this.checkedArgTypes) { +;;; // We expect a string to each position. +;;; // By default, returnType is "string" so we also +;;; // check undefined. +;;; var returnType = arg.pprovider.returnType; +;;; if (returnType && returnType != 'string') { +;;; kukit.E = 'Expected string value and got [' + returnType; +;;; kukit.E += '] in argument #[' + (i + 1) + '] of provider ['; +;;; kukit.E += this.methodName + '].'; +;;; throw new Error(kukit.E); +;;; } +;;; } + } } -;;; this.pprovider.check(this.args); }; kukit.rd.KssMethodValue.prototype.evaluate = @@ -599,6 +621,17 @@ } }; +// The evaluation of string is handled specially +// in case of some parameter names. +// +// kssSelector string "foo" evaluates as css("foo") +// kssSubmitForm string "foo" evaluates as form("foo") +// +kukit.rd.Action.prototype.defaultStringHandling = { + 'kssSelector': 'css', + 'kssSubmitForm': 'form' +}; + kukit.rd.Action.prototype.makeActionOper = function(oper) { // Fill the completed action parms, based on the node // The kssXxx parms, reserved for the action, are @@ -610,16 +643,30 @@ if (typeof(oper.defaultParameters) == 'undefined') { oper.defaultParameters = {}; } + // Evaluate all parameters. for (var key in this.parms) { - var kssvalue = this.parms[key]; + // Evaluate the value of the parameter. + var value = this.parms[key].evaluate(oper.node, + oper.defaultParameters); + // Final handling of special cases. + // This is needed in case we have a string, and we + // look up the provider we need from the defaultStringHandling table. + var providerName = this.defaultStringHandling[key]; + if (providerName && typeof(value) == 'string') { + // Use the value provider. This means the string is + // a shortcut and this provider is applied. + var providerClass = kukit.pprovidersGlobalRegistry.get(providerName); + var provider = new providerClass(); + // check is not needed now... we evaluate it right away + value = provider.eval([value], oper.node, oper.defaultParameters); + } + // Store it, depending if it's a kss or normal parameter. if (key.match(/^kss/)) { // kssXxx parms are separated to kssParms. - kssParms[key] = kssvalue.evaluate(oper.node, - oper.defaultParameters); + kssParms[key] = value; } else { // evaluate the method parms into parms - parms[key] = kssvalue.evaluate(oper.node, - oper.defaultParameters); + parms[key] = value; } } var anOper = oper.clone({ Modified: kukit/kukit.js/branch/ree-1.4-markup-and-syntax-changes/kukit/selectorreg.js ============================================================================== --- kukit/kukit.js/branch/ree-1.4-markup-and-syntax-changes/kukit/selectorreg.js (original) +++ kukit/kukit.js/branch/ree-1.4-markup-and-syntax-changes/kukit/selectorreg.js Fri Jan 4 17:57:24 2008 @@ -1,5 +1,5 @@ /* -* Copyright (c) 2005-2007 +* Copyright (c) 2005-2008 * Authors: KSS Project Contributors (see doc/CREDITS.txt) * * This program is free software; you can redistribute it and/or modify @@ -19,11 +19,6 @@ kukit.sr = {}; -// Registry of the pprovider functions for selecting - -kukit.sr.pproviderSelRegistry = new kukit.pr.ValueProviderRegistry(); - - // this will provide an arbitrary selector, and is designed to // be used with the makeAnyPP factory function. kukit.sr.AnyPP = function() {}; @@ -43,8 +38,6 @@ } }; -kukit.sr.pproviderSelRegistry.register('', kukit.sr.AnyPP); - kukit.sr.makeAnyPP = function(selector_type) { var pp = function () {}; pp.prototype.eval = kukit.sr.AnyPP.prototype.eval; @@ -72,7 +65,7 @@ return nodes; } }; -kukit.sr.pproviderSelRegistry.register('passnode', kukit.sr.PassnodePP); +kukit.pprovidersGlobalRegistry.register('passnode', kukit.sr.PassnodePP, 'selection'); /* @@ -103,7 +96,8 @@ this.mapping[name] = func; // Also register the selector param provider var pp = kukit.sr.makeAnyPP(name); - kukit.sr.pproviderSelRegistry.register(name, pp); + // register them with returnType = 'nodes' + kukit.pprovidersGlobalRegistry.register(name, pp, 'selection'); }; kukit.sr.SelectorTypeRegistry.prototype.get = function(name) { From reebalazs at codespeak.net Fri Jan 4 17:57:29 2008 From: reebalazs at codespeak.net (reebalazs at codespeak.net) Date: Fri, 4 Jan 2008 17:57:29 +0100 (CET) Subject: [KSS-checkins] r50320 - in kukit/kukit.js/branch/ree-1.4-markup-and-syntax-changes: . kukit tests Message-ID: <20080104165729.9CC3B16844E@codespeak.net> Author: reebalazs Date: Fri Jan 4 17:57:28 2008 New Revision: 50320 Modified: kukit/kukit.js/branch/ree-1.4-markup-and-syntax-changes/ (props changed) kukit/kukit.js/branch/ree-1.4-markup-and-syntax-changes/kukit/providerreg.js kukit/kukit.js/branch/ree-1.4-markup-and-syntax-changes/kukit/resourcedata.js kukit/kukit.js/branch/ree-1.4-markup-and-syntax-changes/tests/runtests.js kukit/kukit.js/branch/ree-1.4-markup-and-syntax-changes/tests/test_kssparser.js Log: Add ecma tests to check handling of value provider return types Modified: kukit/kukit.js/branch/ree-1.4-markup-and-syntax-changes/kukit/providerreg.js ============================================================================== --- kukit/kukit.js/branch/ree-1.4-markup-and-syntax-changes/kukit/providerreg.js (original) +++ kukit/kukit.js/branch/ree-1.4-markup-and-syntax-changes/kukit/providerreg.js Fri Jan 4 17:57:28 2008 @@ -178,15 +178,15 @@ ;;; kukit.E += ' [recurseParents]).'; ;;; throw new Error(kukit.E); ;;; } -;;; if (args[0].toLowerCase() == 'style') { + }, + eval: function(args, node) { + var argname = args[0]; +;;; if (argname.toLowerCase() == 'style') { ;;; throw new Error('nodeAttr method does not accept [style] as attrname.'); ;;; } -;;; if (args[0].match(/[ ]/)) { +;;; if (argname.match(/[ ]/)) { ;;; throw new Error('attrname parameter in nodeAttr method cannot contain space.'); ;;; } - }, - eval: function(args, node) { - var argname = args[0]; var recurseParents = false; if (args.length == 2) { recurseParents = args[1]; Modified: kukit/kukit.js/branch/ree-1.4-markup-and-syntax-changes/kukit/resourcedata.js ============================================================================== --- kukit/kukit.js/branch/ree-1.4-markup-and-syntax-changes/kukit/resourcedata.js (original) +++ kukit/kukit.js/branch/ree-1.4-markup-and-syntax-changes/kukit/resourcedata.js Fri Jan 4 17:57:28 2008 @@ -186,7 +186,7 @@ ;;; //Check the provider first. ;;; this.pprovider.check(this.args); // After checking the provider, we check the args recursively. - for(i=0; i < this.args.length; i++){ + for(var i=0; i < this.args.length; i++){ // XXX We treat text values separetly because // they are now currently wrapped as KssTextValue // (as they should). TODO Modified: kukit/kukit.js/branch/ree-1.4-markup-and-syntax-changes/tests/runtests.js ============================================================================== --- kukit/kukit.js/branch/ree-1.4-markup-and-syntax-changes/tests/runtests.js (original) +++ kukit/kukit.js/branch/ree-1.4-markup-and-syntax-changes/tests/runtests.js Fri Jan 4 17:57:28 2008 @@ -22,6 +22,7 @@ testsuite.registerTest(kukit.TokenizerTestCase); testsuite.registerTest(kukit.KssParserTestCase); testsuite.registerTest(kukit.KssParserSelectorsTestCase); + testsuite.registerTest(kukit.KssParserValueProvidersCheckTestCase); testsuite.registerTest(kukit.KssParserSelectorTestCase); testsuite.runSuite(); }; Modified: kukit/kukit.js/branch/ree-1.4-markup-and-syntax-changes/tests/test_kssparser.js ============================================================================== --- kukit/kukit.js/branch/ree-1.4-markup-and-syntax-changes/tests/test_kssparser.js (original) +++ kukit/kukit.js/branch/ree-1.4-markup-and-syntax-changes/tests/test_kssparser.js Fri Jan 4 17:57:28 2008 @@ -226,7 +226,7 @@ this.assertParsingError(kukit.kssp.PropValue, cursor, null, true, 'Wrong value : unallowed characters after the property', 17); }; - + this.testEventValueSimple = function() { // Parsing event value var txt= "b"; @@ -813,6 +813,245 @@ kukit.KssParserTestCase.prototype = new kukit.KssParserTestCaseBase; +kukit.KssParserValueProvidersCheckTestCase = function() { + this.name = 'kukit.KssParserValueProvidersCheckTestCase'; + // Different tests to see if the syntax type check of + // the value providers is working correctly. + // At the moment we have the following return value types: + // string, selection, formquery + // We do not check the actual evaluation here, as we + // have no DOM at hand. + // + // This testcase is added in DEVELOPMENT MODE ONLY. + + this.testNormalProviderAcceptsString = function() { + // normal providers does accept string + // + // This test can only run in development mode, pass otherwise. + if (! kukit.isDevelMode) {return;} + // + var txt= "nodeAttr('id')"; + var cursor = new kukit.tk.Cursor(txt); + var parser = new kukit.kssp.PropValue(cursor, null, true); + var value = parser.value; + value.check(); + }; + + this.testNormalProviderRejectsSelection = function() { + // normal providers does not accept selection + // + // This test can only run in development mode, pass otherwise. + if (! kukit.isDevelMode) {return;} + // + var txt= "nodeAttr('id')"; + var txt= "nodeAttr(htmlid('id'))"; + var cursor = new kukit.tk.Cursor(txt); + var parser = new kukit.kssp.PropValue(cursor, null, true); + var value = parser.value; + this.assertThrows(function() { + value.check(); + }, + Error); + }; + + this.testNormalProviderRejectsSelectionFullRule = function() { + // normal providers do not accept selection + // full rule + // + // This test can only run in development mode, pass otherwise. + if (! kukit.isDevelMode) {return;} + // + var txt= "nodeAttr('id')"; + var txt= "#id:click {\n" + + " action-client: log;\n" + + " log-message: nodeAttr(htmlid('id'));\n" + + "}\n" + var cursor = new kukit.tk.Cursor(txt); + this.assertParsingError(kukit.kssp.Document, cursor, null, true, + // XXX This error message will be fixed in service-layer branch + 'Error in value : Error: Expected string value and got [selection] in argument #[1] of provider [nodeAttr].., at row 1, column 11'); + }; + + this.testNormalProviderRejectsFormQuery = function() { + // normal providers do not accept form query + // + // This test can only run in development mode, pass otherwise. + if (! kukit.isDevelMode) {return;} + // + var txt= "nodeAttr('id')"; + var txt= "nodeAttr(form('name'))"; + var cursor = new kukit.tk.Cursor(txt); + var parser = new kukit.kssp.PropValue(cursor, null, true); + var value = parser.value; + this.assertThrows(function() { + value.check(); + }, + Error); + }; + + this.testNormalProviderRejectsFormQueryFullRule = function() { + // normal providers do not accept form query + // full rule + // + // This test can only run in development mode, pass otherwise. + if (! kukit.isDevelMode) {return;} + // + var txt= "nodeAttr('id')"; + var txt= "#id:click {\n" + + " action-client: log;\n" + + " log-message: nodeAttr(form('name'));\n" + + "}\n" + var cursor = new kukit.tk.Cursor(txt); + this.assertParsingError(kukit.kssp.Document, cursor, null, true, + // XXX This error message will be fixed in service-layer branch + 'Error in value : Error: Expected string value and got [formquery] in argument #[1] of provider [nodeAttr].., at row 1, column 11'); + }; + + this.testNormalProviderRejectsSelector = function() { + // normal parameters do not accept selector + // + // This test can only run in development mode, pass otherwise. + if (! kukit.isDevelMode) {return;} + // + var txt= "nodeAttr('id')"; + var txt= "#id:click {\n" + + " action-client: log;\n" + + " log-message: htmlid('id');\n" + + "}\n" + var cursor = new kukit.tk.Cursor(txt); + this.assertParsingError(kukit.kssp.Document, cursor, null, true, + // XXX This error message will be fixed in service-layer branch + 'Expected string and got [selection] in the action parameter [message]., at row 1, column 11'); + }; + + this.testNormalProviderRejectsFormQuery = function() { + // normal parameters do not accept form query + // + // This test can only run in development mode, pass otherwise. + if (! kukit.isDevelMode) {return;} + // + var txt= "nodeAttr('id')"; + var txt= "#id:click {\n" + + " action-client: log;\n" + + " log-message: form('name');\n" + + "}\n" + var cursor = new kukit.tk.Cursor(txt); + this.assertParsingError(kukit.kssp.Document, cursor, null, true, + // XXX This error message will be fixed in service-layer branch + 'Expected string and got [formquery] in the action parameter [message]., at row 1, column 11'); + }; + + this.testKssSelectorAcceptsSelector = function() { + // kssSelector accepts selector + // + // This test can only run in development mode, pass otherwise. + if (! kukit.isDevelMode) {return;} + // + var txt= "nodeAttr('id')"; + var txt= "#id:click {\n" + + " action-client: setAttribute;\n" + + " setAttribute-kssSelector: htmlid('id');\n" + + " setAttribute-name: name;\n" + + " setAttribute-value: value;\n" + + "}\n" + var cursor = new kukit.tk.Cursor(txt); + var parser = new kukit.kssp.Document(cursor, null, true); + this.assertEquals(parser.finished, true); + }; + + this.testKssSelectorAcceptsString = function() { + // kssSelector accepts string + // (it will evaluate as css(xxx), but we can't check that without a dom) + // + // This test can only run in development mode, pass otherwise. + if (! kukit.isDevelMode) {return;} + // + var txt= "nodeAttr('id')"; + var txt= "#id:click {\n" + + " action-client: setAttribute;\n" + + " setAttribute-kssSelector: htmlid('id');\n" + + " setAttribute-name: name;\n" + + " setAttribute-value: value;\n" + + "}\n" + var cursor = new kukit.tk.Cursor(txt); + var parser = new kukit.kssp.Document(cursor, null, true); + this.assertEquals(parser.finished, true); + }; + + this.testKssSelectorRejectsFormQuery = function() { + // kssSelector rejects form query + // + // This test can only run in development mode, pass otherwise. + if (! kukit.isDevelMode) {return;} + // + var txt= "nodeAttr('id')"; + var txt= "#id:click {\n" + + " action-client: setAttribute;\n" + + " setAttribute-kssSelector: form('name');\n" + + " setAttribute-name: name;\n" + + " setAttribute-value: value;\n" + + "}\n" + var cursor = new kukit.tk.Cursor(txt); + this.assertParsingError(kukit.kssp.Document, cursor, null, true, + // XXX This error message will be fixed in service-layer branch + 'Expected string or a selection result and got [formquery] in the kss action parameter [kssSelector]., at row 1, column 11'); + }; + + this.testKssSubmitFormAcceptsFormQuery = function() { + // kssSubmitForm accepts form query + // + // This test can only run in development mode, pass otherwise. + if (! kukit.isDevelMode) {return;} + // + var txt= "nodeAttr('id')"; + var txt= "#id:click {\n" + + " action-server: doIt;\n" + + " doIt-kssSubmitForm: form('name');\n" + + "}\n" + var cursor = new kukit.tk.Cursor(txt); + var parser = new kukit.kssp.Document(cursor, null, true); + this.assertEquals(parser.finished, true); + }; + + this.testKssSubmitFormAcceptsString = function() { + // kssSubmitForm accepts string + // (it will evaluate as form(xxx), but we can't check that without a dom) + // + // This test can only run in development mode, pass otherwise. + if (! kukit.isDevelMode) {return;} + // + var txt= "nodeAttr('id')"; + var txt= "#id:click {\n" + + " action-server: doIt;\n" + + " doIt-kssSubmitForm: 'name';\n" + + "}\n" + var cursor = new kukit.tk.Cursor(txt); + var parser = new kukit.kssp.Document(cursor, null, true); + this.assertEquals(parser.finished, true); + }; + + this.testKssSubmitFormRejectsSelection = function() { + // kssSubmitForm rejects selection + // + // This test can only run in development mode, pass otherwise. + if (! kukit.isDevelMode) {return;} + // + var txt= "nodeAttr('id')"; + var txt= "#id:click {\n" + + " action-server: doIt;\n" + + " doIt-kssSubmitForm: htmlid('id');\n" + + "}\n" + var cursor = new kukit.tk.Cursor(txt); + this.assertParsingError(kukit.kssp.Document, cursor, null, true, + // XXX This error message will be fixed in service-layer branch + 'Expected string or a formquery result and got [selection] in the kss action parameter [kssSubmitForm]., at row 1, column 11'); + }; + +}; + +kukit.KssParserValueProvidersCheckTestCase.prototype = new kukit.KssParserTestCaseBase; + + kukit.KssParserSelectorTestCase = function() { this.name = 'kukit.KssParserSelectorTestCase'; @@ -1115,6 +1354,7 @@ this.assertParsingError(kukit.kssp.KssSelector, cursor, null, true, 'Error : undefined namespace or event in [dnd-drog].'); } + }; kukit.KssParserSelectorTestCase.prototype = new kukit.KssParserTestCaseBase; @@ -1476,6 +1716,8 @@ if (typeof(testcase_registry) != 'undefined') { testcase_registry.registerTestCase(kukit.KssParserTestCase, 'kukit.KssParserTestCase'); + testcase_registry.registerTestCase(kukit.KssParserValueProvidersCheckTestCase, + 'kukit.KssParserValueProvidersCheckTestCase'); testcase_registry.registerTestCase(kukit.KssParserSelectorTestCase, 'kukit.KssParserSelectorTestCase'); testcase_registry.registerTestCase(kukit.KssParserSelectorsTestCase, From reebalazs at codespeak.net Fri Jan 4 17:57:32 2008 From: reebalazs at codespeak.net (reebalazs at codespeak.net) Date: Fri, 4 Jan 2008 17:57:32 +0100 (CET) Subject: [KSS-checkins] r50321 - in kukit/kukit.js/branch/ree-1.4-markup-and-syntax-changes: . kukit Message-ID: <20080104165732.1FC61168449@codespeak.net> Author: reebalazs Date: Fri Jan 4 17:57:31 2008 New Revision: 50321 Modified: kukit/kukit.js/branch/ree-1.4-markup-and-syntax-changes/ (props changed) kukit/kukit.js/branch/ree-1.4-markup-and-syntax-changes/kukit/providerreg.js Log: Relocate a check that needs to be in eval now, because it needs to check the evaluated value. Modified: kukit/kukit.js/branch/ree-1.4-markup-and-syntax-changes/kukit/providerreg.js ============================================================================== --- kukit/kukit.js/branch/ree-1.4-markup-and-syntax-changes/kukit/providerreg.js (original) +++ kukit/kukit.js/branch/ree-1.4-markup-and-syntax-changes/kukit/providerreg.js Fri Jan 4 17:57:31 2008 @@ -207,15 +207,15 @@ ;;; kukit.E += ' [recurseParents]).'; ;;; throw new Error(kukit.E); ;;; } -;;; if (args[0].match(/[ -]/)) { -;;; kukit.E = 'attrname parameter in kssAttr method cannot contain'; -;;; kukit.E += ' dashes or spaces.'; -;;; throw new Error(kukit.E); -;;; } }, eval: function(args, node) { var argname = args[0]; var recurseParents = false; +;;; if (argname.match(/[ -]/)) { +;;; kukit.E = 'attrname parameter in kssAttr method cannot contain'; +;;; kukit.E += ' dashes or spaces.'; +;;; throw new Error(kukit.E); +;;; } if (args.length == 2) { recurseParents = args[1]; ;;; kukit.E = '2nd attribute of kssAttr must be a boolean.'; From reebalazs at codespeak.net Fri Jan 4 17:57:36 2008 From: reebalazs at codespeak.net (reebalazs at codespeak.net) Date: Fri, 4 Jan 2008 17:57:36 +0100 (CET) Subject: [KSS-checkins] r50322 - in kukit/kukit.js/branch/ree-1.4-markup-and-syntax-changes: . kukit Message-ID: <20080104165736.09743168449@codespeak.net> Author: reebalazs Date: Fri Jan 4 17:57:35 2008 New Revision: 50322 Modified: kukit/kukit.js/branch/ree-1.4-markup-and-syntax-changes/ (props changed) kukit/kukit.js/branch/ree-1.4-markup-and-syntax-changes/kukit/dom.js kukit/kukit.js/branch/ree-1.4-markup-and-syntax-changes/kukit/providerreg.js Log: Refactor the recursive attribute lookup. Add getKssValue provider. Modified: kukit/kukit.js/branch/ree-1.4-markup-and-syntax-changes/kukit/dom.js ============================================================================== --- kukit/kukit.js/branch/ree-1.4-markup-and-syntax-changes/kukit/dom.js (original) +++ kukit/kukit.js/branch/ree-1.4-markup-and-syntax-changes/kukit/dom.js Fri Jan 4 17:57:35 2008 @@ -227,27 +227,57 @@ var _kssAttrNamespace = 'kssattr'; +// the namespace prefix for kss values, +// i.e.: +// class="... kss-attr-key-value..." +// id=="kss-id-key-value" +// (XHTML:) kss-attr:key-value +// +var _kssNamespacePrefix = 'kss'; + +var _getKssValueFromEncodings = function(encodings, prefix) { + // Value us a list of values. + // If a value equals prefix-value, it will find it + // and return the value after the prefix and the dash. + // (First value found will be returned.) + // + // For example: + // + // _getKssValueFromEncodings(['kss-attr-key1-value1', 'kss-attr-key2-value2', + // 'kss-id-key1-value1'], "kss-attr-key1') + // + // results 'value1'. + // + // Legacy example: + // + // _getKssValueFromEncodings(['kssattr-key1-value1', 'kssatt-rkey2-value2'], + // "kss-attr-key1') + // + // results 'value1'. + // + prefix = prefix + '-'; + var prefixLength = prefix.length; + for (var i=0; i Author: reebalazs Date: Fri Jan 4 17:57:38 2008 New Revision: 50323 Modified: kukit/kukit.js/branch/ree-1.4-markup-and-syntax-changes/ (props changed) kukit/kukit.js/branch/ree-1.4-markup-and-syntax-changes/kukit/dom.js kukit/kukit.js/branch/ree-1.4-markup-and-syntax-changes/kukit/providerreg.js Log: Fix code by testing. Add KssIdOfValue provider. Modified: kukit/kukit.js/branch/ree-1.4-markup-and-syntax-changes/kukit/dom.js ============================================================================== --- kukit/kukit.js/branch/ree-1.4-markup-and-syntax-changes/kukit/dom.js (original) +++ kukit/kukit.js/branch/ree-1.4-markup-and-syntax-changes/kukit/dom.js Fri Jan 4 17:57:38 2008 @@ -318,6 +318,9 @@ // This means setting an attribute to '' is the same as deleting it - // at least at the moment if (! result) { + // Make sure result is null, in case we can't produce one + // below. + result = null; // Now try to get it from the class and id encodings. // Having it in the id gives the advantage that we can use // kss-id-key-value both as a unique html id, and widget markup. @@ -337,9 +340,8 @@ // Get the result- var prefix = namespacedName + '-' + key; return _getKssValueFromEncodings(encodings, prefix); - } else { - return null; } + return result; }; dom.setKssValue = function(node, keyType, key, value) { Modified: kukit/kukit.js/branch/ree-1.4-markup-and-syntax-changes/kukit/providerreg.js ============================================================================== --- kukit/kukit.js/branch/ree-1.4-markup-and-syntax-changes/kukit/providerreg.js (original) +++ kukit/kukit.js/branch/ree-1.4-markup-and-syntax-changes/kukit/providerreg.js Fri Jan 4 17:57:38 2008 @@ -158,8 +158,7 @@ if (args.length == 2) { ;;; kukit.E = '2nd attribute of currentFormVarForKssAttr must be a'; ;;; kukit.E += ' boolean'; - kukit.ut.evalBool(args[1], kukit.E); - recurseParents = args[1]; + recurseParents = kukit.ut.evalBool(args[1], kukit.E); } var formvarname = kukit.dom.getRecursiveAttribute(node, argname, recurseParents, kukit.dom.getKssAttribute); @@ -191,7 +190,7 @@ if (args.length == 2) { recurseParents = args[1]; ;;; kukit.E = '2nd attribute of nodeAttr must be a boolean.'; - kukit.ut.evalBool(recurseParents, kukit.E); + recurseParents = kukit.ut.evalBool(recurseParents, kukit.E); } return kukit.dom.getRecursiveAttribute(node, argname, recurseParents, kukit.dom.getAttribute); @@ -219,7 +218,7 @@ if (args.length == 2) { recurseParents = args[1]; ;;; kukit.E = '2nd attribute of kssAttr must be a boolean.'; - kukit.ut.evalBool(recurseParents, kukit.E); + recurseParents = kukit.ut.evalBool(recurseParents, kukit.E); } return kukit.dom.getRecursiveAttribute(node, argname, recurseParents, kukit.dom.getKssAttribute); @@ -287,7 +286,7 @@ kukit.pr.KssValuePP = function() {}; kukit.pr.KssValuePP.prototype = { check: function(args) { -;;; if (args.length != 1 && args.length != 2) { +;;; if (args.length != 2 && args.length != 3) { ;;; kukit.E = 'kssValue provider needs 2 or 3 argument (keytype, key,'; ;;; kukit.E += ' [recurseParents]).'; ;;; throw new Error(kukit.E); @@ -311,12 +310,49 @@ if (args.length == 3) { recurseParents = args[2]; ;;; kukit.E = '3rd attribute of kssAttr must be a boolean.'; - kukit.ut.evalBool(recurseParents, kukit.E); + recurseParents = kukit.ut.evalBool(recurseParents, kukit.E); } - return kukit.dom.getRecursiveAttribute(node, argname, recurseParents, - kukit.dom.getKssValue); + return kukit.dom.locateMarkup(node, recurseParents, + kukit.dom.getKssValue, + keytype, key).value; + } }; kukit.pprovidersGlobalRegistry.register('kssValue', kukit.pr.KssValuePP); +kukit.pr.KssIdOfValuePP = function() {}; +kukit.pr.KssIdOfValuePP.prototype = { + check: function(args) { +;;; if (args.length != 2) { +;;; kukit.E = 'kssIdOfValue provider needs 2 arguments (keytype, key).'; +;;; throw new Error(kukit.E); +;;; } + }, + eval: function(args, node) { + var keytype = args[0]; + var key = args[1]; +;;; if (keytype.match(/[ -]/)) { +;;; kukit.E = 'keytype parameter in kssIdOfValue provider cannot contain'; +;;; kukit.E += ' dashes or spaces.'; +;;; throw new Error(kukit.E); +;;; } +;;; if (key.match(/[ -]/)) { +;;; kukit.E = 'key parameter in kssIdOfValue provider cannot contain'; +;;; kukit.E += ' dashes or spaces.'; +;;; throw new Error(kukit.E); +;;; } + var markup = kukit.dom.locateMarkup(node, true, + kukit.dom.getKssValue, + keytype, key); + // return the id of the node where the markup is found + var id = markup.node.idd; + if (typeof(id) == 'undefined') { + // notfound arguments will get null + id = null; + } + return id; + } +}; +kukit.pprovidersGlobalRegistry.register('kssIdOfValue', kukit.pr.KssIdOfValuePP); + From reebalazs at codespeak.net Fri Jan 4 17:57:42 2008 From: reebalazs at codespeak.net (reebalazs at codespeak.net) Date: Fri, 4 Jan 2008 17:57:42 +0100 (CET) Subject: [KSS-checkins] r50324 - in kukit/kukit.js/branch/ree-1.4-markup-and-syntax-changes: . kukit Message-ID: <20080104165742.8DE0C1684CE@codespeak.net> Author: reebalazs Date: Fri Jan 4 17:57:41 2008 New Revision: 50324 Modified: kukit/kukit.js/branch/ree-1.4-markup-and-syntax-changes/ (props changed) kukit/kukit.js/branch/ree-1.4-markup-and-syntax-changes/kukit/commandreg.js Log: Change the lookup of selectors when executing for commands We now look up the selector from the provider, not the other way around. This will make it possible for commands to use selectors with more parameters. (todo later) Modified: kukit/kukit.js/branch/ree-1.4-markup-and-syntax-changes/kukit/commandreg.js ============================================================================== --- kukit/kukit.js/branch/ree-1.4-markup-and-syntax-changes/kukit/commandreg.js (original) +++ kukit/kukit.js/branch/ree-1.4-markup-and-syntax-changes/kukit/commandreg.js Fri Jan 4 17:57:41 2008 @@ -114,10 +114,30 @@ }; var _executeCommandOnSelector = function(oper) { - var selfunc = kukit.selectorTypesGlobalRegistry.get(this.selectorType); - // When applying the selection, the original event target will be used + // if the selector type is null or undefined or '', + // we use the default type. + var selectorType = this.selectorType || + kukit.selectorTypesGlobalRegistry.defaultSelectorType; + // Use the provider registry to look up the selection provider. + var providerClass = kukit.pprovidersGlobalRegistry.get(selectorType); + // See if if is really a selection provider. + if (providerClass.prototype.returnType != 'selection') { + kukit.E = 'Undefined selector type [' + selectorType + '], '; + kukit.E = 'it exists as provider but it does not return a selection.'; + throw new Error(kukit.E); + } + // Instantiate it + var provider = new providerClass(); + var args = [this.selector]; +;;; // Check the provider first. +;;; provider.check(args); + // When evaluating the provider, the original event target will be used // as a starting point for the selection. - var nodes = selfunc(this.selector, oper.orignode, {}); + // args will contain a single item, since the server side currently + // cannot marshall selectors with more parameters + // defaultParameters will be empty when using from commands. + var nodes = provider.eval(args, oper.orignode, {}); + // ;;;var printType; ;;;if (this.selectorType) { ;;; printType = this.selectorType; From reebalazs at codespeak.net Fri Jan 4 17:57:46 2008 From: reebalazs at codespeak.net (reebalazs at codespeak.net) Date: Fri, 4 Jan 2008 17:57:46 +0100 (CET) Subject: [KSS-checkins] r50325 - in kukit/kukit.js/branch/ree-1.4-markup-and-syntax-changes: . kukit Message-ID: <20080104165746.C01F11684CE@codespeak.net> Author: reebalazs Date: Fri Jan 4 17:57:46 2008 New Revision: 50325 Modified: kukit/kukit.js/branch/ree-1.4-markup-and-syntax-changes/ (props changed) kukit/kukit.js/branch/ree-1.4-markup-and-syntax-changes/kukit/providerreg.js kukit/kukit.js/branch/ree-1.4-markup-and-syntax-changes/kukit/selectorreg.js Log: Add kssWidget selector Modified: kukit/kukit.js/branch/ree-1.4-markup-and-syntax-changes/kukit/providerreg.js ============================================================================== --- kukit/kukit.js/branch/ree-1.4-markup-and-syntax-changes/kukit/providerreg.js (original) +++ kukit/kukit.js/branch/ree-1.4-markup-and-syntax-changes/kukit/providerreg.js Fri Jan 4 17:57:46 2008 @@ -345,7 +345,7 @@ kukit.dom.getKssValue, keytype, key); // return the id of the node where the markup is found - var id = markup.node.idd; + var id = markup.node.id; if (typeof(id) == 'undefined') { // notfound arguments will get null id = null; Modified: kukit/kukit.js/branch/ree-1.4-markup-and-syntax-changes/kukit/selectorreg.js ============================================================================== --- kukit/kukit.js/branch/ree-1.4-markup-and-syntax-changes/kukit/selectorreg.js (original) +++ kukit/kukit.js/branch/ree-1.4-markup-and-syntax-changes/kukit/selectorreg.js Fri Jan 4 17:57:46 2008 @@ -21,6 +21,7 @@ // this will provide an arbitrary selector, and is designed to // be used with the makeAnyPP factory function. +// It produces selectors that have a single input parameter. kukit.sr.AnyPP = function() {}; kukit.sr.AnyPP.prototype = { check: function(args) { @@ -160,3 +161,33 @@ } return results; }); + +kukit.sr.KssWidgetPP = function() {}; +kukit.sr.KssWidgetPP.prototype = { + check: function(args) { +;;; if (args.length != 2) { +;;; throw new Error('kssWidget selector method needs 2 arguments'); +;;; } + }, + eval: function(args, node, defaultParameters) { + var keytype = args[0]; + var key = args[1]; +;;; if (keytype.match(/[ -]/)) { +;;; kukit.E = 'keytype parameter in kssIdOfValue provider cannot contain'; +;;; kukit.E += ' dashes or spaces.'; +;;; throw new Error(kukit.E); +;;; } +;;; if (key.match(/[ -]/)) { +;;; kukit.E = 'key parameter in kssIdOfValue provider cannot contain'; +;;; kukit.E += ' dashes or spaces.'; +;;; throw new Error(kukit.E); +;;; } + var markup = kukit.dom.locateMarkup(node, true, + kukit.dom.getKssValue, + keytype, key); + // Just return the markup's node as a single result. + return [markup.node]; + } +}; +kukit.pprovidersGlobalRegistry.register('kssWidget', kukit.sr.KssWidgetPP, 'selection'); + From reebalazs at codespeak.net Fri Jan 4 18:03:19 2008 From: reebalazs at codespeak.net (reebalazs at codespeak.net) Date: Fri, 4 Jan 2008 18:03:19 +0100 (CET) Subject: [KSS-checkins] r50326 - kukit/kss.core/branch/ree-1.4-markup-and-syntax-changes Message-ID: <20080104170319.5BA12168446@codespeak.net> Author: reebalazs Date: Fri Jan 4 18:03:18 2008 New Revision: 50326 Added: kukit/kss.core/branch/ree-1.4-markup-and-syntax-changes/ - copied from r50325, kukit/kss.core/trunk/ Log: Branch off From reebalazs at codespeak.net Fri Jan 4 18:11:10 2008 From: reebalazs at codespeak.net (reebalazs at codespeak.net) Date: Fri, 4 Jan 2008 18:11:10 +0100 (CET) Subject: [KSS-checkins] r50327 - in kukit/kss.core/branch/ree-1.4-markup-and-syntax-changes: docs kss/core/plugins/core/demo kss/core/plugins/core/demo/markup kss/core/plugins/core/demo/markup/selenium_tests kss/core/plugins/core/demo/parameterfunction Message-ID: <20080104171110.101E21684C4@codespeak.net> Author: reebalazs Date: Fri Jan 4 18:11:10 2008 New Revision: 50327 Added: kukit/kss.core/branch/ree-1.4-markup-and-syntax-changes/kss/core/plugins/core/demo/markup/ kukit/kss.core/branch/ree-1.4-markup-and-syntax-changes/kss/core/plugins/core/demo/markup/README kukit/kss.core/branch/ree-1.4-markup-and-syntax-changes/kss/core/plugins/core/demo/markup/__init__.py kukit/kss.core/branch/ree-1.4-markup-and-syntax-changes/kss/core/plugins/core/demo/markup/config.py kukit/kss.core/branch/ree-1.4-markup-and-syntax-changes/kss/core/plugins/core/demo/markup/configure.zcml kukit/kss.core/branch/ree-1.4-markup-and-syntax-changes/kss/core/plugins/core/demo/markup/markup.kss kukit/kss.core/branch/ree-1.4-markup-and-syntax-changes/kss/core/plugins/core/demo/markup/markup.pt kukit/kss.core/branch/ree-1.4-markup-and-syntax-changes/kss/core/plugins/core/demo/markup/selenium_tests/ kukit/kss.core/branch/ree-1.4-markup-and-syntax-changes/kss/core/plugins/core/demo/markup/selenium_tests/README.txt kukit/kss.core/branch/ree-1.4-markup-and-syntax-changes/kss/core/plugins/core/demo/markup/selenium_tests/markup.html kukit/kss.core/branch/ree-1.4-markup-and-syntax-changes/kss/core/plugins/core/demo/markup/zopeconfig.py Modified: kukit/kss.core/branch/ree-1.4-markup-and-syntax-changes/docs/HISTORY.txt kukit/kss.core/branch/ree-1.4-markup-and-syntax-changes/kss/core/plugins/core/demo/config.py kukit/kss.core/branch/ree-1.4-markup-and-syntax-changes/kss/core/plugins/core/demo/configure.zcml kukit/kss.core/branch/ree-1.4-markup-and-syntax-changes/kss/core/plugins/core/demo/demoview.py kukit/kss.core/branch/ree-1.4-markup-and-syntax-changes/kss/core/plugins/core/demo/form_submit.kss kukit/kss.core/branch/ree-1.4-markup-and-syntax-changes/kss/core/plugins/core/demo/parameterfunction/forms.kss kukit/kss.core/branch/ree-1.4-markup-and-syntax-changes/kss/core/plugins/core/demo/parameterfunction/forms.pt kukit/kss.core/branch/ree-1.4-markup-and-syntax-changes/kss/core/plugins/core/demo/zopeconfig.py Log: Start of work. Adding an extra demo and test. Modified: kukit/kss.core/branch/ree-1.4-markup-and-syntax-changes/docs/HISTORY.txt ============================================================================== --- kukit/kss.core/branch/ree-1.4-markup-and-syntax-changes/docs/HISTORY.txt (original) +++ kukit/kss.core/branch/ree-1.4-markup-and-syntax-changes/docs/HISTORY.txt Fri Jan 4 18:11:10 2008 @@ -6,6 +6,19 @@ - ... + - refactor the value provider registry to use + a single registry in place of 3. + This will enable to define value + providers that recieve non-string parameters + like a node selection. + + Remove previously deprecated form() and + currentForm() value providers from normal + action parameters (remark: they should + be used with kssSelector.) + They now give a parsing error. + [ree] + - Fix multiple selection form fields marshalling on Safari (fixes #22 in kssproject) Modified: kukit/kss.core/branch/ree-1.4-markup-and-syntax-changes/kss/core/plugins/core/demo/config.py ============================================================================== --- kukit/kss.core/branch/ree-1.4-markup-and-syntax-changes/kss/core/plugins/core/demo/config.py (original) +++ kukit/kss.core/branch/ree-1.4-markup-and-syntax-changes/kss/core/plugins/core/demo/config.py Fri Jan 4 18:11:10 2008 @@ -21,7 +21,7 @@ KSSDemo('', '', "preventdefault.html", "Preventdefault (a.k.a. Safari workarounds)"), KSSDemo('', '', "html_inserts.html", "HTML insertions (Change tag content returns)"), KSSDemo('', '', "client-server-protocol", "Client server protocol"), - KSSDemo('', 'Parameter functions', 'pf_forms.html', 'Forms'), + KSSDemo('', 'Value providers', 'pf_forms.html', 'Forms'), KSSDemo('', 'Selectors', 'selectors.html', 'Parent node selector'), KSSDemo('', 'Core syntax', "kss_selector_param.html", "Kss selector parameters"), KSSDemo('', 'Core syntax', "kss_url_param.html", "Kss url parameters"), Modified: kukit/kss.core/branch/ree-1.4-markup-and-syntax-changes/kss/core/plugins/core/demo/configure.zcml ============================================================================== --- kukit/kss.core/branch/ree-1.4-markup-and-syntax-changes/kss/core/plugins/core/demo/configure.zcml (original) +++ kukit/kss.core/branch/ree-1.4-markup-and-syntax-changes/kss/core/plugins/core/demo/configure.zcml Fri Jan 4 18:11:10 2008 @@ -15,6 +15,7 @@ + + + + + + + + + + + + + + Added: kukit/kss.core/branch/ree-1.4-markup-and-syntax-changes/kss/core/plugins/core/demo/markup/markup.kss ============================================================================== --- (empty file) +++ kukit/kss.core/branch/ree-1.4-markup-and-syntax-changes/kss/core/plugins/core/demo/markup/markup.kss Fri Jan 4 18:11:10 2008 @@ -0,0 +1,43 @@ + +/* Set up kss rules needed for your demo. + * Use the following rule as an example only. + */ + +.buttons:click { + action-client: replaceInnerHTML; + replaceInnerHTML-kssSelector: #logger; +} + +#log-reset a:click { + evt-click-preventdefault: true; + action-client: clearChildNodes; + clearChildNodes-kssSelector: #logger; +} + +#button1:click { + replaceInnerHTML-html: kssValue(attr, key); +} + +#button2:click { + replaceInnerHTML-html: kssValue(id, key); +} + +#button3:click { + replaceInnerHTML-html: kssValue(attr, key); +} + +#button4:click, #button5:click { + replaceInnerHTML-html: kssValue(mymarkup, key, false); +} + +#button6:click { + replaceInnerHTML-html: kssIdOfValue(attr, key); +} + +#button7:click { + replaceInnerHTML-html: "Executed, look at button's text."; + action-client: insertHTMLAsFirstChild; + insertHTMLAsFirstChild-kssSelector: kssWidget(attr, key); + insertHTMLAsFirstChild-html: 'Selector succeeded'; +} + Added: kukit/kss.core/branch/ree-1.4-markup-and-syntax-changes/kss/core/plugins/core/demo/markup/markup.pt ============================================================================== --- (empty file) +++ kukit/kss.core/branch/ree-1.4-markup-and-syntax-changes/kss/core/plugins/core/demo/markup/markup.pt Fri Jan 4 18:11:10 2008 @@ -0,0 +1,76 @@ + + + + + +

header

+ + +

HTML markup

+ +
+ + +

Log

+

Reset log

+

You clicked:

+
+

+
+ +
+ +

kssValue(attr, key) encoding in class

+ +
+ +
+ +
+

kssValue(id, key) encoding in id

+ +
+ +
+ +
+

kssValue(attr, key) as XHTML attribute

+ +
+ +
+ +
+

kssValue(mymarkup, key, false) encoding in class

+ +
+ +
+ +
+

kssValue(mymarkup, key, false) encoding in class (should give no result)

+ +
+ +
+ +
+

kssIdOfValue(attr, key) encoding in class

+ +
+ +
+ +
+

xxx-kssSelector: kssWidget(attr, key); encoding in class

+ +
+ +
+ + +
+ + + + Added: kukit/kss.core/branch/ree-1.4-markup-and-syntax-changes/kss/core/plugins/core/demo/markup/selenium_tests/README.txt ============================================================================== --- (empty file) +++ kukit/kss.core/branch/ree-1.4-markup-and-syntax-changes/kss/core/plugins/core/demo/markup/selenium_tests/README.txt Fri Jan 4 18:11:10 2008 @@ -0,0 +1,4 @@ + +Save sour selenium tests into this directory, in html format. +All the tests ending with .html will be processed automatically. + Added: kukit/kss.core/branch/ree-1.4-markup-and-syntax-changes/kss/core/plugins/core/demo/markup/selenium_tests/markup.html ============================================================================== --- (empty file) +++ kukit/kss.core/branch/ree-1.4-markup-and-syntax-changes/kss/core/plugins/core/demo/markup/selenium_tests/markup.html Fri Jan 4 18:11:10 2008 @@ -0,0 +1,84 @@ + + + +markup + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
markup
open/demo/markup.html
clickbutton1
waitForTextPresentvalue1
clickbutton2
waitForTextPresentvalue2
clickbutton3
waitForTextPresentvalue3
clickbutton4
waitForTextPresentvalue4
clickbutton5
waitForTextPresent
clickbutton7
waitForTextPresentExecuted, look at button's text.
verifyTextPresentSelector succeeded
+ + Added: kukit/kss.core/branch/ree-1.4-markup-and-syntax-changes/kss/core/plugins/core/demo/markup/zopeconfig.py ============================================================================== --- (empty file) +++ kukit/kss.core/branch/ree-1.4-markup-and-syntax-changes/kss/core/plugins/core/demo/markup/zopeconfig.py Fri Jan 4 18:11:10 2008 @@ -0,0 +1,35 @@ + +from kss.demo.interfaces import ( + IKSSDemoResource, + IKSSSeleniumTestResource, + ) +from kss.demo.resource import ( + KSSDemo, + KSSSeleniumTestDirectory, + ) +from zope.interface import implements + +# Create a mesh of provided interfaces +# This is needed, because an utility must have a single interface. +class IResource(IKSSDemoResource, IKSSSeleniumTestResource): + pass + +# XXX you do not need to change anything above here +# ------------------------------------------------- + +class KSSDemos(object): + implements(IResource) + + demos = ( + # List your demos here. + # (Second parameter can be a subcategory within the demo if needed.) + KSSDemo('', 'Value providers', 'markup.html', 'HTML markup'), + + ) + + # directories are relative from the location of this .py file + selenium_tests = ( + # if you only have one test directory, you + # need not change anything here. + KSSSeleniumTestDirectory('selenium_tests'), + ) Modified: kukit/kss.core/branch/ree-1.4-markup-and-syntax-changes/kss/core/plugins/core/demo/parameterfunction/forms.kss ============================================================================== --- kukit/kss.core/branch/ree-1.4-markup-and-syntax-changes/kss/core/plugins/core/demo/parameterfunction/forms.kss (original) +++ kukit/kss.core/branch/ree-1.4-markup-and-syntax-changes/kss/core/plugins/core/demo/parameterfunction/forms.kss Fri Jan 4 18:11:10 2008 @@ -53,16 +53,6 @@ executeCommand-html: currentFormVar(radio-by-name); } -#fullform-simple:click { - action-server: submitFullForm; - submitFullForm-form: currentForm(); -} - -#fullform-simplenamed:click { - action-server: submitFullForm; - submitFullForm-form: form(full1); -} - #fullform-current:click { action-server: submitFullFormIntoRequest; submitFullFormIntoRequest-kssSubmitForm: currentForm(); Modified: kukit/kss.core/branch/ree-1.4-markup-and-syntax-changes/kss/core/plugins/core/demo/parameterfunction/forms.pt ============================================================================== --- kukit/kss.core/branch/ree-1.4-markup-and-syntax-changes/kss/core/plugins/core/demo/parameterfunction/forms.pt (original) +++ kukit/kss.core/branch/ree-1.4-markup-and-syntax-changes/kss/core/plugins/core/demo/parameterfunction/forms.pt Fri Jan 4 18:11:10 2008 @@ -143,24 +143,14 @@ form(full1) with simple field names, named form
- Click the button. + Removed after deprecation. +
+

+ currentForm() with simple field names +

+
+ Removed after deprecation.
- Click me ! -
-
-

- currentForm() with simple field names -

-
- Click the button. -
- Click me ! - - -
-

xxx-kssSubmitForm: form(full2) with complex field names, named form

Modified: kukit/kss.core/branch/ree-1.4-markup-and-syntax-changes/kss/core/plugins/core/demo/zopeconfig.py ============================================================================== --- kukit/kss.core/branch/ree-1.4-markup-and-syntax-changes/kss/core/plugins/core/demo/zopeconfig.py (original) +++ kukit/kss.core/branch/ree-1.4-markup-and-syntax-changes/kss/core/plugins/core/demo/zopeconfig.py Fri Jan 4 18:11:10 2008 @@ -33,7 +33,7 @@ KSSDemo('', '', "html_inserts.html", "HTML insertions (Change tag content returns)"), KSSDemo('', '', "client-server-protocol", "Client server protocol"), ## KSSDemo('', '', "draganddrop.html", "Scriptaculous drag and drop"), - KSSDemo('', 'Parameter functions', 'pf_forms.html', 'Forms'), + KSSDemo('', 'Value providers', 'pf_forms.html', 'Forms'), KSSDemo('', 'Selectors', 'selectors.html', 'Parent node selector'), KSSDemo('', 'Core syntax', "kss_selector_param.html", "Kss selector parameters"), KSSDemo('', 'Core syntax', "kss_url_param.html", "Kss url parameters"), From reebalazs at codespeak.net Fri Jan 4 18:12:24 2008 From: reebalazs at codespeak.net (reebalazs at codespeak.net) Date: Fri, 4 Jan 2008 18:12:24 +0100 (CET) Subject: [KSS-checkins] r50328 - kukit/kss.core/branch/ree-1.4-markup-and-syntax-changes/kss/core Message-ID: <20080104171224.B5A4E1684C4@codespeak.net> Author: reebalazs Date: Fri Jan 4 18:12:24 2008 New Revision: 50328 Modified: kukit/kss.core/branch/ree-1.4-markup-and-syntax-changes/kss/core/ (props changed) kukit/kss.core/branch/ree-1.4-markup-and-syntax-changes/kss/core/EXTERNALS.TXT Log: Set branch Modified: kukit/kss.core/branch/ree-1.4-markup-and-syntax-changes/kss/core/EXTERNALS.TXT ============================================================================== --- kukit/kss.core/branch/ree-1.4-markup-and-syntax-changes/kss/core/EXTERNALS.TXT (original) +++ kukit/kss.core/branch/ree-1.4-markup-and-syntax-changes/kss/core/EXTERNALS.TXT Fri Jan 4 18:12:24 2008 @@ -5,4 +5,5 @@ # You can update your working dir by: # svn propset svn:externals -F EXTERNALS.TXT . # -kukit http://codespeak.net/svn/kukit/kukit.js/trunk/ +kukit http://codespeak.net/svn/kukit/kukit.js/trunk/branch/ree-1.4-markup-and-syntax-changes + From kukit-checkins at codespeak.net Sat Jan 5 10:15:29 2008 From: kukit-checkins at codespeak.net (kukit-checkins at codespeak.net) Date: Sat, 5 Jan 2008 10:15:29 +0100 (CET) Subject: [KSS-checkins] Penis Today, Not Gone Tomorrow! Message-ID: <20080105131900.5671.qmail@static-212.56.199.17.mldnet.com> An HTML attachment was scrubbed... URL: http://codespeak.net/pipermail/kukit-checkins/attachments/20080105/d1d53bd2/attachment.htm From kukit-checkins at codespeak.net Sat Jan 5 10:44:59 2008 From: kukit-checkins at codespeak.net (kukit-checkins at codespeak.net) Date: Sat, 5 Jan 2008 10:44:59 +0100 (CET) Subject: [KSS-checkins] Penis Today, Not Gone Tomorrow! Message-ID: <20080105114500.11653.qmail@caching1-pnc2.asianet.co.th> An HTML attachment was scrubbed... URL: http://codespeak.net/pipermail/kukit-checkins/attachments/20080105/7b2987c2/attachment.htm From kukit-checkins at codespeak.net Sat Jan 5 10:45:17 2008 From: kukit-checkins at codespeak.net (kukit-checkins at codespeak.net) Date: Sat, 5 Jan 2008 10:45:17 +0100 (CET) Subject: [KSS-checkins] Penis Today, Not Gone Tomorrow! Message-ID: <20080105114519.2508.qmail@bn170.osiedle.net.pl> An HTML attachment was scrubbed... URL: http://codespeak.net/pipermail/kukit-checkins/attachments/20080105/152b0f71/attachment-0001.htm From jvloothuis at codespeak.net Sun Jan 6 15:24:58 2008 From: jvloothuis at codespeak.net (jvloothuis at codespeak.net) Date: Sun, 6 Jan 2008 15:24:58 +0100 (CET) Subject: [KSS-checkins] r50377 - in kukit/kss.core/trunk/kss/core: . browser plugins/core/demo plugins/core/demo/selenium_tests tests Message-ID: <20080106142458.E13051684CE@codespeak.net> Author: jvloothuis Date: Sun Jan 6 15:24:58 2008 New Revision: 50377 Added: kukit/kss.core/trunk/kss/core/plugins/core/demo/selenium_tests/protocol.html Modified: kukit/kss.core/trunk/kss/core/browser/errorresponse.pt kukit/kss.core/trunk/kss/core/commands.py kukit/kss.core/trunk/kss/core/plugins/core/demo/protocol.pt kukit/kss.core/trunk/kss/core/tests/kukitresponse_test.pt kukit/kss.core/trunk/kss/core/tests/test_browserview.py kukit/kss.core/trunk/kss/core/tests/test_kssview_core.py Log: Increased the version number of all responses to 1.1 as discussed with Godefroid and Balazs since we currently put HTML inside CDATA nodes (we previously made HTML part of the response DOM). Fixed problems in the protocol due to improper escaping Fixed a problem with the protocol and Firefox where Firefox splits text nodes larger than 4K Modified: kukit/kss.core/trunk/kss/core/browser/errorresponse.pt ============================================================================== --- kukit/kss.core/trunk/kss/core/browser/errorresponse.pt (original) +++ kukit/kss.core/trunk/kss/core/browser/errorresponse.pt Sun Jan 6 15:24:58 2008 @@ -1,5 +1,5 @@ - Modified: kukit/kss.core/trunk/kss/core/commands.py ============================================================================== --- kukit/kss.core/trunk/kss/core/commands.py (original) +++ kukit/kss.core/trunk/kss/core/commands.py Sun Jan 6 15:24:58 2008 @@ -22,6 +22,7 @@ in the defined format ''' +from xml.sax.saxutils import escape as xml_escape from zope.interface import implements from zope.app.pagetemplate.viewpagetemplatefile import ViewPageTemplateFile from interfaces import IKSSCommands, IKSSCommand, IKSSParam, IKSSCommandView @@ -106,6 +107,16 @@ # just send complex data types directly with AddParam def addParam(self, name, content=''): + # Check for the size of the content. Larger than 4K will give + # problems with Firefox (which splits text nodes). Therefore + # we give this special treatment. + if len(content) > 4096: + return self.addCdataParam(name, content) + else: + # Escape all XML characters + return self._addParam(name, content=xml_escape(content)) + + def _addParam(self, name, content=''): 'Add the param as is' param = KSSParam(name, content) self.params.append(param) @@ -115,14 +126,14 @@ # Some helpers # - def addUnicodeParam(self, name, content=''): + def addUnicodeParam(self, name, content=u''): 'Add the param as unicode' - self.addParam(name, content=content) + self.addParam(name, content) - def addStringParam(self, name, content='', encoding='utf'): + def addStringParam(self, name, content='', encoding='utf8'): 'Add the param as an encoded string, by default UTF-8' - content = unicode(content, 'utf') - self.addParam(name, content=content) + content = unicode(content, encoding) + self.addUnicodeParam(name, content=content) def addHtmlParam(self, name, content=''): 'Add the param as an HTML content.' @@ -134,12 +145,14 @@ def addXmlParam(self, name, content=''): 'Add the param as XML content' content = XmlParser(content)().encode('ascii', 'xmlcharrefreplace') - self.addParam(name, content=content) + self._addParam(name, content=content) def addCdataParam(self, name, content=''): 'Add the param as a CDATA node' - content = '' % (content, ) - self.addParam(name, content=content) + # Replace `>` part of `]]>` with the entity ref so it won't + # accidentally close the CDATA (required by the XML spec) + content = '' % content.replace(']]>', ']]>') + self._addParam(name, content=content) # -- Modified: kukit/kss.core/trunk/kss/core/plugins/core/demo/protocol.pt ============================================================================== --- kukit/kss.core/trunk/kss/core/plugins/core/demo/protocol.pt (original) +++ kukit/kss.core/trunk/kss/core/plugins/core/demo/protocol.pt Sun Jan 6 15:24:58 2008 @@ -29,6 +29,9 @@
  • Small dataset
  • Large dataset
  • +
    + The contents of this node will change +

    Currently kss.core treats non-HTML commands differently from others. The following examples show why I think this to be a Added: kukit/kss.core/trunk/kss/core/plugins/core/demo/selenium_tests/protocol.html ============================================================================== --- (empty file) +++ kukit/kss.core/trunk/kss/core/plugins/core/demo/selenium_tests/protocol.html Sun Jan 6 15:24:58 2008 @@ -0,0 +1,169 @@ + + + +protocol + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    protocol
    open/demo/client-server-protocol
    clicksmall-dataset
    waitForTextcss=#dataset-output emWorked
    clicklarge-dataset
    waitForTextcss=#dataset-output emreally really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really really large text
    clicksmall-attribute
    waitForAttributeattribute-output at classsome smallattr
    verifyAttributeattribute-output at classsome smallattr
    clicklarge-attribute
    waitForAttributeattribute-output at classh h1 h22 h333 h4444 h55555 h666666 h7777777 h88888888 h999999999 haaaaaaaaaa hbbbbbbbbbbb hcccccccccccc hddddddddddddd heeeeeeeeeeeeee hfffffffffffffff h10101010101010101010101010101010 h1111111111111111111111111111111111 h121212121212121212121212121212121212 h13131313131313131313131313131313131313 h1414141414141414141414141414141414141414 h151515151515151515151515151515151515151515 h16161616161616161616161616161616161616161616 h1717171717171717171717171717171717171717171717 h181818181818181818181818181818181818181818181818 h19191919191919191919191919191919191919191919191919 h1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a h1b1b1b1b1b1b1b1b1b1b1b1b1b1b1b1b1b1b1b1b1b1b1b1b1b1b1b h1c1c1c1c1c1c1c1c1c1c1c1c1c1c1c1c1c1c1c1c1c1c1c1c1c1c1c1c h1d1d1d1d1d1d1d1d1d1d1d1d1d1d1d1d1d1d1d1d1d1d1d1d1d1d1d1d1d h1e1e1e1e1e1e1e1e1e1e1e1e1e1e1e1e1e1e1e1e1e1e1e1e1e1e1e1e1e1e h1f1f1f1f1f1f1f1f1f1f1f1f1f1f1f1f1f1f1f1f1f1f1f1f1f1f1f1f1f1f1f h2020202020202020202020202020202020202020202020202020202020202020 h212121212121212121212121212121212121212121212121212121212121212121 h22222222222222222222222222222222222222222222222222222222222222222222 h2323232323232323232323232323232323232323232323232323232323232323232323 h242424242424242424242424242424242424242424242424242424242424242424242424 h25252525252525252525252525252525252525252525252525252525252525252525252525 h2626262626262626262626262626262626262626262626262626262626262626262626262626 h272727272727272727272727272727272727272727272727272727272727272727272727272727 h28282828282828282828282828282828282828282828282828282828282828282828282828282828 h2929292929292929292929292929292929292929292929292929292929292929292929292929292929 h2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a h2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b h2c2c2c2c2c2c2c2c2c2c2c2c2c2c2c2c2c2c2c2c2c2c2c2c2c2c2c2c2c2c2c2c2c2c2c2c2c2c2c2c2c2c2c2c h2d2d2d2d2d2d2d2d2d2d2d2d2d2d2d2d2d2d2d2d2d2d2d2d2d2d2d2d2d2d2d2d2d2d2d2d2d2d2d2d2d2d2d2d2d h2e2e2e2e2e2e2e2e2e2e2e2e2e2e2e2e2e2e2e2e2e2e2e2e2e2e2e2e2e2e2e2e2e2e2e2e2e2e2e2e2e2e2e2e2e2e h2f2f2f2f2f2f2f2f2f2f2f2f2f2f2f2f2f2f2f2f2f2f2f2f2f2f2f2f2f2f2f2f2f2f2f2f2f2f2f2f2f2f2f2f2f2f2f h303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030 h31313131313131313131313131313131313131313131313131313131313131313131313131313131313131313131313131 h3232323232323232323232323232323232323232323232323232323232323232323232323232323232323232323232323232 h333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333 h34343434343434343434343434343434343434343434343434343434343434343434343434343434343434343434343434343434 h3535353535353535353535353535353535353535353535353535353535353535353535353535353535353535353535353535353535 h363636363636363636363636363636363636363636363636363636363636363636363636363636363636363636363636363636363636 h37373737373737373737373737373737373737373737373737373737373737373737373737373737373737373737373737373737373737 h3838383838383838383838383838383838383838383838383838383838383838383838383838383838383838383838383838383838383838 h393939393939393939393939393939393939393939393939393939393939393939393939393939393939393939393939393939393939393939 h3a3a3a3a3a3a3a3a3a3a3a3a3a3a3a3a3a3a3a3a3a3a3a3a3a3a3a3a3a3a3a3a3a3a3a3a3a3a3a3a3a3a3a3a3a3a3a3a3a3a3a3a3a3a3a3a3a3a h3b3b3b3b3b3b3b3b3b3b3b3b3b3b3b3b3b3b3b3b3b3b3b3b3b3b3b3b3b3b3b3b3b3b3b3b3b3b3b3b3b3b3b3b3b3b3b3b3b3b3b3b3b3b3b3b3b3b3b h3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c h3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d h3e3e3e3e3e3e3e3e3e3e3e3e3e3e3e3e3e3e3e3e3e3e3e3e3e3e3e3e3e3e3e3e3e3e3e3e3e3e3e3e3e3e3e3e3e3e3e3e3e3e3e3e3e3e3e3e3e3e3e3e3e3e h3f3f3f3f3f3f3f3f3f3f3f3f3f3f3f3f3f3f3f3f3f3f3f3f3f3f3f3f3f3f3f3f3f3f3f3f3f3f3f3f3f3f3f3f3f3f3f3f3f3f3f3f3f3f3f3f3f3f3f3f3f3f3f h40404040404040404040404040404040404040404040404040404040404040404040404040404040404040404040404040404040404040404040404040404040 h4141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141 h424242424242424242424242424242424242424242424242424242424242424242424242424242424242424242424242424242424242424242424242424242424242 h43434343434343434343434343434343434343434343434343434343434343434343434343434343434343434343434343434343434343434343434343434343434343 h4444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444 h454545454545454545454545454545454545454545454545454545454545454545454545454545454545454545454545454545454545454545454545454545454545454545 largeattr
    verifyAttributeattribute-output at classh h1 h22 h333 h4444 h55555 h666666 h7777777 h88888888 h999999999 haaaaaaaaaa hbbbbbbbbbbb hcccccccccccc hddddddddddddd heeeeeeeeeeeeee hfffffffffffffff h10101010101010101010101010101010 h1111111111111111111111111111111111 h121212121212121212121212121212121212 h13131313131313131313131313131313131313 h1414141414141414141414141414141414141414 h151515151515151515151515151515151515151515 h16161616161616161616161616161616161616161616 h1717171717171717171717171717171717171717171717 h181818181818181818181818181818181818181818181818 h19191919191919191919191919191919191919191919191919 h1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a h1b1b1b1b1b1b1b1b1b1b1b1b1b1b1b1b1b1b1b1b1b1b1b1b1b1b1b h1c1c1c1c1c1c1c1c1c1c1c1c1c1c1c1c1c1c1c1c1c1c1c1c1c1c1c1c h1d1d1d1d1d1d1d1d1d1d1d1d1d1d1d1d1d1d1d1d1d1d1d1d1d1d1d1d1d h1e1e1e1e1e1e1e1e1e1e1e1e1e1e1e1e1e1e1e1e1e1e1e1e1e1e1e1e1e1e h1f1f1f1f1f1f1f1f1f1f1f1f1f1f1f1f1f1f1f1f1f1f1f1f1f1f1f1f1f1f1f h2020202020202020202020202020202020202020202020202020202020202020 h212121212121212121212121212121212121212121212121212121212121212121 h22222222222222222222222222222222222222222222222222222222222222222222 h2323232323232323232323232323232323232323232323232323232323232323232323 h242424242424242424242424242424242424242424242424242424242424242424242424 h25252525252525252525252525252525252525252525252525252525252525252525252525 h2626262626262626262626262626262626262626262626262626262626262626262626262626 h272727272727272727272727272727272727272727272727272727272727272727272727272727 h28282828282828282828282828282828282828282828282828282828282828282828282828282828 h2929292929292929292929292929292929292929292929292929292929292929292929292929292929 h2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a h2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b h2c2c2c2c2c2c2c2c2c2c2c2c2c2c2c2c2c2c2c2c2c2c2c2c2c2c2c2c2c2c2c2c2c2c2c2c2c2c2c2c2c2c2c2c h2d2d2d2d2d2d2d2d2d2d2d2d2d2d2d2d2d2d2d2d2d2d2d2d2d2d2d2d2d2d2d2d2d2d2d2d2d2d2d2d2d2d2d2d2d h2e2e2e2e2e2e2e2e2e2e2e2e2e2e2e2e2e2e2e2e2e2e2e2e2e2e2e2e2e2e2e2e2e2e2e2e2e2e2e2e2e2e2e2e2e2e h2f2f2f2f2f2f2f2f2f2f2f2f2f2f2f2f2f2f2f2f2f2f2f2f2f2f2f2f2f2f2f2f2f2f2f2f2f2f2f2f2f2f2f2f2f2f2f h303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030 h31313131313131313131313131313131313131313131313131313131313131313131313131313131313131313131313131 h3232323232323232323232323232323232323232323232323232323232323232323232323232323232323232323232323232 h333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333 h34343434343434343434343434343434343434343434343434343434343434343434343434343434343434343434343434343434 h3535353535353535353535353535353535353535353535353535353535353535353535353535353535353535353535353535353535 h363636363636363636363636363636363636363636363636363636363636363636363636363636363636363636363636363636363636 h37373737373737373737373737373737373737373737373737373737373737373737373737373737373737373737373737373737373737 h3838383838383838383838383838383838383838383838383838383838383838383838383838383838383838383838383838383838383838 h393939393939393939393939393939393939393939393939393939393939393939393939393939393939393939393939393939393939393939 h3a3a3a3a3a3a3a3a3a3a3a3a3a3a3a3a3a3a3a3a3a3a3a3a3a3a3a3a3a3a3a3a3a3a3a3a3a3a3a3a3a3a3a3a3a3a3a3a3a3a3a3a3a3a3a3a3a3a h3b3b3b3b3b3b3b3b3b3b3b3b3b3b3b3b3b3b3b3b3b3b3b3b3b3b3b3b3b3b3b3b3b3b3b3b3b3b3b3b3b3b3b3b3b3b3b3b3b3b3b3b3b3b3b3b3b3b3b h3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c h3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d h3e3e3e3e3e3e3e3e3e3e3e3e3e3e3e3e3e3e3e3e3e3e3e3e3e3e3e3e3e3e3e3e3e3e3e3e3e3e3e3e3e3e3e3e3e3e3e3e3e3e3e3e3e3e3e3e3e3e3e3e3e3e h3f3f3f3f3f3f3f3f3f3f3f3f3f3f3f3f3f3f3f3f3f3f3f3f3f3f3f3f3f3f3f3f3f3f3f3f3f3f3f3f3f3f3f3f3f3f3f3f3f3f3f3f3f3f3f3f3f3f3f3f3f3f3f h40404040404040404040404040404040404040404040404040404040404040404040404040404040404040404040404040404040404040404040404040404040 h4141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141 h424242424242424242424242424242424242424242424242424242424242424242424242424242424242424242424242424242424242424242424242424242424242 h43434343434343434343434343434343434343434343434343434343434343434343434343434343434343434343434343434343434343434343434343434343434343 h4444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444 h454545454545454545454545454545454545454545454545454545454545454545454545454545454545454545454545454545454545454545454545454545454545454545 largeattr
    clickamp
    waitForTextcharacter-outputtext & stuff
    clicklt
    waitForTextcharacter-outputtext < stuff
    clickgt
    waitForTextcharacter-outputtext > stuff
    clickendcdata
    waitForTextcharacter-outputbefore ]]> after
    clickattr-amp
    waitForAttributecharacter-attr-output at titletext & stuff
    verifyAttributecharacter-attr-output at titletext & stuff
    clickattr-lt
    waitForAttributecharacter-attr-output at titletext < stuff
    verifyAttributecharacter-attr-output at titletext < stuff
    clickattr-gt
    waitForAttributecharacter-attr-output at titletext > stuff
    verifyAttributecharacter-attr-output at titletext > stuff
    clickattr-endcdata
    waitForAttributecharacter-attr-output at titlebefore ]]> after
    verifyAttributecharacter-attr-output at titlebefore ]]> after
    + + Modified: kukit/kss.core/trunk/kss/core/tests/kukitresponse_test.pt ============================================================================== --- kukit/kss.core/trunk/kss/core/tests/kukitresponse_test.pt (original) +++ kukit/kss.core/trunk/kss/core/tests/kukitresponse_test.pt Sun Jan 6 15:24:58 2008 @@ -1,5 +1,5 @@ - Modified: kukit/kss.core/trunk/kss/core/tests/test_browserview.py ============================================================================== --- kukit/kss.core/trunk/kss/core/tests/test_browserview.py (original) +++ kukit/kss.core/trunk/kss/core/tests/test_browserview.py Sun Jan 6 15:24:58 2008 @@ -31,7 +31,7 @@ header = response.getHeader('x-ksscommands') self.assert_('the_&lt;&gt;message' in header) # no < > in the message self.assert_('\n' not in header) # no /n in the payload: would destroy the page - self.assertEqual(header, ' \t \t\tsystem \t\tTheError: the_&lt;&gt;message \t ') + self.assertEqual(header, ' \t \t\tsystem \t\tTheError: the_&lt;&gt;message \t ') def test_suite(): suites = [] Modified: kukit/kss.core/trunk/kss/core/tests/test_kssview_core.py ============================================================================== --- kukit/kss.core/trunk/kss/core/tests/test_kssview_core.py (original) +++ kukit/kss.core/trunk/kss/core/tests/test_kssview_core.py Sun Jan 6 15:24:58 2008 @@ -100,7 +100,7 @@ def _wrapped_commands(self, inline): header = textwrap.dedent(u'''\ - + ''') footer = textwrap.dedent('''\ From reebalazs at codespeak.net Sun Jan 6 17:08:10 2008 From: reebalazs at codespeak.net (reebalazs at codespeak.net) Date: Sun, 6 Jan 2008 17:08:10 +0100 (CET) Subject: [KSS-checkins] r50392 - in kukit/kukit.js/branch/ree-service-layer-and-refactoring: . tests Message-ID: <20080106160810.B72EE168476@codespeak.net> Author: reebalazs Date: Sun Jan 6 17:08:09 2008 New Revision: 50392 Modified: kukit/kukit.js/branch/ree-service-layer-and-refactoring/ (props changed) kukit/kukit.js/branch/ree-service-layer-and-refactoring/tests/test_errors.js Log: Make each test that can only run in development mode, pass green in production mode, rather then adding the testcase conditionally. Modified: kukit/kukit.js/branch/ree-service-layer-and-refactoring/tests/test_errors.js ============================================================================== --- kukit/kukit.js/branch/ree-service-layer-and-refactoring/tests/test_errors.js (original) +++ kukit/kukit.js/branch/ree-service-layer-and-refactoring/tests/test_errors.js Sun Jan 6 17:08:09 2008 @@ -30,6 +30,10 @@ this.testCreateGenuineError = function() { // Create a genuine error message. // An error message of a given type can be created on the fly. + // + // This test can only run in development mode, pass otherwise. + if (! kukit.isDevelMode) {return;} + // var E = kukit.err.setErrorInfo(null, 'MyError', 'Something went wrong', {a:1, b:2}); // Check that error has the message this.assertEquals(E.message, 'MyError: Something went wrong'); @@ -40,7 +44,12 @@ }; this.testCreateErrorFromTxt = function() { + // Create a genuine error message. // Create an annotated error from text. + // + // This test can only run in development mode, pass otherwise. + if (! kukit.isDevelMode) {return;} + // // XXX this works but gives warning: this way we cannot preserve the traceback. var orig_txt = "Original error"; var E = kukit.err.setErrorInfo(orig_txt, 'MyError', 'Something went wrong', {a:1, b:2}); @@ -54,7 +63,12 @@ }; this.testCreateErrorFromRawError = function() { + // Create a genuine error message. // Create an annotated error from a raw, unannorated error. + // + // This test can only run in development mode, pass otherwise. + if (! kukit.isDevelMode) {return;} + // var orig_err = new Error("Original error"); var E = kukit.err.setErrorInfo(orig_err, 'MyError', 'Something went wrong', {a:1, b:2}); // Check that error has the message @@ -67,9 +81,14 @@ }; this.testCreateErrorFromAnnotatedError = function() { + // Create a genuine error message. // Create an error from an annotated error message. // this message is a genuine error created by us // create chain of errors + // + // This test can only run in development mode, pass otherwise. + if (! kukit.isDevelMode) {return;} + // var orig_err = kukit.err.setErrorInfo(null, 'MyError', 'Something went wrong', {a:1, b:2}); var E = kukit.err.setErrorInfo(orig_err, 'YourError', 'Wrong here too', {a:2, b:3}); // Check that error has the message @@ -82,9 +101,14 @@ }; this.testCreateErrorFromAnnotatedError2 = function() { + // Create a genuine error message. // Create an error from an annotated error message. // this message is a string error // create chain of errors + // + // This test can only run in development mode, pass otherwise. + if (! kukit.isDevelMode) {return;} + // var orig_txt = "Original error"; var err1 = kukit.err.setErrorInfo(orig_txt, 'MyError', 'Something went wrong', {a:1, b:2}); var E = kukit.err.setErrorInfo(err1, 'YourError', 'Wrong here too', {a:2, b:3}); @@ -99,9 +123,14 @@ }; this.testCreateErrorFromAnnotatedError3 = function() { + // Create a genuine error message. // Create an error from an annotated error message. // This message is an unannotated error object // create chain of errors + // + // This test can only run in development mode, pass otherwise. + if (! kukit.isDevelMode) {return;} + // var orig_err = new Error("Original error"); var err1 = kukit.err.setErrorInfo(orig_err, 'MyError', 'Something went wrong', {a:1, b:2}); var E = kukit.err.setErrorInfo(err1, 'YourError', 'Wrong here too', {a:2, b:3}); @@ -116,8 +145,13 @@ }; this.testCreateErrorManyLevels = function() { + // Create a genuine error message. // Many levels together // create chain of errors + // + // This test can only run in development mode, pass otherwise. + if (! kukit.isDevelMode) {return;} + // var orig_err = new Error("Original error"); var err1 = kukit.err.setErrorInfo(orig_err, 'Error1', 'Wrong 1', {a:1, b:2}); var err2 = kukit.err.setErrorInfo(err1, 'Error2', 'Wrong 2', {a:2, b:3}); @@ -138,18 +172,10 @@ this.assertDictEquals(E.info.kw, {a:5, b:6}); }; - - - - }; kukit.ErrorsTestCase.prototype = new kukit.UtilsTestCaseBase; if (typeof(testcase_registry) != 'undefined') { - // Only add these tests for development mode - // (For the console, they are added elsewhere permanently.) - if (kukit.isDevelMode) { - testcase_registry.registerTestCase(kukit.ErrorsTestCase, 'kukit.ErrorsTestCase'); - } + testcase_registry.registerTestCase(kukit.ErrorsTestCase, 'kukit.ErrorsTestCase'); } From reebalazs at codespeak.net Sun Jan 6 17:08:14 2008 From: reebalazs at codespeak.net (reebalazs at codespeak.net) Date: Sun, 6 Jan 2008 17:08:14 +0100 (CET) Subject: [KSS-checkins] r50393 - in kukit/kukit.js/branch/ree-service-layer-and-refactoring: . tests Message-ID: <20080106160814.5AE091684D0@codespeak.net> Author: reebalazs Date: Sun Jan 6 17:08:13 2008 New Revision: 50393 Modified: kukit/kukit.js/branch/ree-service-layer-and-refactoring/ (props changed) kukit/kukit.js/branch/ree-service-layer-and-refactoring/tests/test_tokenizer.js Log: Fix the ecma test testException itself, to run on IE All ecma is green on IE6, and Safari 3.0.3 Modified: kukit/kukit.js/branch/ree-service-layer-and-refactoring/tests/test_tokenizer.js ============================================================================== --- kukit/kukit.js/branch/ree-service-layer-and-refactoring/tests/test_tokenizer.js (original) +++ kukit/kukit.js/branch/ree-service-layer-and-refactoring/tests/test_tokenizer.js Sun Jan 6 17:08:13 2008 @@ -105,26 +105,19 @@ } catch(e) { exc = e; } + // It is pointless to test for exc.toString(), first IE returns the constant + // '[object Error]' in some versions, then it is not really important + // for us since we use our own annotation info anyway. this.assertNotEquals(exc, null); this.assertEquals(exc.name, 'ParsingError'); - // test here under tries to discriminate IE - // it does work for IE 6.0.2900.2180.xpsp_sp2 - // it does not work at least for IE 6.0.2800.1106 - if (typeof(exc.number) == 'number') { - // IE - this.assertEquals(exc.description, 'ParsingError: Error happened'); - this.assertEquals(exc.info.message, 'Error happened'); - } else { - // toString result is browser dependent. - // colon in FF - // dash in Safari - // reason for the indexOf below - var toString = exc.toString(); - this.assertTrue(toString.indexOf('ParsingError') != -1, '"ParsingError" not in toString() : ' + toString); - this.assertTrue(toString.indexOf('Error happened') != -1, '"Error happened" not in toString() : ' + toString); - this.assertEquals(exc.message, 'ParsingError: Error happened'); - this.assertEquals(exc.info.message, 'Error happened'); - }; + // exc.description is needed for IE, + // ... exc.message is for all W3C compliant browsers. + this.assert(exc.message =='ParsingError: Error happened' || + exc.description == 'ParsingError: Error happened'); + // Most important is to have the annotation info, + // since we use this for logging and testing: + this.assertEquals(exc.info.message, 'Error happened'); + // check positions this.assertEquals(exc.errpos, null); this.assertEquals(exc.errrow, null); this.assertEquals(exc.errcol, null); @@ -143,24 +136,19 @@ } this.assertNotEquals(exc, null); this.assertEquals(exc.name, 'ParsingError'); - // test here under tries to discriminate IE - // it does work for IE 6.0.2900.2180.xpsp_sp2 - // it does not work at least for IE 6.0.2800.1106 - if (typeof(exc.number) == 'number') { - // IE - this.assertEquals(exc.description, 'ParsingError: Error happened, at row 3, column 4'); - this.assertEquals(exc.info.message, 'Error happened, at row 3, column 4'); - } else { - // toString result is browser dependent. - // colon in FF - // dash in Safari - // reason for the indexOf below - var toString = exc.toString(); - this.assertTrue(toString.indexOf('ParsingError') != -1, '"ParsingError" not in toString() : ' + toString); - this.assertTrue(toString.indexOf('Error happened, at row 3, column 4') != -1, '"Error happened, at row 3, column 4" not in toString() : ' + toString); - this.assertEquals(exc.message, 'ParsingError: Error happened, at row 3, column 4'); - this.assertEquals(exc.info.message, 'Error happened, at row 3, column 4'); - }; + // It is pointless to test for exc.toString(), first IE returns the constant + // '[object Error]' in some versions, then it is not really important + // for us since we use our own annotation info anyway. + this.assertNotEquals(exc, null); + this.assertEquals(exc.name, 'ParsingError'); + // exc.description is needed for IE, + // ... exc.message is for all W3C compliant browsers. + this.assert(exc.message == 'ParsingError: Error happened, at row 3, column 4' || + exc.description == 'Error happened'); + // Most important is to have the annotation info, + // since we use this for logging and testing: + this.assertEquals(exc.info.message, 'Error happened, at row 3, column 4'); + // check positions this.assertEquals(exc.info.kw.errpos, 13); this.assertEquals(exc.info.kw.errrow, 3); this.assertEquals(exc.info.kw.errcol, 4); From reebalazs at codespeak.net Sun Jan 6 17:19:25 2008 From: reebalazs at codespeak.net (reebalazs at codespeak.net) Date: Sun, 6 Jan 2008 17:19:25 +0100 (CET) Subject: [KSS-checkins] r50395 - in kukit/kukit.js/branch/ree-1.4-markup-and-syntax-changes: . kukit tests Message-ID: <20080106161925.BE7DC168477@codespeak.net> Author: reebalazs Date: Sun Jan 6 17:19:25 2008 New Revision: 50395 Modified: kukit/kukit.js/branch/ree-1.4-markup-and-syntax-changes/ (props changed) kukit/kukit.js/branch/ree-1.4-markup-and-syntax-changes/kukit/kssparser.js kukit/kukit.js/branch/ree-1.4-markup-and-syntax-changes/tests/test_kssparser.js Log: Remove PropValueInMethod: it's not used or needed any more Modified: kukit/kukit.js/branch/ree-1.4-markup-and-syntax-changes/kukit/kssparser.js ============================================================================== --- kukit/kukit.js/branch/ree-1.4-markup-and-syntax-changes/kukit/kssparser.js (original) +++ kukit/kukit.js/branch/ree-1.4-markup-and-syntax-changes/kukit/kssparser.js Sun Jan 6 17:19:25 2008 @@ -446,29 +446,6 @@ }; /* -* class PropValueInMethod -* -* PropValue in method cannot have method-style vars. -*/ -kukit.kssp.PropValueInMethod = kukit.tk.mkParser('propValue', { - ";": 'this.emitAndReturn()', - "}": 'this.emitAndReturn()', - ")": 'this.emitAndReturn()', - "]": 'this.emitAndReturn()', - ",": 'this.emitAndReturn()', - "'": 'new kukit.kssp.String(this.cursor, kukit.kssp.quote)', - '"': 'new kukit.kssp.String2(this.cursor, kukit.kssp.dquote)', - "\/\*": 'new kukit.kssp.Comment(this.cursor, kukit.kssp.openComment)' - }); -kukit.kssp.PropValueInMethod.prototype.multiword_allowed = false; -kukit.kssp.PropValueInMethod.prototype.process = - kukit.kssp.PropValue.prototype.process; -kukit.kssp.PropValueInMethod.prototype.produceTxt = function(txt) { - // txt parms are returned unwrapped - this.txt = txt; -}; - -/* * class EventValue * * PropValue in pseudo must be single word with no spaces around. Modified: kukit/kukit.js/branch/ree-1.4-markup-and-syntax-changes/tests/test_kssparser.js ============================================================================== --- kukit/kukit.js/branch/ree-1.4-markup-and-syntax-changes/tests/test_kssparser.js (original) +++ kukit/kukit.js/branch/ree-1.4-markup-and-syntax-changes/tests/test_kssparser.js Sun Jan 6 17:19:25 2008 @@ -69,89 +69,6 @@ kukit.KssParserTestCase = function() { this.name = 'kukit.KssParserTestCase'; - this.testPropvalueInMethod = function() { - // Parsing prop values (no methods allowed) - var txt= "apple;"; - var cursor = new kukit.tk.Cursor(txt); - var parser = new kukit.kssp.PropValueInMethod(cursor, null, true); - this.assertEquals(parser.finished, true); - this.assertEquals(parser.txt, 'apple'); - - txt= "'a string';"; - cursor = new kukit.tk.Cursor(txt); - parser = new kukit.kssp.PropValueInMethod(cursor, null, true); - this.assertEquals(parser.finished, true); - this.assertEquals(parser.txt, 'a string'); - - txt= '"a string";'; - cursor = new kukit.tk.Cursor(txt); - parser = new kukit.kssp.PropValueInMethod(cursor, null, true); - this.assertEquals(parser.finished, true); - this.assertEquals(parser.txt, 'a string'); - - txt= '"a \\"string";'; - cursor = new kukit.tk.Cursor(txt); - parser = new kukit.kssp.PropValueInMethod(cursor, null, true); - this.assertEquals(parser.finished, true); - this.assertEquals(parser.txt, 'a "string'); - - txt= " /* valid */ 'a string' /* here*/ /*and*/ /*there*/;"; - cursor = new kukit.tk.Cursor(txt); - parser = new kukit.kssp.PropValueInMethod(cursor, null, true); - this.assertEquals(parser.finished, true); - this.assertEquals(parser.txt, 'a string'); - - txt= " in /* valid */ 'a string';"; - cursor = new kukit.tk.Cursor(txt); - this.assertParsingError(kukit.kssp.PropValueInMethod, cursor, null, true, 'Wrong value : unallowed characters [in] before a string.'); - - txt= " 'a string' trashy;"; - cursor = new kukit.tk.Cursor(txt); - this.assertParsingError(kukit.kssp.PropValueInMethod, cursor, null, true, 'Wrong value : unallowed characters after the property.'); - - txt= " 'a string' trashy \"trishy\";"; - cursor = new kukit.tk.Cursor(txt); - this.assertParsingError(kukit.kssp.PropValueInMethod, cursor, null, true, 'Wrong value : unallowed characters after the property.'); - - // multiword not ok - txt= "b c"; - cursor = new kukit.tk.Cursor(txt); - this.assertParsingError(kukit.kssp.PropValueInMethod, cursor, null, true, - 'Wrong value : [b c] cannot have spaces.', 5); - - txt= " apples and oranges ;"; - cursor = new kukit.tk.Cursor(txt); - this.assertParsingError(kukit.kssp.PropValueInMethod, cursor, null, true, - 'Wrong value : [apples and oranges] cannot have spaces.', 25); - - txt= " /* comments; */ apples and /* more comments and*/ oranges ;"; - cursor = new kukit.tk.Cursor(txt); - this.assertParsingError(kukit.kssp.PropValueInMethod, cursor, null, true, - //'Wrong value : [/* comments; */ ap