WebComponentBootstrapHandler extends BootstrapHandler { private void writeBootstrapPage(VaadinResponse response, Element head, String serviceUrl) throws IOException { writeBootstrapPage(CONTENT_TYPE_TEXT_JAVASCRIPT_UTF_8, response, head, serviceUrl); } WebComponentBootstrapHandler(); protected  WebComponentBootstrapHandler(PageBuilder pageBuilder); @Override boolean synchronizedHandleRequest(VaadinSession session,
            VaadinRequest request, VaadinResponse response);  }
@Test public void writeBootstrapPage_skipMetaAndStyleHeaderElements() throws IOException { WebComponentBootstrapHandler handler = new WebComponentBootstrapHandler(); ByteArrayOutputStream stream = new ByteArrayOutputStream(); Element head = new Document("").normalise().head(); Element meta = head.ownerDocument().createElement("meta"); head.appendChild(meta); meta.attr("http-equiv", "Content-Type"); Element style = head.ownerDocument().createElement("style"); head.appendChild(style); style.attr("type", "text/css"); style.text("body {height:100vh;width:100vw;margin:0;}"); Element script = head.ownerDocument().createElement("script"); head.appendChild(script); script.text("var i=1;"); VaadinResponse response = getMockResponse(stream); handler.writeBootstrapPage("", response, head, ""); String resultingScript = stream.toString(StandardCharsets.UTF_8.name()); Assert.assertThat(resultingScript, CoreMatchers.containsString("var i=1;")); Assert.assertThat(resultingScript, CoreMatchers.not(CoreMatchers .containsString("body {height:100vh;width:100vw;margin:0;}"))); Assert.assertThat(resultingScript, CoreMatchers.not(CoreMatchers.containsString("http-equiv"))); }
@Test public void writeBootstrapPage_spepe() throws Exception { WebComponentBootstrapHandler handler = new WebComponentBootstrapHandler(); ByteArrayOutputStream stream = new ByteArrayOutputStream(); Element head = new Document("").normalise().head(); VaadinResponse response = getMockResponse(stream); handler.writeBootstrapPage("", response, head, ""); String resultingScript = stream.toString(StandardCharsets.UTF_8.name()); System.err.println(resultingScript); }