diff options
author | Artur Signell <artur.signell@itmill.com> | 2009-11-12 13:55:27 +0000 |
---|---|---|
committer | Artur Signell <artur.signell@itmill.com> | 2009-11-12 13:55:27 +0000 |
commit | 1d2c11a2f7b4f528aae73601caff3479cbf6d26a (patch) | |
tree | f237b8e6d3ca005e8388d41b5303776cd45bd1ca /tests/src | |
parent | 6109ba63b494e288d8a30bc00ba97babb07d4d76 (diff) | |
download | vaadin-framework-1d2c11a2f7b4f528aae73601caff3479cbf6d26a.tar.gz vaadin-framework-1d2c11a2f7b4f528aae73601caff3479cbf6d26a.zip |
Fix for #3589 - Window.executeJavaScript(). Removed DOM reference possibility.
svn changeset:9746/svn branch:6.2
Diffstat (limited to 'tests/src')
-rw-r--r-- | tests/src/com/vaadin/tests/components/window/ExecuteJavaScript.java | 46 | ||||
-rw-r--r-- | tests/src/com/vaadin/tests/tickets/Ticket3589.java | 57 |
2 files changed, 46 insertions, 57 deletions
diff --git a/tests/src/com/vaadin/tests/components/window/ExecuteJavaScript.java b/tests/src/com/vaadin/tests/components/window/ExecuteJavaScript.java new file mode 100644 index 0000000000..3d4394dede --- /dev/null +++ b/tests/src/com/vaadin/tests/components/window/ExecuteJavaScript.java @@ -0,0 +1,46 @@ +package com.vaadin.tests.components.window; + +import com.vaadin.tests.components.AbstractTestCase; +import com.vaadin.ui.Button; +import com.vaadin.ui.Panel; +import com.vaadin.ui.Window; +import com.vaadin.ui.Button.ClickEvent; + +public class ExecuteJavaScript extends AbstractTestCase { + + @Override + public void init() { + final Window mainWindow = new Window("Test"); + setMainWindow(mainWindow); + + for (final String script : new String[] { "alert('foo');", + "window.print()", "document.write('foo')" }) { + Panel p = new Panel("Example: " + script); + p.addComponent(createScriptButton(script)); + mainWindow.addComponent(p); + } + + } + + private Button createScriptButton(final String script) { + Button b = new Button(script); + b.addListener(new Button.ClickListener() { + + public void buttonClick(ClickEvent event) { + getMainWindow().executeJavaScript(script); + } + }); + + return b; + } + + @Override + protected String getDescription() { + return "Test for the Window.executeJavaScript method. Click a button to execute the javascript"; + } + + @Override + protected Integer getTicketNumber() { + return 3589; + } +} diff --git a/tests/src/com/vaadin/tests/tickets/Ticket3589.java b/tests/src/com/vaadin/tests/tickets/Ticket3589.java deleted file mode 100644 index f072f2dd90..0000000000 --- a/tests/src/com/vaadin/tests/tickets/Ticket3589.java +++ /dev/null @@ -1,57 +0,0 @@ -package com.vaadin.tests.tickets; - -import com.vaadin.Application; -import com.vaadin.ui.Button; -import com.vaadin.ui.Label; -import com.vaadin.ui.Panel; -import com.vaadin.ui.TextField; -import com.vaadin.ui.Window; -import com.vaadin.ui.Button.ClickEvent; - -public class Ticket3589 extends Application { - - @Override - public void init() { - final Window mainWindow = new Window("Test"); - setMainWindow(mainWindow); - - for (final String script : new String[] { "alert('foo');", - "window.print()", "document.write('foo')" }) { - Panel p = new Panel("Example: " + script); - p.addComponent(new Button("Run javascript", - new Button.ClickListener() { - - public void buttonClick(ClickEvent event) { - mainWindow.executeJavaScript(script); - } - })); - mainWindow.addComponent(p); - } - - final String script = "$1.style.backgroundColor='yellow';$2.style.borderColor='red';"; - Panel p = new Panel("Example: " + script); - final Label label = new Label("Label"); - final TextField textfield = new TextField("TestField"); - p.addComponent(label); - p.addComponent(textfield); - p.addComponent(new Button("Run javascript", new Button.ClickListener() { - - public void buttonClick(ClickEvent event) { - mainWindow.executeJavaScript(script, label, textfield); - } - })); - mainWindow.addComponent(p); - - final String script2 = "var w = window.open(); w.document.write($1.outerHTML); w.print();"; - final Panel p2 = new Panel("Example: " + script2); - p2.addComponent(new Label("Only this panel will be printed...")); - p2.addComponent(new Button("Run javascript", - new Button.ClickListener() { - public void buttonClick(ClickEvent event) { - mainWindow.executeJavaScript(script2, p2); - } - })); - mainWindow.addComponent(p2); - - } -} |