diff options
author | Aleksi Hietanen <aleksi@vaadin.com> | 2017-04-19 10:33:01 +0300 |
---|---|---|
committer | Henri Sara <henri.sara@gmail.com> | 2017-04-19 10:33:01 +0300 |
commit | 2d9fb530cced8a4329a57293d308760b424af067 (patch) | |
tree | 79c2c59da668bd0786083b718abf2866544033c0 /uitest/src/main | |
parent | de63e1f36a479b9fdbf7faff5b96aa75745f5970 (diff) | |
download | vaadin-framework-2d9fb530cced8a4329a57293d308760b424af067.tar.gz vaadin-framework-2d9fb530cced8a4329a57293d308760b424af067.zip |
Fix client-side memory leak caused by Grid events (#9062)
Refactors AbstractGridKeyEvent, AbstractGridMouseEvent and their
descendants to follow the pattern used in other GWT DomEvents.
Fixes #7633
Diffstat (limited to 'uitest/src/main')
-rw-r--r-- | uitest/src/main/java/com/vaadin/tests/components/grid/GridClientMemoryLeak.java | 49 |
1 files changed, 49 insertions, 0 deletions
diff --git a/uitest/src/main/java/com/vaadin/tests/components/grid/GridClientMemoryLeak.java b/uitest/src/main/java/com/vaadin/tests/components/grid/GridClientMemoryLeak.java new file mode 100644 index 0000000000..3db4d003e4 --- /dev/null +++ b/uitest/src/main/java/com/vaadin/tests/components/grid/GridClientMemoryLeak.java @@ -0,0 +1,49 @@ +package com.vaadin.tests.components.grid; + +import com.vaadin.server.VaadinRequest; +import com.vaadin.shared.ui.label.ContentMode; +import com.vaadin.tests.components.AbstractTestUI; +import com.vaadin.ui.Button; +import com.vaadin.ui.Button.ClickEvent; +import com.vaadin.ui.Grid; +import com.vaadin.ui.Label; +import com.vaadin.ui.VerticalLayout; + +public class GridClientMemoryLeak extends AbstractTestUI { + + private static final String INSTRUCTIONS = "This UI is for manually testing that the client side grid does not leak memory. " + + "Steps to take:\n" + + "\t1. Click the newGrid button 1-n times\n" + + "\t2. Capture a JS heap dump in your browser\n" + + "\t3. The heap dump should only contain 1 instance of each of the following:\n" + + "\t\tGrid, GridKeyDownEvent, GridKeyPressEvent, GridKeyUpEvent, GridClickEvent, GridDoubleClickEvent"; + + @Override + protected void setup(VaadinRequest request) { + final Label instructionLabel = new Label(INSTRUCTIONS, + ContentMode.PREFORMATTED); + final VerticalLayout layout = new VerticalLayout(); + final Button btn = new Button("newGrid"); + btn.addClickListener(new Button.ClickListener() { + + @Override + public void buttonClick(ClickEvent event) { + layout.removeComponent(layout.getComponent(1)); + layout.addComponent(grid()); + } + }); + layout.addComponent(instructionLabel); + layout.addComponent(btn); + layout.addComponent(grid()); + addComponent(layout); + } + + private Grid grid() { + Grid grid = new Grid(); + grid.addColumn("col1", String.class); + grid.addColumn("col2", String.class); + grid.addRow("a", "b" + System.currentTimeMillis()); + grid.addRow("d", "e"); + return grid; + } +} |