-
Notifications
You must be signed in to change notification settings - Fork 542
8327478: Add System test to verify TextSelection issue for webkit-617.1 #1719
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
Conversation
|
Hi @Gopalora, welcome to this OpenJDK project and thanks for contributing! We do not recognize you as Contributor and need to ensure you have signed the Oracle Contributor Agreement (OCA). If you have not signed the OCA, please follow the instructions. Please fill in your GitHub username in the "Username" field of the application. Once you have signed the OCA, please let us know by writing If you already are an OpenJDK Author, Committer or Reviewer, please click here to open a new issue so that we can record that fact. Please use "Add GitHub user Gopalora" as summary for the issue. If you are contributing this work on behalf of your employer and your employer has signed the OCA, please let us know by writing |
|
@Gopalora This change now passes all automated pre-integration checks. ℹ️ This project also has non-automated pre-integration requirements. Please see the file CONTRIBUTING.md for details. After integration, the commit message for the final commit will be: You can use pull request commands such as /summary, /contributor and /issue to adjust it as needed. At the time when this comment was updated there had been 8 new commits pushed to the
Please see this link for an up-to-date comparison between the source branch of this pull request and the As you do not have Committer status in this project an existing Committer must agree to sponsor your change. Possible candidates are the reviewers of this PR (@kevinrushforth, @andy-goryachev-oracle) but any other Committer may sponsor as well. ➡️ To flag this PR as ready for integration with the above commit message, type |
|
/covered |
|
Thank you! Please allow for a few business days to verify that your employer has signed the OCA. Also, please note that pull requests that are pending an OCA check will not usually be evaluated, so your patience is appreciated! |
|
@Gopalora Please enable GHA tests on your repo. I'll provide a few comments now, and formally review it once your OCA status is verified. |
| int y = (int)(scene.getWindow().getY() + scene.getY() + 15); | ||
|
|
||
| Util.runAndWait(() -> { | ||
| robot.mouseMove(1, 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.
Minor: use the utility method Util.parkCursor(robot); instead
| Util.sleep(500); | ||
|
|
||
| Util.runAndWait(() -> { | ||
| robot.mouseMove(1, 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.
Minor: use the utility method Util.parkCursor(robot); instead
| robot.mousePress(MouseButton.PRIMARY); | ||
| robot.mouseRelease(MouseButton.PRIMARY); | ||
| Util.sleep(50); | ||
| robot.mousePress(MouseButton.PRIMARY); | ||
| robot.mouseRelease(MouseButton.PRIMARY); |
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.
Minor: You can call robot.mouseClick(MouseButton) instead of separate calls to press/release.
Not so minor: You shouldn't' sleep in the FX app thread. Instead, break this block into two separate lambdas passed into to separate calls to runAndWait with the sleep in between them running in the test thread. Like this:
Util.runAndWait(() -> {
...
robot.mouseClick(MouseButton.PRIMARY);
});
Util.sleep(50);
Util.runAndWait(() -> {
robot.mouseClick(MouseButton.PRIMARY);
});
Suggestion: consider creating a doubleClick utility method in the test Util class.
|
Thanks for the review. |
| /** | ||
| * Makes double click of the mouse left button. | ||
| */ | ||
| public static void doubleClick(Robot robot, int x, int y) { |
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.
Since this is now a general-purpose utility, I'd prefer to separate out the mouse move from the double-click (with the mouse move being done in the test itself) and just have this be void doubleClick(Robot robot).
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.
Done.
|
The latest changes look good. I'll formally review it once your OCA status is verified. |
Webrevs
|
|
|
||
| public class TextSelectionTest { | ||
|
|
||
| private static final String html = "<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.
we could use new java text block here
private static final String html =
"""
<html>
<head></head>
<body>     some text</body>
</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.
Done.
| import org.junit.jupiter.api.Timeout; | ||
| import test.util.Util; | ||
|
|
||
| public class TextSelectionTest { |
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 wonder if we could extend RobotTestBase base class to simplify the code?
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.
Done.
| public void testTextSelection() throws Exception { | ||
|
|
||
| int x = (int)(scene.getWindow().getX() + scene.getX() + 22); | ||
| int y = (int)(scene.getWindow().getY() + scene.getY() + 15); |
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.
can these offsets (22, 15) be measured instead of hard-coded?
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.
We are not getting the text area from web view. This point is used to simulate the mouse click.
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.
so they are arbitrary, and will work for every font size?
(The default font size varies depending on the platform and other circumstances, see PrismFontFactory::getSystemFontSize() - though I am not sure if the default font size is picked up by the WebView.
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.
Tested in font size 1 and 5 separately. In both case it passed. For this test case, set font size 2 for test purpose only.
kevinrushforth
left a comment
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.
Looks good with one minor code style issue.
| import test.robot.testharness.RobotTestBase; | ||
| import test.util.Util; | ||
|
|
||
| public class TextSelectionTest extends RobotTestBase{ |
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.
Minor: please add a space before the {
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.
Done.
| """ | ||
| <html> | ||
| <head></head> | ||
| <body>     some text</body> | ||
| </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.
One more minor code style issue: lines 45-50 should be intended
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.
Done as per one suggestion on "https://docs.oracle.com/en/java/javase/18/text-blocks/index.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.
Removed the line "" as this is empty.
| """; | ||
|
|
||
| private static CountDownLatch webviewLoadLatch = new CountDownLatch(1); | ||
| private Color colorBefore; |
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.
suggestion: make colorBefore/After volatile since they are being accessed from different threads without any synchronization.
I think this should be sufficient (no need for AtomicReference).
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 isn't strictly needed, since runAndWait synchronizes the two threads (although there is no harm in adding volatile).
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.
https://en.wikipedia.org/wiki/Cache_coherence
edit: you might be right about runAndWait, we know it does separate the access from multiple threads in time, and it might be even smart enough to figure out that the field is being accessed from two different threads and emit the appropriate bytecode (similarly how we don't need the final keyword for effectively final variables nowadays).
But I think that adding volatile guarantees that all the necessary steps are done by the JVM.
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.
That's interesting, but not particularly relevant. What is relevant is the JVM spec, specifically the Java Memory Model, which guarantees a happens-before ordering of actions in two threads that synchronize-with each other.
edit: you might be right about runAndWait, we know it does separate the access from multiple threads in time, and it might be even smart enough to figure out that the field is being accessed from two different threads and emit the appropriate bytecode (similarly how we don't need the
finalkeyword for effectively final variables nowadays).
It isn't about the byte code that is emitted as much as it is about how the code is executed by the two different threads. And it isn't because it need to be "smart enough", it's because that's how the memory model works.
A write by the thread that executes the runnable passed into runAndWait (the FX app thread in this case), happens-before the read done by the test thread that is done after the runAndWait returns because the runAndWait call causes the actions done in the runAndWait's runnable to synchronize-with the wait done by the calling thread.
But I think that adding
volatileguarantees that all the necessary steps are done by the JVM.
Yes, adding volatile guarantees the appropriate happens-before relationship. But so does synchronizing.
I don't really care one way or the other in this case.
| Util.parkCursor(robot); | ||
| Util.runAndWait(() -> colorAfter = robot.getPixelColor(x, y)); | ||
|
|
||
| Assertions.assertNotEquals(colorBefore, colorAfter, |
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 we also test for non-null colorBefore ?
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.
Robot::getPixelColor can't return null (although I checked the docs and we don't specify one way or the other). It seems fine either way.
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.
what if the lambdas never run?
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.
Then we have far bigger problems than this one test. The reason we use runAndWait instead of runLater is so we guarantee that the lambda has run before that method returns. It's guaranteed to do so.
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.
Added volatile to the variables colorBefore and colorAfter.
kevinrushforth
left a comment
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.
Looks good.
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.
lgtm, thank you for addressing the comments.
|
/integrate |
|
/sponsor |
|
Going to push as commit 0a20fef.
Your commit was automatically rebased without conflicts. |
There was no test included with the fix for JDK-8326989,
Hence we are adding a system test now.
Test is written as
Verification:
The test passes with latest webkit source
Also verified that test fails when the fix for JDK-8326989 is reverted.
Progress
Issue
Reviewers
Reviewing
Using
gitCheckout this PR locally:
$ git fetch https://git.openjdk.org/jfx.git pull/1719/head:pull/1719$ git checkout pull/1719Update a local copy of the PR:
$ git checkout pull/1719$ git pull https://git.openjdk.org/jfx.git pull/1719/headUsing Skara CLI tools
Checkout this PR locally:
$ git pr checkout 1719View PR using the GUI difftool:
$ git pr show -t 1719Using diff file
Download this PR as a diff file:
https://git.openjdk.org/jfx/pull/1719.diff
Using Webrev
Link to Webrev Comment