-
Notifications
You must be signed in to change notification settings - Fork 168
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: use textContent instead of innerHTML for error elements (#11354)
Fixes #11324
- Loading branch information
Denis
committed
Jun 30, 2021
1 parent
422648a
commit 5cb2045
Showing
3 changed files
with
73 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
64 changes: 64 additions & 0 deletions
64
flow-client/src/test-gwt/java/com/vaadin/client/flow/GwtErrotHandlerTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
/* | ||
* Copyright 2000-2021 Vaadin Ltd. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); you may not | ||
* use this file except in compliance with the License. You may obtain a copy of | ||
* the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT | ||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the | ||
* License for the specific language governing permissions and limitations under | ||
* the License. | ||
*/ | ||
package com.vaadin.client.flow; | ||
|
||
import com.vaadin.client.ApplicationConfiguration; | ||
import com.vaadin.client.ClientEngineTestBase; | ||
import com.vaadin.client.Registry; | ||
import com.vaadin.client.SystemErrorHandler; | ||
import com.vaadin.client.flow.reactive.Reactive; | ||
|
||
import elemental.client.Browser; | ||
import elemental.dom.Element; | ||
|
||
public class GwtErrotHandlerTest extends ClientEngineTestBase { | ||
|
||
private Registry registry; | ||
|
||
@Override | ||
protected void gwtSetUp() throws Exception { | ||
super.gwtSetUp(); | ||
Reactive.reset(); | ||
|
||
registry = new Registry() { | ||
{ | ||
set(ApplicationConfiguration.class, | ||
new ApplicationConfiguration()); | ||
set(SystemErrorHandler.class, new SystemErrorHandler(this)); | ||
} | ||
}; | ||
|
||
} | ||
|
||
public void testhandleUnrecoverableError_textContentIsSetInDivsNotInnerHtml() { | ||
registry.getSystemErrorHandler().handleUnrecoverableError("<foo></foo>", | ||
"<bar></bar>", "<baz></baz>", null); | ||
Element container = Browser.getDocument().getBody() | ||
.querySelector(".v-system-error"); | ||
Element caption = container.querySelector(".caption"); | ||
Element message = container.querySelector(".message"); | ||
Element details = container.querySelector(".details"); | ||
|
||
assertEquals("<foo></foo>", caption.getInnerHTML()); | ||
assertEquals("<foo></foo>", caption.getTextContent()); | ||
|
||
assertEquals("<bar></bar>", message.getInnerHTML()); | ||
assertEquals("<bar></bar>", message.getTextContent()); | ||
|
||
assertEquals("<baz></baz>", details.getInnerHTML()); | ||
assertEquals("<baz></baz>", details.getTextContent()); | ||
} | ||
} |