|
| 1 | +/* |
| 2 | + * Copyright 2000-2021 Vaadin Ltd. |
| 3 | + * |
| 4 | + * Licensed under the Apache License, Version 2.0 (the "License"); you may not |
| 5 | + * use this file except in compliance with the License. You may obtain a copy of |
| 6 | + * the License at |
| 7 | + * |
| 8 | + * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | + * |
| 10 | + * Unless required by applicable law or agreed to in writing, software |
| 11 | + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT |
| 12 | + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the |
| 13 | + * License for the specific language governing permissions and limitations under |
| 14 | + * the License. |
| 15 | + */ |
| 16 | +package com.vaadin.client.flow; |
| 17 | + |
| 18 | +import com.vaadin.client.ApplicationConfiguration; |
| 19 | +import com.vaadin.client.ClientEngineTestBase; |
| 20 | +import com.vaadin.client.Registry; |
| 21 | +import com.vaadin.client.SystemErrorHandler; |
| 22 | +import com.vaadin.client.flow.reactive.Reactive; |
| 23 | + |
| 24 | +import elemental.client.Browser; |
| 25 | +import elemental.dom.Element; |
| 26 | + |
| 27 | +public class GwtErrotHandlerTest extends ClientEngineTestBase { |
| 28 | + |
| 29 | + private Registry registry; |
| 30 | + |
| 31 | + @Override |
| 32 | + protected void gwtSetUp() throws Exception { |
| 33 | + super.gwtSetUp(); |
| 34 | + Reactive.reset(); |
| 35 | + |
| 36 | + registry = new Registry() { |
| 37 | + { |
| 38 | + set(ApplicationConfiguration.class, |
| 39 | + new ApplicationConfiguration()); |
| 40 | + set(SystemErrorHandler.class, new SystemErrorHandler(this)); |
| 41 | + } |
| 42 | + }; |
| 43 | + |
| 44 | + } |
| 45 | + |
| 46 | + public void testhandleUnrecoverableError_textContentIsSetInDivsNotInnerHtml() { |
| 47 | + registry.getSystemErrorHandler().handleUnrecoverableError("<foo></foo>", |
| 48 | + "<bar></bar>", "<baz></baz>", null); |
| 49 | + Element container = Browser.getDocument().getBody() |
| 50 | + .querySelector(".v-system-error"); |
| 51 | + Element caption = container.querySelector(".caption"); |
| 52 | + Element message = container.querySelector(".message"); |
| 53 | + Element details = container.querySelector(".details"); |
| 54 | + |
| 55 | + assertEquals("<foo></foo>", caption.getInnerHTML()); |
| 56 | + assertEquals("<foo></foo>", caption.getTextContent()); |
| 57 | + |
| 58 | + assertEquals("<bar></bar>", message.getInnerHTML()); |
| 59 | + assertEquals("<bar></bar>", message.getTextContent()); |
| 60 | + |
| 61 | + assertEquals("<baz></baz>", details.getInnerHTML()); |
| 62 | + assertEquals("<baz></baz>", details.getTextContent()); |
| 63 | + } |
| 64 | +} |
0 commit comments