Bug 146695

Summary: REGRESSION (r183133-r183138): Secondary clicking in whitespace selects preceding word
Product: WebKit Reporter: Brent Fulgham <bfulgham>
Component: WebCore Misc.Assignee: Brent Fulgham <bfulgham>
Status: RESOLVED FIXED    
Severity: Normal CC: ap, bfulgham, buildbot, rniwa, simon.fraser, thorton, webkit-bug-importer
Priority: P2 Keywords: InRadar
Version: 528+ (Nightly build)   
Hardware: Unspecified   
OS: Unspecified   
Bug Depends on: 146836    
Bug Blocks:    
Attachments:
Description Flags
Patch
none
Patch
none
Archive of layout-test-results from ews106 for mac-mavericks-wk2
none
Patch
none
Archive of layout-test-results from ews106 for mac-mavericks-wk2
none
Patch v3 (Should not timeout even in failing case)
none
Patch v4 (Guard against undefined selections)
none
Patch
none
Archive of layout-test-results from ews107 for mac-mavericks-wk2
none
Patch
none
Patch (Reuploaded to run EWS now that Bug 146695 is fixed) thorton: review+

Brent Fulgham
Reported 2015-07-07 15:07:32 PDT
While resolving Bug 143958 I introduced a problem with using the context menu to paste content into an editable fields. With the new changes, if you right-clicked in a whitespace area with the intention of pasting content, the new selection logic will hop over the whitespace and grab the preceding word. To fix this, we should use the original behavior with editable fields so that we can leave our insertion point where it is when pasting.
Attachments
Patch (1.89 KB, patch)
2015-07-07 15:13 PDT, Brent Fulgham
no flags
Patch (4.78 KB, patch)
2015-07-08 11:31 PDT, Brent Fulgham
no flags
Archive of layout-test-results from ews106 for mac-mavericks-wk2 (559.27 KB, application/zip)
2015-07-08 12:09 PDT, Build Bot
no flags
Patch (5.02 KB, patch)
2015-07-09 10:04 PDT, Brent Fulgham
no flags
Archive of layout-test-results from ews106 for mac-mavericks-wk2 (558.25 KB, application/zip)
2015-07-09 10:42 PDT, Build Bot
no flags
Patch v3 (Should not timeout even in failing case) (5.10 KB, patch)
2015-07-09 12:35 PDT, Brent Fulgham
no flags
Patch v4 (Guard against undefined selections) (5.44 KB, patch)
2015-07-09 12:49 PDT, Brent Fulgham
no flags
Patch (5.44 KB, patch)
2015-07-09 12:51 PDT, Brent Fulgham
no flags
Archive of layout-test-results from ews107 for mac-mavericks-wk2 (591.64 KB, application/zip)
2015-07-09 13:51 PDT, Build Bot
no flags
Patch (3.78 KB, patch)
2015-07-10 15:35 PDT, Brent Fulgham
no flags
Patch (Reuploaded to run EWS now that Bug 146695 is fixed) (3.78 KB, patch)
2015-07-10 16:12 PDT, Brent Fulgham
thorton: review+
Brent Fulgham
Comment 1 2015-07-07 15:07:52 PDT
Brent Fulgham
Comment 2 2015-07-07 15:13:47 PDT
Brent Fulgham
Comment 3 2015-07-07 15:33:56 PDT
Simon Fraser (smfr)
Comment 4 2015-07-07 15:37:52 PDT
No test?
Tim Horton
Comment 5 2015-07-07 15:39:24 PDT
Comment on attachment 256324 [details] Patch Can we get a layout test for both modes?
Brent Fulgham
Comment 6 2015-07-08 11:31:55 PDT
Reopening to attach new patch.
Brent Fulgham
Comment 7 2015-07-08 11:31:57 PDT
Tim Horton
Comment 8 2015-07-08 11:56:55 PDT
Comment on attachment 256389 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=256389&action=review > LayoutTests/platform/mac/editing/selection/context-menu-select-editability.html:27 > + var x = input.offsetParent.offsetLeft + input.offsetLeft + 200; > + var y = input.offsetParent.offsetTop + input.offsetTop + input.offsetHeight / 2; IIRC in previous tests, I used <spans> to give JS something to target so that you could get rid of the 200 here and just read offsets/clientRects/whatever (and use the center). Might be less fragile.
Build Bot
Comment 9 2015-07-08 12:09:54 PDT
Comment on attachment 256389 [details] Patch Attachment 256389 [details] did not pass mac-wk2-ews (mac-wk2): Output: http://webkit-queues.appspot.com/results/5844986906017792 New failing tests: platform/mac/editing/selection/context-menu-select-editability.html
Build Bot
Comment 10 2015-07-08 12:09:57 PDT
Created attachment 256392 [details] Archive of layout-test-results from ews106 for mac-mavericks-wk2 The attached test failures were seen while running run-webkit-tests on the mac-wk2-ews. Bot: ews106 Port: mac-mavericks-wk2 Platform: Mac OS X 10.9.5
Brent Fulgham
Comment 11 2015-07-09 10:04:42 PDT
Comment on attachment 256389 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=256389&action=review >> LayoutTests/platform/mac/editing/selection/context-menu-select-editability.html:27 >> + var y = input.offsetParent.offsetTop + input.offsetTop + input.offsetHeight / 2; > > IIRC in previous tests, I used <spans> to give JS something to target so that you could get rid of the 200 here and just read offsets/clientRects/whatever (and use the center). > > Might be less fragile. EWS shows that my test *is* fragile, so I will try this!
Brent Fulgham
Comment 12 2015-07-09 10:04:58 PDT
Build Bot
Comment 13 2015-07-09 10:42:37 PDT
Comment on attachment 256483 [details] Patch Attachment 256483 [details] did not pass mac-wk2-ews (mac-wk2): Output: http://webkit-queues.appspot.com/results/4514907475148800 New failing tests: platform/mac/editing/selection/context-menu-select-editability.html
Build Bot
Comment 14 2015-07-09 10:42:40 PDT
Created attachment 256488 [details] Archive of layout-test-results from ews106 for mac-mavericks-wk2 The attached test failures were seen while running run-webkit-tests on the mac-wk2-ews. Bot: ews106 Port: mac-mavericks-wk2 Platform: Mac OS X 10.9.5
Brent Fulgham
Comment 15 2015-07-09 12:35:24 PDT
Created attachment 256500 [details] Patch v3 (Should not timeout even in failing case)
Tim Horton
Comment 16 2015-07-09 12:40:34 PDT
Comment on attachment 256500 [details] Patch v3 (Should not timeout even in failing case) View in context: https://bugs.webkit.org/attachment.cgi?id=256500&action=review > LayoutTests/platform/mac/editing/selection/context-menu-select-editability.html:40 > + { This { is not where it belongs.
Brent Fulgham
Comment 17 2015-07-09 12:49:48 PDT
Created attachment 256501 [details] Patch v4 (Guard against undefined selections)
Brent Fulgham
Comment 18 2015-07-09 12:51:22 PDT
Build Bot
Comment 19 2015-07-09 13:51:37 PDT
Comment on attachment 256502 [details] Patch Attachment 256502 [details] did not pass mac-wk2-ews (mac-wk2): Output: http://webkit-queues.appspot.com/results/5623346192449536 New failing tests: platform/mac/editing/selection/context-menu-select-editability.html
Build Bot
Comment 20 2015-07-09 13:51:40 PDT
Created attachment 256508 [details] Archive of layout-test-results from ews107 for mac-mavericks-wk2 The attached test failures were seen while running run-webkit-tests on the mac-wk2-ews. Bot: ews107 Port: mac-mavericks-wk2 Platform: Mac OS X 10.9.5
Ryosuke Niwa
Comment 21 2015-07-09 14:57:58 PDT
Comment on attachment 256502 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=256502&action=review Looks like the test is failing on the bot? > LayoutTests/platform/mac/editing/selection/context-menu-select-editability.html:32 > + var target = document.getElementById("readOnlyWhitespace"); > + > + var x = target.offsetParent.offsetLeft + target.offsetLeft + target.clientWidth / 2; > + var y = target.offsetParent.offsetTop + target.offsetTop + target.clientHeight / 2; > + > + if (!window.eventSender) { > + testRunner.notifyDone(); > + return; > + } > + Can we extract a helper function to do this? It's not great to repeat it here and in editableTest > LayoutTests/platform/mac/editing/selection/context-menu-select-editability.html:43 > + var selection = window.getSelection(); > + if (typeof selection != 'undefined') { > + readOnlySelectionContents = selection.toString(); > + } else { > + readOnlySelectionContents = ''; > + } window.getSelection() is never undefined. > LayoutTests/platform/mac/editing/selection/context-menu-select-editability.html:56 > + readOnlySelectionContents = window.getSelection().toString(); > + if (readOnlySelectionContents.length) { > + readOnlySelectionContents.trim(); > + > + // We expect it to select 'New York, New York' based on dictionary lookup > + if (readOnlySelectionContents == "New York, New York") > + testPassed('ReadOnly: SUCCESS'); > + else > + testFailed('Did not get "New York, New York". Got: ' + readOnlySelectionContents); > + } else { > + testFailed("Read-only selection had no range."); > + } Why don't we just do: shouldBe("getSelection().toString().trim()", '"New York, New York"') instead? > LayoutTests/platform/mac/editing/selection/context-menu-select-editability.html:71 > + if (!window.eventSender) { > + testRunner.notifyDone(); > + return; > + } We should check this condition in onLoad() function instead.
Alexey Proskuryakov
Comment 22 2015-07-10 04:42:29 PDT
Comment on attachment 256502 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=256502&action=review > LayoutTests/platform/mac/editing/selection/context-menu-select-editability-expected.txt:15 > +TEST COMPLETE > + > + > + > +PASS Editable: SUCCESS > +PASS ReadOnly: SUCCESS It's wrong to have PASS output after TEST COMPLETE. Please use jsTestIsAsync and finishJSTest() instead of testRunner methods. > LayoutTests/platform/mac/editing/selection/context-menu-select-editability.html:101 > + testRunner.dumpAsText(); This is also unneeded, js-test-pre does that automatically. > LayoutTests/platform/mac/editing/selection/context-menu-select-editability.html:105 > + setTimeout(editableTest, 0); This looks suspect. What is the operation that we need to wait for after loading?
Brent Fulgham
Comment 23 2015-07-10 10:06:11 PDT
The timeouts in my test case are caused by Bug 146836.
Brent Fulgham
Comment 24 2015-07-10 15:35:51 PDT
Brent Fulgham
Comment 25 2015-07-10 16:12:04 PDT
Created attachment 256622 [details] Patch (Reuploaded to run EWS now that Bug 146695 is fixed)
Tim Horton
Comment 26 2015-07-10 16:49:02 PDT
Comment on attachment 256622 [details] Patch (Reuploaded to run EWS now that Bug 146695 is fixed) View in context: https://bugs.webkit.org/attachment.cgi?id=256622&action=review > LayoutTests/platform/mac/editing/selection/context-menu-select-editability.html:30 > + // esc key to kill the context menu > + eventSender.keyDown(String.fromCharCode(0x001B), null); Do you still need this now that contextClick doesn't actually pop a context menu?
Brent Fulgham
Comment 27 2015-07-10 16:52:00 PDT
Comment on attachment 256622 [details] Patch (Reuploaded to run EWS now that Bug 146695 is fixed) View in context: https://bugs.webkit.org/attachment.cgi?id=256622&action=review >> LayoutTests/platform/mac/editing/selection/context-menu-select-editability.html:30 >> + eventSender.keyDown(String.fromCharCode(0x001B), null); > > Do you still need this now that contextClick doesn't actually pop a context menu? You're right. I'll take this out.
Brent Fulgham
Comment 28 2015-07-10 17:06:04 PDT
Note You need to log in before you can comment on or make changes to this bug.