Bug 39433

Summary: editingBehavior settings needs to be set back to a reasonable default between tests
Product: WebKit Reporter: Martin Robinson <mrobinson>
Component: Tools / TestsAssignee: Nobody <webkit-unassigned>
Status: RESOLVED FIXED    
Severity: Normal CC: abarth, ap, dglazkov, eric, ojan, tonikitoo, webkit.review.bot
Priority: P2    
Version: 528+ (Nightly build)   
Hardware: PC   
OS: All   
Bug Depends on:    
Bug Blocks: 38603    
Attachments:
Description Flags
Patch
none
Patch
none
Reset Mac and Windows to platform default between tests
none
(committed with r60158, reviewed by eseidel, tkent) Reset Gtk and Chromium to platform default between tests none

Description Martin Robinson 2010-05-20 10:52:21 PDT
The actual setting depends on the platform.
Comment 1 Martin Robinson 2010-05-20 10:54:28 PDT
Created attachment 56608 [details]
Patch
Comment 2 Martin Robinson 2010-05-20 11:18:14 PDT
Comment on attachment 56608 [details]
Patch

via IRC:
(10:57:24 AM) ojan: mrobinson: i'd rather see a shared method in Settings
(10:57:53 AM) ojan: mrobinson: that way, if a port changes which editing behavior they use ona  platform, they only change it in one place
(11:01:09 AM) ojan: mrobinson: so, i'm thinking...add Settings::resetEditingBehavior and move the logic from the Settings constructor into that method. then call the method instead of setEditingBehavior.
(11:05:48 AM) ojan: so, i'm just staying to move those 7 lines of code into Settings::resetEditingBehavior and instead call that method from the constructor
Comment 3 Martin Robinson 2010-05-20 11:24:14 PDT
Created attachment 56616 [details]
Patch
Comment 4 Martin Robinson 2010-05-20 12:01:35 PDT
Reverted tests causing failures until this can be sorted out properly: http://trac.webkit.org/changeset/59852
Comment 5 Martin Robinson 2010-05-20 12:32:22 PDT
Committed r59857: <http://trac.webkit.org/changeset/59857>
Comment 7 Martin Robinson 2010-05-20 13:11:31 PDT
Created attachment 56624 [details]
Reset Mac and Windows to platform default between tests
Comment 8 Eric Seidel (no email) 2010-05-20 13:16:56 PDT
Comment on attachment 56624 [details]
Reset Mac and Windows to platform default between tests

LGTM!
Comment 9 Martin Robinson 2010-05-20 13:21:11 PDT
Committed r59861: <http://trac.webkit.org/changeset/59861>
Comment 10 Alexey Proskuryakov 2010-05-20 17:08:12 PDT
> Committed r59861: <http://trac.webkit.org/changeset/59861>

Sounds like this should be closed.

+        editingBehavior settings needs to be set back to a reasonable default between tests

