Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLeo Ufimtsev2017-09-29 16:01:15 +0000
committerLeo Ufimtsev2017-10-02 13:37:39 +0000
commitc652317455bd64fe35f585ead710f8ffd3783464 (patch)
tree7ea54a8f9ae7e39410b09f44c176c58b42ae5ecc /tests/org.eclipse.swt.tests
parent107ceeba3d355c1a95c2593eef27399f855da615 (diff)
downloadeclipse.platform.swt-c652317455bd64fe35f585ead710f8ffd3783464.tar.gz
eclipse.platform.swt-c652317455bd64fe35f585ead710f8ffd3783464.tar.xz
eclipse.platform.swt-c652317455bd64fe35f585ead710f8ffd3783464.zip
Bug 525340 [Gtk][Webkit2] Javascript evaluate fails with "SyntaxError:
Return statements are only valid inside functions" jUnit test to catch such issues in the future. Change-Id: Ib94b293232a42a3c14748a325ea388a3e37ff88b Signed-off-by: Leo Ufimtsev <lufimtse@redhat.com>
Diffstat (limited to 'tests/org.eclipse.swt.tests')
-rw-r--r--tests/org.eclipse.swt.tests/JUnit Tests/org/eclipse/swt/tests/junit/Test_org_eclipse_swt_browser_Browser.java18
1 files changed, 18 insertions, 0 deletions
diff --git a/tests/org.eclipse.swt.tests/JUnit Tests/org/eclipse/swt/tests/junit/Test_org_eclipse_swt_browser_Browser.java b/tests/org.eclipse.swt.tests/JUnit Tests/org/eclipse/swt/tests/junit/Test_org_eclipse_swt_browser_Browser.java
index 5bff1a32b0..86def025c6 100644
--- a/tests/org.eclipse.swt.tests/JUnit Tests/org/eclipse/swt/tests/junit/Test_org_eclipse_swt_browser_Browser.java
+++ b/tests/org.eclipse.swt.tests/JUnit Tests/org/eclipse/swt/tests/junit/Test_org_eclipse_swt_browser_Browser.java
@@ -1384,6 +1384,24 @@ public void test_evaluate_string() {
assertTrue("Evaluation did not return a value. Or test timed out.", passed);
}
+// Test where the script has the 'return' not in the beginning,
+@Test
+public void test_evaluate_returnMoved() {
+ // Run locally, skip on hudson's webkit1. see Bug 509411
+ assumeFalse(webkit1SkipMsg(), (SwtTestUtil.isRunningOnEclipseOrgHudsonGTK && isWebkit1));
+
+ final AtomicReference<String> returnValue = new AtomicReference<>();
+ browser.addProgressListener(completedAdapter(event -> {
+ String evalResult = (String) browser.evaluate("var x = 1; return 'hello'");
+ returnValue.set(evalResult);
+ }));
+
+ browser.setText("test text");
+ shell.open();
+ boolean passed = waitForPassCondition(()-> "hello".equals(returnValue.get()));
+ assertTrue("Evaluation did not return a value. Or test timed out.", passed);
+}
+
/**
* Test the evaluate() api that returns a number (Double). Functionality based on Snippet308.
* Only wait till success. Otherwise timeout after 3 seconds.

Back to the top