Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Extend Browser API to check for custom text location #1409

Conversation

amartya4256
Copy link
Contributor

The contribution provides an API to check if the location is the location where custom texts are loaded in a browser. By construct, "about:blank" is used for that purpose. This API can be adapted by the clients instead of explicitly defining the string and checking.

Contributes to #213

@amartya4256 amartya4256 force-pushed the create_api_forbrowser_location_check branch 3 times, most recently from 3ef45a9 to 68427b0 Compare August 16, 2024 14:30
Copy link
Contributor

github-actions bot commented Aug 16, 2024

Test Results

   486 files  ± 0     486 suites  ±0   8m 43s ⏱️ + 1m 31s
 4 156 tests + 5   4 148 ✅ + 5   8 💤 ±0  0 ❌ ±0 
16 378 runs  +20  16 286 ✅ +20  92 💤 ±0  0 ❌ ±0 

Results for commit aa4988a. ± Comparison against base commit d200d94.

♻️ This comment has been updated with latest results.

@amartya4256 amartya4256 force-pushed the create_api_forbrowser_location_check branch 5 times, most recently from 3428a6f to 4652035 Compare August 20, 2024 09:56
Copy link
Contributor

@HeikoKlare HeikoKlare left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seeing the implementation, I am wondering whether it would also be sufficient to just add a showsCustomText() method instead of the isLocationForCustomText(String) one. Then the functionality would be completely independent from the location and the browser handle the state of whether it shows custom text or some URI-based page completely internally and even better hide it from consumers.
@amartya4256 Can you check whether that's possible?

Edit: Please also validate against the WebKit implementation. It seems to already have the about:blank page encoded as kind of a base URI internally. It also has some comments about using about:blank to be consistent with IE, so maybe there is also some further chance to align. I.e., a comment states:

/*
* If the URI indicates that the page is being rendered from memory
* (via setText()) then set it to about:blank to be consistent with IE.
*/

@amartya4256
Copy link
Contributor Author

amartya4256 commented Aug 21, 2024

Seeing the implementation, I am wondering whether it would also be sufficient to just add a showsCustomText() method instead of the isLocationForCustomText(String) one. Then the functionality would be completely independent from the location and the browser handle the state of whether it shows custom text or some URI-based page completely internally and even better hide it from consumers. @amartya4256 Can you check whether that's possible?

Edit: Please also validate against the WebKit implementation. It seems to already have the about:blank page encoded as kind of a base URI internally. It also has some comments about using about:blank to be consistent with IE, so maybe there is also some further chance to align. I.e., a comment states:

/*
* If the URI indicates that the page is being rendered from memory
* (via setText()) then set it to about:blank to be consistent with IE.
*/

using showsCustomText() won't be possible everywhere since there are Url comparison before the location of the browser has changed. For example in location listener in the changing method which executes before the location is actually changed. Another option was to cache the state type on setText but we don't know where we land with back and forward calls so it cannot be fully implemented. Moreover, I find the current method fine to accept a location as an argument. If you want to check something explictly, that can be passed, otherwise browser.getUrl() can be passed.

The Webkit implementation does make the behaviour consistent by exchanging the places in the API result with about:blank but I think that our implementattion takes thwe technicality away from the client and they dont have to hardcode about:blank anymore and they can leave his decision completely on the browser to tell if it is their custom text page.

Copy link
Contributor

@HeikoKlare HeikoKlare left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The API extension in general looks good to me. I have some comments on naming, documentation and testing.

Please also adapt the commit message header (and PR name) to be more self-explaining. I.e., instead of "Added API for checking if BASE_URI" use something like "Extend Browser API to check for custom text location"

@@ -724,6 +726,10 @@ public void setBrowser (Browser browser) {
this.browser = browser;
}

public URI getBaseUri() {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can this be package protected, since the only intended consumer (`Browser´) is in the same package? Please also improve the name according to field name (see comment on the field name for that).

In addition, please check whether this method can be used by the IE and WebKit implementations, which currently have their own ABOUT_BLANK field, which might (at least at some places) be reasonably replaced by this method.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Made it package protected but I think refactoring of the browser specific usage can be done in a follow up PR?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's also fine. But then it should be done directly after merging this change.

@amartya4256 amartya4256 force-pushed the create_api_forbrowser_location_check branch 4 times, most recently from 5671ddd to 66ae8a5 Compare August 30, 2024 11:55
Copy link
Contributor

@HeikoKlare HeikoKlare left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for adding the tests! In general, they look fine. My comments are mostly nitpicky style proposals, but some are also on potential race conditions. Anyway, all of them should be easy to resolve.

@amartya4256 amartya4256 force-pushed the create_api_forbrowser_location_check branch 2 times, most recently from 343bb38 to 03601c4 Compare September 2, 2024 11:33
Copy link
Contributor

@HeikoKlare HeikoKlare left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks again for the recent update! I have some minor questions/comments left.

@amartya4256 amartya4256 force-pushed the create_api_forbrowser_location_check branch 6 times, most recently from 8253b50 to 66c8ae2 Compare September 3, 2024 11:49
@amartya4256 amartya4256 force-pushed the create_api_forbrowser_location_check branch 2 times, most recently from b7ab89b to 642aa32 Compare September 3, 2024 14:44
@HeikoKlare HeikoKlare changed the title Added API for checking if BASE_URI Extend Browser API to check for custom text location Sep 3, 2024
@amartya4256 amartya4256 force-pushed the create_api_forbrowser_location_check branch 5 times, most recently from 51b8d8f to 50c18c5 Compare September 4, 2024 10:02
Copy link
Contributor

@HeikoKlare HeikoKlare left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

From my side, this is ready to be merged once master branch is open again. Thank you!

The contribution provides an API to check if the location is the
location where custom texts are loaded in a browser. By construct,
"about:blank" is used for that purpose. This API can be adapted by the
clients instead of explicitly defining the string and checking.

Contributes to eclipse-platform#213
@HeikoKlare HeikoKlare force-pushed the create_api_forbrowser_location_check branch from 50c18c5 to aa4988a Compare September 5, 2024 07:39
@HeikoKlare HeikoKlare merged commit d9159c0 into eclipse-platform:master Sep 5, 2024
14 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants