use of com.vaadin.flow.template.angular.InlineTemplate in project flow by vaadin.
the class ElementUtilTest method includesScriptTags.
@Test
public void includesScriptTags() {
InlineTemplate template = new InlineTemplate("<div><script>window.alert('shazbot');</script></div>");
Node jsoupNode = ElementUtil.toJsoup(new Document(""), template.getElement());
Assert.assertEquals(1, jsoupNode.childNodeSize());
Node child = jsoupNode.childNode(0);
Assert.assertEquals("<script>window.alert('shazbot');</script>", child.outerHtml());
}
use of com.vaadin.flow.template.angular.InlineTemplate in project flow by vaadin.
the class EventRpcHandlerTest method templateChildElementEventListener.
@Test
public void templateChildElementEventListener() throws Exception {
UI ui = new UI();
AngularTemplate t = new InlineTemplate("<root><child></child></root>");
Element element = t.getElement().getChild(0);
ui.add(t);
AtomicInteger invoked = new AtomicInteger(0);
element.addEventListener("test-event", e -> {
invoked.incrementAndGet();
});
sendElementEvent(element, ui, "test-event", null);
Assert.assertEquals(1, invoked.get());
}
use of com.vaadin.flow.template.angular.InlineTemplate in project flow by vaadin.
the class EventRpcHandlerTest method templateRootElementEventListener.
@Test
public void templateRootElementEventListener() throws Exception {
UI ui = new UI();
AngularTemplate t = new InlineTemplate("<root><child></child></root>");
Element element = t.getElement();
ui.add(t);
AtomicInteger invoked = new AtomicInteger(0);
element.addEventListener("test-event", e -> {
invoked.incrementAndGet();
});
sendElementEvent(element, ui, "test-event", null);
Assert.assertEquals(1, invoked.get());
}
Aggregations