From ccdcae184d237c366db3a87328a90e573daab881 Mon Sep 17 00:00:00 2001 From: divdavem Date: Wed, 13 Sep 2017 18:14:57 +0200 Subject: [PATCH] feat #1775 new ariaLive parameter on the aria:ErrorList widget This new ariaLive parameter allows to specify whether role="alert" and aria-live="assertive" are included (true) or omitted (false) on the container element of the aria:ErrorList widget (defaults to true, only used if waiAria is true) close #1775 PTR 12238923 --- src/aria/widgets/CfgBeans.js | 5 ++ src/aria/widgets/errorlist/ErrorList.js | 2 +- .../errorlist/binding/ErrorListBindingCtrl.js | 11 ++- .../binding/ErrorListBindingJawsTestCase.js | 2 - .../errorlist/binding/ErrorListBindingTpl.tpl | 1 + .../ErrorListNoAriaLiveJawsTestCase.js | 86 +++++++++++++++++++ 6 files changed, 102 insertions(+), 5 deletions(-) create mode 100644 test/aria/widgets/wai/errorlist/binding/ErrorListNoAriaLiveJawsTestCase.js diff --git a/src/aria/widgets/CfgBeans.js b/src/aria/widgets/CfgBeans.js index 2e25d6e13..866432c50 100644 --- a/src/aria/widgets/CfgBeans.js +++ b/src/aria/widgets/CfgBeans.js @@ -1656,6 +1656,11 @@ module.exports = Aria.beanDefinitions({ $type : "json:Boolean", $description : "Set this bindable property to true to put the focus on the first item. As soon as the focus has been set, the property will be set back to false.", $default : false + }, + "ariaLive" : { + $type : "json:Boolean", + $description : "Specifies whether role=alert and aria-live=assertive are included (true) or omitted (false) on the container element (defaults to true, only used if waiAria is true)", + $default : true } } }, diff --git a/src/aria/widgets/errorlist/ErrorList.js b/src/aria/widgets/errorlist/ErrorList.js index 42f0a7957..f227ac022 100644 --- a/src/aria/widgets/errorlist/ErrorList.js +++ b/src/aria/widgets/errorlist/ErrorList.js @@ -44,7 +44,7 @@ module.exports = Aria.classDefinition({ divCfg.margins = "0 0 0 0"; divCfg.id = cfg.id + "_div"; - if (cfg.waiAria) { + if (cfg.waiAria && cfg.ariaLive) { this._extraAttributes = ' role="alert" aria-live="assertive" '; } diff --git a/test/aria/widgets/wai/errorlist/binding/ErrorListBindingCtrl.js b/test/aria/widgets/wai/errorlist/binding/ErrorListBindingCtrl.js index 4299a25b9..3ddbec464 100644 --- a/test/aria/widgets/wai/errorlist/binding/ErrorListBindingCtrl.js +++ b/test/aria/widgets/wai/errorlist/binding/ErrorListBindingCtrl.js @@ -12,7 +12,8 @@ Aria.classDefinition({ phoneNumber : "", email : "", errorMessages : [], - focus: false + focus: false, + focusOnError: true }; this.myDataUtil = aria.utils.Data; this.validators = []; @@ -30,6 +31,12 @@ Aria.classDefinition({ $publicInterfaceName : "test.aria.widgets.wai.errorlist.binding.IErrorListBindingCtrl", init : function (arg, cb) { var validatorPkg = aria.utils.validators; + if ("ariaLive" in arg) { + this.json.setValue(this._data, "ariaLive", arg.ariaLive); + } + if ("focusOnError" in arg) { + this.json.setValue(this._data, "focusOnError", arg.focusOnError); + } var firstNameValidator = new validatorPkg.Mandatory("The first name is a required field using a mandatory validator."); this.myDataUtil.setValidatorProperties(firstNameValidator, null, "onblur"); @@ -58,7 +65,7 @@ Aria.classDefinition({ var messages = {}; this.myDataUtil.validateModel(this._data, messages); this.json.setValue(this._data, "errorMessages", messages.listOfMessages); - if (messages.listOfMessages && messages.listOfMessages.length) { + if (messages.listOfMessages && messages.listOfMessages.length && this._data.focusOnError) { this.json.setValue(this._data, "focus", true); } } diff --git a/test/aria/widgets/wai/errorlist/binding/ErrorListBindingJawsTestCase.js b/test/aria/widgets/wai/errorlist/binding/ErrorListBindingJawsTestCase.js index 4394a548e..eaa4a66fb 100644 --- a/test/aria/widgets/wai/errorlist/binding/ErrorListBindingJawsTestCase.js +++ b/test/aria/widgets/wai/errorlist/binding/ErrorListBindingJawsTestCase.js @@ -34,8 +34,6 @@ module.exports = Aria.classDefinition({ // ------------------------------------ template data & test environment - var type = dataUtils.TYPE_CONFIRMATION; - this.setTestEnv({ template : "test.aria.widgets.wai.errorlist.binding.ErrorListBindingTpl", moduleCtrl : { diff --git a/test/aria/widgets/wai/errorlist/binding/ErrorListBindingTpl.tpl b/test/aria/widgets/wai/errorlist/binding/ErrorListBindingTpl.tpl index 7869bb541..41e28da51 100644 --- a/test/aria/widgets/wai/errorlist/binding/ErrorListBindingTpl.tpl +++ b/test/aria/widgets/wai/errorlist/binding/ErrorListBindingTpl.tpl @@ -11,6 +11,7 @@ margins: "10 1 10 1", title: "Error", filterTypes: ['E'], + ariaLive: data.ariaLive, bind: { messages: { to: "errorMessages", diff --git a/test/aria/widgets/wai/errorlist/binding/ErrorListNoAriaLiveJawsTestCase.js b/test/aria/widgets/wai/errorlist/binding/ErrorListNoAriaLiveJawsTestCase.js new file mode 100644 index 000000000..347e7a59b --- /dev/null +++ b/test/aria/widgets/wai/errorlist/binding/ErrorListNoAriaLiveJawsTestCase.js @@ -0,0 +1,86 @@ +/* + * Copyright 2013 Amadeus s.a.s. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +var Aria = require("ariatemplates/Aria"); + +var dataUtils = require("ariatemplates/utils/Data"); + +var JawsTestCase = require("ariatemplates/jsunit/JawsTestCase"); +var AppEnvironment = require("ariatemplates/core/AppEnvironment"); + +require("ariatemplates/utils/validators/CfgBeans"); // just to make sure it is correctly defined +require("ariatemplates/widgets/errorlist/ErrorListTemplate.tpl"); // just to be sure the template is loaded when the test is run, since it depends on its (DOM) content + +module.exports = Aria.classDefinition({ + $classpath : "test.aria.widgets.wai.errorlist.binding.ErrorListNoAriaLiveJawsTestCase", + $extends : JawsTestCase, + + $constructor : function() { + // --------------------------------------------------------------------- + + this.$JawsTestCase.constructor.call(this); + + // ------------------------------------ template data & test environment + + this.setTestEnv({ + template : "test.aria.widgets.wai.errorlist.binding.ErrorListBindingTpl", + moduleCtrl : { + classpath : 'test.aria.widgets.wai.errorlist.binding.ErrorListBindingCtrl', + initArgs: { + ariaLive : false, + focusOnError : false + } + } + }); + + this.noiseRegExps.push(/\\$/, /^Email Address:$/i); + }, + + $prototype : { + run : function () { + AppEnvironment.setEnvironment({ + appSettings: { + waiAria: true + } + }, { + scope: this, + fn: this.$JawsTestCase.run + }); + }, + + runTemplateTest : function () { + this.synEvent.execute([ + ["click", this.getInputField("email")], + ["pause", 1000], + ["type", null, "[down][down]"], + ["pause", 1000], + ["type", null, "[space]"], + ["pause", 3000] // check that nothing is said when errors are displayed + ], { + fn: function () { + this.assertJawsHistoryEquals( + "Email Address: Edit\nType in text.\nSubmit Button", + this.end, + function filter(content) { + content = content.replace(/(Submit)\n(Button)/gi, '$1 $2'); + return content; + } + ); + }, + scope: this + }); + } + } +});