Skip to content

Commit 9e3e78b

Browse files
HeikoKlarefedejeanne
authored andcommitted
Add some debug output
1 parent 2db6e49 commit 9e3e78b

File tree

2 files changed

+11
-5
lines changed

2 files changed

+11
-5
lines changed

bundles/org.eclipse.swt/Eclipse SWT Browser/win32/org/eclipse/swt/browser/Edge.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -596,6 +596,7 @@ void setupBrowser(int hr, long pv) {
596596
error(SWT.ERROR_THREAD_INVALID_ACCESS, hr);
597597
break;
598598
default:
599+
System.err.println("WebView instantiation failed with result: " + hr);
599600
containingEnvironment.instances().remove(this);
600601
error(SWT.ERROR_NO_HANDLES, hr);
601602
}

tests/org.eclipse.swt.tests/JUnit Tests/org/eclipse/swt/tests/junit/Test_org_eclipse_swt_browser_Browser.java

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -298,6 +298,8 @@ private Browser createBrowser(Shell s, int flags) {
298298
long maximumBrowserCreationMilliseconds = 10_000;
299299
long createStartTime = System.currentTimeMillis();
300300
Browser b = new Browser(s, flags);
301+
// Wait for asynchronous initialization via getting URL
302+
b.getUrl();
301303
createdBroswers.add(b);
302304
long createDuration = System.currentTimeMillis() - createStartTime;
303305
assertTrue("creating browser took too long: " + createDuration + "ms", createDuration < maximumBrowserCreationMilliseconds);
@@ -735,14 +737,16 @@ public void changed(LocationEvent event) {
735737

736738
@Test
737739
public void test_LocationListener_LocationListener_ordered_changing () {
738-
List<String> locations = new ArrayList<>();
739-
browser.addLocationListener(changingAdapter(event -> locations.add(event.location)));
740+
List<String> locations = Collections.synchronizedList(new ArrayList<>());
741+
browser.addLocationListener(changingAdapter(event -> {
742+
locations.add(event.location);
743+
}));
740744
shell.open();
741745
browser.setText("You should not see this message.");
742746
String url = getValidUrl();
743747
browser.setUrl(url);
744-
waitForPassCondition(() -> locations.size() == 2);
745-
assertTrue("Change of locations do not fire in order.", locations.get(0).equals("about:blank") && locations.get(1).contains("testWebsiteWithTitle.html"));
748+
assertTrue("Change of locations do not fire in order: " + locations.toString(), waitForPassCondition(() -> locations.size() == 2));
749+
assertTrue("Change of locations do not fire in order", locations.get(0).equals("about:blank") && locations.get(1).contains("testWebsiteWithTitle.html"));
746750
}
747751

748752
private String getValidUrl() {
@@ -1955,6 +1959,7 @@ public void test_evaluate_null() {
19551959
// Boolen only used as dummy placeholder so the object is not null.
19561960
final AtomicReference<Object> returnValue = new AtomicReference<>(true);
19571961
browser.addProgressListener(completedAdapter(event -> {
1962+
returnValue.set(false);
19581963
Object evalResult = browser.evaluate("return null");
19591964
returnValue.set(evalResult);
19601965
if (debug_verbose_output)
@@ -1964,7 +1969,7 @@ public void test_evaluate_null() {
19641969
browser.setText("<html><body>HelloWorld</body></html>");
19651970
shell.open();
19661971
boolean passed = waitForPassCondition(() -> returnValue.get() == null);
1967-
assertTrue("Evaluate did not return a null. Timed out.", passed);
1972+
assertTrue("Evaluate did not return a null (current value: " + returnValue.get() + "). Timed out.", passed);
19681973
}
19691974

19701975
/**

0 commit comments

Comments
 (0)