use of com.github.bordertech.wcomponents.WMenuItem in project wcomponents by BorderTech.
the class WMenuItemRenderer_Test method testXssEscaping.
@Test
public void testXssEscaping() throws IOException, SAXException, XpathException {
WMenu menu = new WMenu();
WMenuItem item = new WMenuItem(getMaliciousAttribute());
menu.add(item);
assertSafeContent(menu);
item.setToolTip(getMaliciousAttribute());
assertSafeContent(menu);
item.setAccessibleText(getMaliciousAttribute());
assertSafeContent(menu);
item.setUrl(getMaliciousAttribute());
assertSafeContent(menu);
}
use of com.github.bordertech.wcomponents.WMenuItem in project wcomponents by BorderTech.
the class WMenuItemRenderer_Test method testSelectability.
@Test
public void testSelectability() throws IOException, SAXException, XpathException {
// Selectability - output as @role
WMenuItem item = new WMenuItem(itemText);
WMenu wrapped = wrapMenuItem(item);
wrapped.setSelectionMode(MenuSelectContainer.SelectionMode.SINGLE);
// default selectability is selectable
assertXpathEvaluatesTo("menuitemradio", "//ui:menuitem/@role", item);
item = new WMenuItem(itemText);
wrapped.add(item);
item.setSelectability(Boolean.FALSE);
assertSchemaMatch(wrapped);
assertXpathNotExists("//ui:menuitem/@role", item);
item = new WMenuItem(itemText);
wrapped.add(item);
item.setSelectability(Boolean.TRUE);
assertSchemaMatch(wrapped);
assertXpathEvaluatesTo("menuitemradio", "//ui:menuitem/@role", item);
item = new WMenuItem(itemText);
wrapped = wrapMenuItem(item);
wrapped.setSelectionMode(MenuSelectContainer.SelectionMode.MULTIPLE);
// default selectability is selectable and so role is menuitemcheckbox
assertXpathEvaluatesTo("menuitemcheckbox", "//ui:menuitem/@role", item);
item = new WMenuItem(itemText);
wrapped.add(item);
item.setSelectability(Boolean.FALSE);
assertXpathNotExists("//ui:menuitem/@role", item);
item = new WMenuItem(itemText);
wrapped.add(item);
item.setSelectability(Boolean.TRUE);
assertXpathEvaluatesTo("menuitemcheckbox", "//ui:menuitem/@role", item);
}
use of com.github.bordertech.wcomponents.WMenuItem in project wcomponents by BorderTech.
the class WMenuItemRenderer_Test method testAccessKey.
@Test
public void testAccessKey() throws IOException, SAXException, XpathException {
// AccessKey
WMenuItem item = new WMenuItem(itemText, url);
WMenu wrapped = wrapMenuItem(item);
item.setAccessKey('A');
assertSchemaMatch(wrapped);
assertXpathEvaluatesTo("A", "//ui:menuitem/@accessKey", item);
// no access key if nested
WSubMenu sub = new WSubMenu("sub");
wrapped.add(sub);
item = new WMenuItem(itemText, url);
sub.add(item);
item.setAccessKey('A');
assertSchemaMatch(wrapped);
assertXpathNotExists("//ui:menuitem/@accessKey", item);
}
use of com.github.bordertech.wcomponents.WMenuItem in project wcomponents by BorderTech.
the class WMenuItemRenderer_Test method testHidden.
@Test
public void testHidden() throws IOException, SAXException, XpathException {
WMenuItem item = new WMenuItem(itemText, url);
WMenu wrapped = wrapMenuItem(item);
setFlag(item, ComponentModel.HIDE_FLAG, true);
assertSchemaMatch(wrapped);
assertXpathEvaluatesTo("true", "//ui:menuitem/@hidden", item);
}
use of com.github.bordertech.wcomponents.WMenuItem in project wcomponents by BorderTech.
the class WMenuItemRenderer_Test method testAction.
@Test
public void testAction() throws IOException, SAXException, XpathException {
// Test with action
WMenuItem item = new WMenuItem(itemText, new TestAction());
WMenu wrapped = wrapMenuItem(item);
assertSchemaMatch(wrapped);
assertXpathEvaluatesTo(itemText, "normalize-space(//ui:menuitem/ui:decoratedlabel)", item);
assertXpathNotExists("//ui:menuitem/@url", item);
assertXpathEvaluatesTo("true", "//ui:menuitem/@submit", item);
}
Aggregations