Skip to content

Commit 8fe0fb0

Browse files
amartya4256HeikoKlare
authored andcommitted
Revert "Extend Browser API to check for custom text location"
This reverts commit 51b8d8f. The API isLocationForCustomText is not needed for Browsers. contributes to eclipse-platform#213
1 parent 8ce60f9 commit 8fe0fb0

File tree

4 files changed

+13
-95
lines changed

4 files changed

+13
-95
lines changed

bundles/org.eclipse.swt/Eclipse SWT Browser/common/org/eclipse/swt/browser/Browser.java

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,6 @@
1313
*******************************************************************************/
1414
package org.eclipse.swt.browser;
1515

16-
import java.net.*;
17-
import java.util.*;
18-
1916
import org.eclipse.swt.*;
2017
import org.eclipse.swt.widgets.*;
2118

@@ -1190,21 +1187,6 @@ public boolean setUrl (String url, String postData, String[] headers) {
11901187
return webBrowser.setUrl (url, postData, headers);
11911188
}
11921189

1193-
/**
1194-
* Checks if the location supplied is the location for setting custom text in the browser.
1195-
* This means, when passing the browser URL to this method after a custom text has been set
1196-
* via {@link #setText(String)} will yield true as long as no further navigation
1197-
* to some other location is performed.
1198-
*
1199-
* @param location the URL to be checked, must not be null
1200-
*
1201-
* @since 3.128
1202-
*/
1203-
public boolean isLocationForCustomText(String location) {
1204-
checkWidget();
1205-
return URI.create(Objects.requireNonNull(location)).equals(webBrowser.getUriForCustomText());
1206-
}
1207-
12081190
/**
12091191
* Stop any loading and rendering activity.
12101192
*

bundles/org.eclipse.swt/Eclipse SWT Browser/common/org/eclipse/swt/browser/WebBrowser.java

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313
*******************************************************************************/
1414
package org.eclipse.swt.browser;
1515

16-
import java.net.*;
1716
import java.util.*;
1817
import java.util.List;
1918

