-
Notifications
You must be signed in to change notification settings - Fork 65
testBodyReplace #1463
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
base: main
Are you sure you want to change the base?
testBodyReplace #1463
Conversation
| Import-Package: com.google.common.base, | ||
| com.google.gson;version="2.7.0" | ||
| com.google.gson;version="2.7.0", | ||
| org.apache.commons.lang;version="[2.6.0,3.0.0)" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should rather be a require-plugin, and the plugin should be added to the target file by referencing Orbit.
| setSize(hint.x, hint.y); | ||
|
|
||
| if (!"complete".equals(safeEvaluate(browser, "return document.readyState"))) { //$NON-NLS-1$ //$NON-NLS-2$ | ||
| if (!"complete".equals(safeEvaluate(browser, "if (document.documentElement === null) {return 'no content';} return document.readyState;"))) { //$NON-NLS-1$ //$NON-NLS-2$ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This I think should not be needed with this approach.
|
|
||
| public void setTextInBrowser(final Browser browser, final String text) { | ||
| String escapedHtmlBody = StringEscapeUtils.escapeJavaScript(text); | ||
| safeExecute(browser, "document.body.innerHTML = \"" + escapedHtmlBody + "\";"); //$NON-NLS-1$//$NON-NLS-2$ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this should work but I was not able to see the updated content on the hover. I did not have time to check if the problem is that the javascript is not correct (I think it is because we have this very same code in production for months without issues), or if it is that I would need to also do something in the internals on the base class (for example override the fInput field as well), or that my Language Server was having problems (I found many of those in my LS, but I did not had time to go back and this PR to double check).
| if (html != null && !html.isBlank()) { | ||
| super.setInput(styleHtml(html)); | ||
| try { | ||
| Field f = BrowserInformationControl.class.getDeclaredField("fBrowser"); //$NON-NLS-1$ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I do not like to do this, but the base class we are using is not good for customizability. Indeed the documentation clearly says it should not be subclassed, which we are ignoring.
I have another test where I do not use that class at all, but we would need to replicate some code which is a bit scary. I can submit that PR as well if you think it is useful.
| Objects.requireNonNull(browser); | ||
| setTextInBrowser(browser, html); | ||
| } catch (NoSuchFieldException | SecurityException | IllegalArgumentException | IllegalAccessException e) { | ||
| super.setInput(html); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should never happen, but it is just a safety net. We should add some logging in this case.
No description provided.