use of org.gwtproject.safehtml.shared.SafeHtmlBuilder in project gwtproject by treblereel.
the class I18N2Test method sh.
/**
* Wrapper to easily convert a String literal to a SafeHtml instance.
*
* @param string
* @return a SafeHtml wrapper around the supplied string
*/
private SafeHtml sh(String string) {
SafeHtmlBuilder buf = new SafeHtmlBuilder();
buf.appendHtmlConstant(string);
return buf.toSafeHtml();
}
use of org.gwtproject.safehtml.shared.SafeHtmlBuilder in project gwtproject by treblereel.
the class AbstractCell method setValue.
public void setValue(Context context, Element parent, C value) {
SafeHtmlBuilder sb = new SafeHtmlBuilder();
render(context, value, sb);
parent.setInnerSafeHtml(sb.toSafeHtml());
}
use of org.gwtproject.safehtml.shared.SafeHtmlBuilder in project gwtproject by treblereel.
the class EditTextCellTest method testRenderViewDataDoneEditing.
/**
* Test rendering the cell with a valid value and view data, but without
* editing.
*/
public void testRenderViewDataDoneEditing() {
EditTextCell cell = createCell();
ViewData viewData = new ViewData("originalValue");
viewData.setText("newValue");
viewData.setEditing(false);
cell.setViewData(DEFAULT_KEY, viewData);
SafeHtmlBuilder sb = new SafeHtmlBuilder();
Context context = new Context(0, 0, DEFAULT_KEY);
cell.render(context, "originalValue", sb);
assertEquals("newValue", sb.toSafeHtml().asString());
}
use of org.gwtproject.safehtml.shared.SafeHtmlBuilder in project gwtproject by treblereel.
the class EditTextCellTest method testRenderUnsafeHtml.
/**
* Test rendering the cell with a malicious value.
*/
public void testRenderUnsafeHtml() {
EditTextCell cell = createCell();
SafeHtmlBuilder sb = new SafeHtmlBuilder();
Context context = new Context(0, 0, null);
cell.render(context, "<script>malicious</script>", sb);
assertEquals("<script>malicious</script>", sb.toSafeHtml().asString());
}
use of org.gwtproject.safehtml.shared.SafeHtmlBuilder in project gwtproject by treblereel.
the class EditableCellTestBase method testRenderViewData.
/**
* Test rendering the cell with a valid value and view data.
*/
public void testRenderViewData() {
AbstractEditableCell<T, V> cell = createCell();
T value = createCellValue();
cell.setViewData(DEFAULT_KEY, createCellViewData());
SafeHtmlBuilder sb = new SafeHtmlBuilder();
Context context = new Context(0, 0, DEFAULT_KEY);
cell.render(context, value, sb);
String expectedInnerHtmlViewData = getExpectedInnerHtmlViewData();
String asString = sb.toSafeHtml().asString();
assertEquals(expectedInnerHtmlViewData, asString);
}
Aggregations