FWIW, I'd expect "reasonable default" to be the same on all platforms. What's the value in making it different?
Comment 11 Martin Robinson 2010-05-20 17:12:55 PDT
This is required because many tests still exist which expect different behavior on different platforms (detected via user agent). At some point, if they are all rewritten, we can probably set some behavior to be the default in DRT. This still needs to be fixed for Chromium and GTK+.
Comment 12 Alexey Proskuryakov 2010-05-20 17:24:33 PDT
How many tests like that are there? What we basically need is make two or three copies of each, and set different behaviors in those.
Comment 13 Antonio Gomes 2010-05-24 19:08:03 PDT
(In reply to comment #12)
> How many tests like that are there? What we basically need is make two or three copies of each, and set different behaviors in those.

~14 tests in /editing.

$ grep -nHR  navigator.userAgent.search LayoutTests/editing/
- LayoutTests/editing/selection/script-tests/click-in-padding-with-multiple-line-boxes.js
- LayoutTests/editing/selection/script-tests/click-in-margins-inside-editable-div.js
- LayoutTests/editing/selection/script-tests/shift-click.js
- LayoutTests/editing/selection/extend-selection-after-double-click.html
- LayoutTests/editing/selection/extend-after-mouse-selection.html
- LayoutTests/editing/selection/move-begin-end.html
- LayoutTests/editing/selection/5195166-1.html
- LayoutTests/editing/input/option-page-up-down.html
- LayoutTests/editing/undo/undo-deleteWord.html
- LayoutTests/editing/deleting/delete-by-word-001.html
- LayoutTests/editing/deleting/delete-by-word-002.html
Comment 14 Antonio Gomes 2010-05-24 21:47:39 PDT
Created attachment 56970 [details]
(committed with r60158, reviewed by eseidel, tkent) Reset Gtk and Chromium to platform default between tests 

according to comment 11, it seems needed
Comment 15 Kent Tamura 2010-05-24 22:01:13 PDT
Comment on attachment 56970 [details]
(committed with r60158, reviewed by eseidel, tkent) Reset Gtk and Chromium to platform default between tests 

Chromium part looks OK.
Comment 16 Eric Seidel (no email) 2010-05-24 22:02:27 PDT
Comment on attachment 56970 [details]
(committed with r60158, reviewed by eseidel, tkent) Reset Gtk and Chromium to platform default between tests 

Looks OK to me.  Why doesn't this affect tests?  Can we write a test this would affect?
Comment 17 WebKit Review Bot 2010-05-24 22:02:46 PDT
Attachment 56970 [details] did not build on chromium:
Build output: http://webkit-commit-queue.appspot.com/results/2315575
Comment 18 Antonio Gomes 2010-05-24 22:14:41 PDT
(In reply to comment #17)
> Attachment 56970 [details] did not build on chromium:
> Build output: http://webkit-commit-queue.appspot.com/results/2315575

s/EditingBehaviorWindows/EditingBehaviorWin/g , will fix before land.

(In reply to comment #16)
> (From update of attachment 56970 [details])
> Looks OK to me.  Why doesn't this affect tests?  Can we write a test this would affect?

@Eric: it will affect tests, for example as soon as https://bugs.webkit.org/attachment.cgi?id=56608 re-lands and all tests cited in comment #12 got changed to use the setEditingBehaviour API of LayoutTestController instead of the user agent string
Comment 19 Antonio Gomes 2010-05-25 06:16:57 PDT
Comment on attachment 56970 [details]
(committed with r60158, reviewed by eseidel, tkent) Reset Gtk and Chromium to platform default between tests 

Clearing flags on attachment: 56970

Committed r59861: <http://trac.webkit.org/changeset/59861>
Comment 20 Antonio Gomes 2010-05-25 06:18:52 PDT
Comment on attachment 56970 [details]
(committed with r60158, reviewed by eseidel, tkent) Reset Gtk and Chromium to platform default between tests 

err:

Committed r60158: <http://trac.webkit.org/changeset/60158>
Comment 21 WebKit Review Bot 2010-05-25 06:51:10 PDT
http://trac.webkit.org/changeset/60158 might have broken GTK Linux 32-bit Release
The following changes are on the blame list:
http://trac.webkit.org/changeset/60158
http://trac.webkit.org/changeset/60159
Comment 22 Ojan Vafai 2010-05-25 09:12:01 PDT
(In reply to comment #10)
> +        editingBehavior settings needs to be set back to a reasonable default between tests
> 
> FWIW, I'd expect "reasonable default" to be the same on all platforms. What's the value in making it different?

For non-DRT, the code in Settings.cpp currently has a different default for Mac and everyone else. So, DRT should, at reset the value to that default. I wouldn't want DRT always defaulting to EditingMacBehavior because then we lose test coverage. For example, if someone accidentally modifies the EditingWinBehavior behavior, then only the tests that call setEditingBehavior would actually test that.

I think it's unfortunate that we have setEditingBehavior calls littered throughout the code though. I'd prefer that we had Settings::resetEditingBehavior or Settings::defaultEditingBehavior so that we have the logic of which editing behavior to use in one place. Eric pushed back on this on #webkit saying that this would be different than all other DRT setters. I don't have enough experience hacking on DRT to say.

(In reply to comment #12)
> How many tests like that are there? What we basically need is make two or three copies of each, and set different behaviors in those.

Now that we've exposed setEditingBehavior, we can modify those tests to test both EditingMacBehavior and EditingWinBehavior. There's no need for them to have platform specific expectations now.
Comment 23 Alexey Proskuryakov 2010-05-25 09:33:44 PDT
> I wouldn't want DRT always defaulting to EditingMacBehavior because then we lose test coverage.

I disagree with that. We need reproducible results more than we need accidental testing - running tests on Mac should be as close to running them on other platforms as possible.
Comment 24 Antonio Gomes 2010-05-25 12:58:27 PDT
I think now that Gtk, Mac, Win, Chromium and soon Qt (see bug 39680) are in, we can revert back r59852 and r59857, and gradually adjust other call sites (see comment #13) to use the new setEditingBehavior.

... and a some point close this bug as FIXED
Comment 25 Ojan Vafai 2010-05-25 13:10:50 PDT
(In reply to comment #23)
> > I wouldn't want DRT always defaulting to EditingMacBehavior because then we lose test coverage.
> 
> I disagree with that. We need reproducible results more than we need accidental testing - running tests on Mac should be as close to running them on other platforms as possible.

If a test fails on Windows because of the editing behavior, then one of two things should happen:
1. There's a bug when using EditingWinBehavior and that should be fixed.
2. The test unintentionally is testing platform-specific behavior and the test should be fixed to test both EditingMacBehavior and EditingWinBehavior.

As long as the above happens, running tests from a Mac is fairly close to running them on other platforms. A given commit might cause a failure on a non-mac port, but the fix will mean broader test coverage. We have bots specifically to ensure that the port-specific code is tested. I don't see why it makes sense for platform-specific code to not get the same testing.
Comment 26 Antonio Gomes 2010-06-08 13:29:07 PDT
(In reply to comment #24)
> I think now that Gtk, Mac, Win, Chromium and soon Qt (see bug 39680) are in, we can revert back r59852 and r59857, and gradually adjust other call sites (see comment #13) to use the new setEditingBehavior.

@Martin, plans to re-land these two backed out revisions? they should be safe to go now.
Comment 27 Antonio Gomes 2010-06-08 13:43:54 PDT
(In reply to comment #25)
> (In reply to comment #23)
> > > I wouldn't want DRT always defaulting to EditingMacBehavior because then we lose test coverage.

If all platform specific editing tests are going through all code paths possible then it would make sense to default DRT generally to the same editing behavior type (being it "mac" or not). However the condition is not what happens currentl, and due to that I also agree that as tests are today, having them all sharing the same default would lose coverage.

That is indeed something that could change in the future though, and I could have a look at that.

For example, if we had at least one layout test for each of the platform specific editing behaviors, and each test were going through all code paths, then we would be safe to default all DRTs to the same value.
Comment 28 Martin Robinson 2010-06-08 13:49:09 PDT
Committed r60865: <http://trac.webkit.org/changeset/60865>
Comment 29 Antonio Gomes 2010-10-12 05:55:29 PDT
Yesterday, I started converting all tests relying on platform specific (for now, Mac x Win) behavior to run with the LayoutTestController::setEditingBehavior machinery. I've fixed the following ones so far:

- bug 47468: editing/selection/extend-after-mouse-selection.html
- bug 47471: editing/selection/script-tests/click-in-margins-inside-editable-div.js
- bug 47472: editing/selection/script-tests/click-in-padding-with-multiple-line-boxes.js


It basically means that instead of having mac, win and qt expected results, we now have only one cross platform expected result file, since all platform behaviors are being tested. I will continue this work along the week.

As a side note, it would be good to turn tests like editing/deleting/delete-by-word-001.html and editing/deleting/delete-by-word-002.html to not dump the render tree, but dump as text. I will try this as well.

> (In reply to comment #12)
> > How many tests like that are there? What we basically need is make two or three copies of each, and set different behaviors in those.
> 
> ~14 tests in /editing.
> 
> $ grep -nHR  navigator.userAgent.search LayoutTests/editing/
> - LayoutTests/editing/selection/script-tests/click-in-padding-with-multiple-line-boxes.js
> - LayoutTests/editing/selection/script-tests/click-in-margins-inside-editable-div.js
> - LayoutTests/editing/selection/script-tests/shift-click.js
> - LayoutTests/editing/selection/extend-selection-after-double-click.html
> - LayoutTests/editing/selection/extend-after-mouse-selection.html
> - LayoutTests/editing/selection/move-begin-end.html
> - LayoutTests/editing/selection/5195166-1.html
> - LayoutTests/editing/input/option-page-up-down.html
> - LayoutTests/editing/undo/undo-deleteWord.html
> - LayoutTests/editing/deleting/delete-by-word-001.html
> - LayoutTests/editing/deleting/delete-by-word-002.html
Comment 30 Antonio Gomes 2010-10-22 07:22:57 PDT
> As a side note, it would be good to turn tests like editing/deleting/delete-by-word-001.html and editing/deleting/delete-by-word-002.html to not dump the render tree, but dump as text. I will try this as well.

Filed bug 48130 and bug 48131 about these two.