diff options
author | Joonas Lehtinen <joonas.lehtinen@itmill.com> | 2009-11-09 08:23:10 +0000 |
---|---|---|
committer | Joonas Lehtinen <joonas.lehtinen@itmill.com> | 2009-11-09 08:23:10 +0000 |
commit | f59f7d457cc535cfbe789058177aa38ca54746bd (patch) | |
tree | 40de300c35269666be583a7de156d2512a9a4631 /tests/src | |
parent | 9a4eabaa7f8e3d5f9c497c940c577f02dfe88bcb (diff) | |
download | vaadin-framework-f59f7d457cc535cfbe789058177aa38ca54746bd.tar.gz vaadin-framework-f59f7d457cc535cfbe789058177aa38ca54746bd.zip |
#3589 : Fixed document and window references for the script executed with executeJavaScript(), better testcases, better API documentation examples
svn changeset:9678/svn branch:6.2
Diffstat (limited to 'tests/src')
-rw-r--r-- | tests/src/com/vaadin/tests/tickets/Ticket3589.java | 40 |
1 files changed, 29 insertions, 11 deletions
diff --git a/tests/src/com/vaadin/tests/tickets/Ticket3589.java b/tests/src/com/vaadin/tests/tickets/Ticket3589.java index 5b7182eb5e..f072f2dd90 100644 --- a/tests/src/com/vaadin/tests/tickets/Ticket3589.java +++ b/tests/src/com/vaadin/tests/tickets/Ticket3589.java @@ -3,6 +3,7 @@ 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; @@ -14,26 +15,43 @@ public class Ticket3589 extends Application { final Window mainWindow = new Window("Test"); setMainWindow(mainWindow); - mainWindow.addComponent(new Button("alert('foo')", - new Button.ClickListener() { + 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("alert('foo');"); - } - })); + 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"); - mainWindow.addComponent(label); - mainWindow.addComponent(textfield); - - final String script = "$1.style.backgroundColor='yellow';$2.style.borderColor='red';"; - mainWindow.addComponent(new Button(script, new Button.ClickListener() { + 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); } } |