blob: 4beec6808511faaf44b6b7429b8c4b6856b088eb (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
|
package com.vaadin.tests.components.window;
import com.vaadin.tests.components.AbstractTestCase;
import com.vaadin.ui.Button;
import com.vaadin.ui.Button.ClickEvent;
import com.vaadin.ui.LegacyWindow;
import com.vaadin.ui.Panel;
public class ExecuteJavaScript extends AbstractTestCase {
@Override
public void init() {
final LegacyWindow mainWindow = new LegacyWindow("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() {
@Override
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;
}
}
|