Skip to content

Commit

Permalink
Add some debug output
Browse files Browse the repository at this point in the history
  • Loading branch information
HeikoKlare authored and fedejeanne committed Dec 16, 2024
1 parent 2db6e49 commit 9e3e78b
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -596,6 +596,7 @@ void setupBrowser(int hr, long pv) {
error(SWT.ERROR_THREAD_INVALID_ACCESS, hr);
break;
default:
System.err.println("WebView instantiation failed with result: " + hr);
containingEnvironment.instances().remove(this);
error(SWT.ERROR_NO_HANDLES, hr);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -298,6 +298,8 @@ private Browser createBrowser(Shell s, int flags) {
long maximumBrowserCreationMilliseconds = 10_000;
long createStartTime = System.currentTimeMillis();
Browser b = new Browser(s, flags);
// Wait for asynchronous initialization via getting URL
b.getUrl();
createdBroswers.add(b);
long createDuration = System.currentTimeMillis() - createStartTime;
assertTrue("creating browser took too long: " + createDuration + "ms", createDuration < maximumBrowserCreationMilliseconds);
Expand Down Expand Up @@ -735,14 +737,16 @@ public void changed(LocationEvent event) {

@Test
public void test_LocationListener_LocationListener_ordered_changing () {
List<String> locations = new ArrayList<>();
browser.addLocationListener(changingAdapter(event -> locations.add(event.location)));
List<String> locations = Collections.synchronizedList(new ArrayList<>());
browser.addLocationListener(changingAdapter(event -> {
locations.add(event.location);
}));
shell.open();
browser.setText("You should not see this message.");
String url = getValidUrl();
browser.setUrl(url);
waitForPassCondition(() -> locations.size() == 2);
assertTrue("Change of locations do not fire in order.", locations.get(0).equals("about:blank") && locations.get(1).contains("testWebsiteWithTitle.html"));
assertTrue("Change of locations do not fire in order: " + locations.toString(), waitForPassCondition(() -> locations.size() == 2));
assertTrue("Change of locations do not fire in order", locations.get(0).equals("about:blank") && locations.get(1).contains("testWebsiteWithTitle.html"));
}

private String getValidUrl() {
Expand Down Expand Up @@ -1955,6 +1959,7 @@ public void test_evaluate_null() {
// Boolen only used as dummy placeholder so the object is not null.
final AtomicReference<Object> returnValue = new AtomicReference<>(true);
browser.addProgressListener(completedAdapter(event -> {
returnValue.set(false);
Object evalResult = browser.evaluate("return null");
returnValue.set(evalResult);
if (debug_verbose_output)
Expand All @@ -1964,7 +1969,7 @@ public void test_evaluate_null() {
browser.setText("<html><body>HelloWorld</body></html>");
shell.open();
boolean passed = waitForPassCondition(() -> returnValue.get() == null);
assertTrue("Evaluate did not return a null. Timed out.", passed);
assertTrue("Evaluate did not return a null (current value: " + returnValue.get() + "). Timed out.", passed);
}

/**
Expand Down

0 comments on commit 9e3e78b

Please sign in to comment.