@@ -37,7 +36,6 @@ abstract class WebBrowser {
3736

3837
static final String ERROR_ID = "org.eclipse.swt.browser.error"; // $NON-NLS-1$
3938
static final String EXECUTE_ID = "SWTExecuteTemporaryFunction"; // $NON-NLS-1$
40-
private static final URI URI_FOR_CUSTOM_TEXT_PAGE = URI.create("about:blank");
4139

4240
static List<String[]> NativePendingCookies = new ArrayList<> ();
4341
static String CookieName, CookieValue, CookieUrl;
@@ -726,10 +724,6 @@ public void setBrowser (Browser browser) {
726724
this.browser = browser;
727725
}
728726

729-
URI getUriForCustomText() {
730-
return URI_FOR_CUSTOM_TEXT_PAGE;
731-
}
732-
733727
public abstract boolean setText (String html, boolean trusted);
734728

735729
public abstract boolean setUrl (String url, String postData, String[] headers);

examples/org.eclipse.swt.examples/src/org/eclipse/swt/examples/controlexample/BrowserTab.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -213,7 +213,7 @@ void disposeExampleWidgets () {
213213
/* store the state of the Browser if applicable */
214214
if (browser != null) {
215215
String url = browser.getUrl();
216-
if (url.length() > 0 && !browser.isLocationForCustomText(url)) { //$NON-NLS-1$
216+
if (url.length() > 0 && !url.equals("about:blank")) { //$NON-NLS-1$
217217
lastUrl = url;
218218
} else {
219219
String text = browser.getText();

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

Lines changed: 12 additions & 70 deletions
Original file line numberDiff line numberDiff line change
@@ -518,75 +518,6 @@ public void changing(LocationEvent event) {
518518
for (int i = 0; i < 100; i++) browser.removeLocationListener(listener);
519519
}
520520

521-
@Test
522-
public void test_isLocationForCustomText_setUrlAfterDisposedThrowsSwtException() {
523-
Browser testBrowser = createBrowser(shell, SWT.NONE);
524-
testBrowser.dispose();
525-
assertThrows(SWTException.class, () -> testBrowser.isLocationForCustomText("about:blank"));
526-
}
527-
528-
@Test
529-
public void test_isLocationForCustomText_isSetUrlNotCustomTextUrlAfterSetText() {
530-
String url = getValidUrl();
531-
AtomicBoolean locationChanged = new AtomicBoolean(false);
532-
browser.addLocationListener(changedAdapter(event -> {
533-
locationChanged.set(true);
534-
}));
535-
536-
browser.setText("Custom text");
537-
assertTrue("Time Out: The Browser didn't navigate to the URL", waitForPassCondition(locationChanged::get));
538-
locationChanged.set(false);
539-
browser.setUrl(url);
540-
assertTrue("Time Out: The Browser didn't navigate to the URL", waitForPassCondition(locationChanged::get));
541-
assertFalse("The navigated URL is falsly indicated to be the custom text URL", browser.isLocationForCustomText(browser.getUrl()));
542-
}
543-
544-
@Test
545-
public void test_isLocationForCustomText_isFirstSetTextURLStillCustomTextUrlAfterSetUrl() {
546-
AtomicBoolean locationChanged = new AtomicBoolean(false);
547-
browser.addLocationListener(changedAdapter(event -> locationChanged.set(true)));
548-
String url = getValidUrl();
549-
browser.setText("Custom text");
550-
assertTrue(waitForPassCondition(locationChanged::get));
551-
String firstUrl = browser.getUrl();
552-
locationChanged.set(false);
553-
browser.setUrl(url);
554-
assertTrue("Time Out: The Browser didn't navigate to the URL", waitForPassCondition(locationChanged::get));
555-
assertTrue(browser.isLocationForCustomText(firstUrl));
556-
assertFalse(browser.isLocationForCustomText(browser.getUrl()));
557-
}
558-
559-
private String getValidUrl() {
560-
String pluginPath = System.getProperty("PLUGIN_PATH");
561-
testLogAppend("PLUGIN_PATH: " + pluginPath);
562-
// When test is run via Ant, URL needs to be acquired differently. In that case the PLUGIN_PATH property is set and used.
563-
if (pluginPath != null) {
564-
return pluginPath + "/data/testWebsiteWithTitle.html";
565-
} else {
566-
// used when ran from Eclipse gui.
567-
return Test_org_eclipse_swt_browser_Browser.class.getClassLoader().getResource("testWebsiteWithTitle.html").toString();
568-
}
569-
}
570-
571-
@Test
572-
public void test_isLocationForCustomText_isSetUrlNotCustomTextUrl() {
573-
AtomicBoolean locationChanged = new AtomicBoolean(false);
574-
browser.addLocationListener(changedAdapter(event -> locationChanged.set(true)));
575-
String url = getValidUrl();
576-
browser.setUrl(url);
577-
waitForPassCondition(locationChanged::get);
578-
assertFalse("Url is wrongly considered Custom Text Url", browser.isLocationForCustomText(browser.getUrl()));
579-
}
580-
581-
@Test
582-
public void test_isLocationForCustomText() {
583-
AtomicBoolean locationChanged = new AtomicBoolean(false);
584-
browser.addLocationListener(changedAdapter(e -> locationChanged.set(true)));
585-
browser.setText("Hello world");
586-
assertTrue("Timeout: LocationListener.changing() event was never fired", waitForPassCondition(locationChanged::get));
587-
assertTrue("Custom Text URI was not loaded on setText", browser.isLocationForCustomText(browser.getUrl()));
588-
}
589-
590521
@Test
591522
public void test_LocationListener_changing() {
592523
AtomicBoolean changingFired = new AtomicBoolean(false);
@@ -762,9 +693,20 @@ public void test_LocationListener_LocationListener_ordered_changing () {
762693
String url = getValidUrl();
763694
browser.setUrl(url);
764695
waitForPassCondition(() -> locations.size() == 2);
765-
assertTrue("Change of locations do not fire in order.", browser.isLocationForCustomText(locations.get(0)) && locations.get(1).contains("testWebsiteWithTitle.html"));
696+
assertTrue("Change of locations do not fire in order.", locations.get(0).equals("about:blank") && locations.get(1).contains("testWebsiteWithTitle.html"));
766697
}
767698

699+
private String getValidUrl() {
700+
String pluginPath = System.getProperty("PLUGIN_PATH");
701+
testLogAppend("PLUGIN_PATH: " + pluginPath);
702+
// When test is run via Ant, URL needs to be acquired differently. In that case the PLUGIN_PATH property is set and used.
703+
if (pluginPath != null) {
704+
return pluginPath + "/data/testWebsiteWithTitle.html";
705+
} else {
706+
// used when ran from Eclipse gui.
707+
return Test_org_eclipse_swt_browser_Browser.class.getClassLoader().getResource("testWebsiteWithTitle.html").toString();
708+
}
709+
}
768710

769711
@Test
770712
/** Ensue that only one changed and one completed event are fired for url changes */

0 commit comments

Comments
 (0)