Bug 146695 - REGRESSION (r183133-r183138): Secondary clicking in whitespace selects preceding word
Summary: REGRESSION (r183133-r183138): Secondary clicking in whitespace selects preced...
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: WebCore Misc. (show other bugs)
Version: 528+ (Nightly build)
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Brent Fulgham
URL:
Keywords: InRadar
Depends on: 146836
Blocks:
  Show dependency treegraph
 
Reported: 2015-07-07 15:07 PDT by Brent Fulgham
Modified: 2015-07-10 17:06 PDT (History)
7 users (show)

See Also:


Attachments
Patch (1.89 KB, patch)
2015-07-07 15:13 PDT, Brent Fulgham
no flags Details | Formatted Diff | Diff
Patch (4.78 KB, patch)
2015-07-08 11:31 PDT, Brent Fulgham
no flags Details | Formatted Diff | Diff
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 Details
Patch (5.02 KB, patch)
2015-07-09 10:04 PDT, Brent Fulgham
no flags Details | Formatted Diff | Diff
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 Details
Patch v3 (Should not timeout even in failing case) (5.10 KB, patch)
2015-07-09 12:35 PDT, Brent Fulgham
no flags Details | Formatted Diff | Diff
Patch v4 (Guard against undefined selections) (5.44 KB, patch)
2015-07-09 12:49 PDT, Brent Fulgham
no flags Details | Formatted Diff | Diff
Patch (5.44 KB, patch)
2015-07-09 12:51 PDT, Brent Fulgham
no flags Details | Formatted Diff | Diff
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 Details
Patch (3.78 KB, patch)
2015-07-10 15:35 PDT, Brent Fulgham
no flags Details | Formatted Diff | Diff
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+
Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Brent Fulgham 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.
Comment 1 Brent Fulgham 2015-07-07 15:07:52 PDT
<rdar://problem/21441466>
Comment 2 Brent Fulgham 2015-07-07 15:13:47 PDT
Created attachment 256324 [details]
Patch
Comment 3 Brent Fulgham 2015-07-07 15:33:56 PDT
Committed r186480: <http://trac.webkit.org/changeset/186480>
Comment 4 Simon Fraser (smfr) 2015-07-07 15:37:52 PDT
No test?
Comment 5 Tim Horton 2015-07-07 15:39:24 PDT
Comment on attachment 256324 [details]
Patch

Can we get a layout test for both modes?
Comment 6 Brent Fulgham 2015-07-08 11:31:55 PDT
Reopening to attach new patch.
Comment 7 Brent Fulgham 2015-07-08 11:31:57 PDT
Created attachment 256389 [details]
Patch
Comment 8 Tim Horton 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.
Comment 9 Build Bot 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
Comment 10 Build Bot 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
Comment 11 Brent Fulgham 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!
Comment 12 Brent Fulgham 2015-07-09 10:04:58 PDT
Created attachment 256483 [details]
Patch
Comment 13 Build Bot 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
Comment 14 Build Bot 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
Comment 15 Brent Fulgham 2015-07-09 12:35:24 PDT
Created attachment 256500 [details]
Patch v3 (Should not timeout even in failing case)
Comment 16 Tim Horton 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.
Comment 17 Brent Fulgham 2015-07-09 12:49:48 PDT
Created attachment 256501 [details]
Patch v4 (Guard against undefined selections)
Comment 18 Brent Fulgham 2015-07-09 12:51:22 PDT
Created attachment 256502 [details]
Patch
Comment 19 Build Bot 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
Comment 20 Build Bot 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
Comment 21 Ryosuke Niwa 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.
Comment 22 Alexey Proskuryakov 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?
Comment 23 Brent Fulgham 2015-07-10 10:06:11 PDT
The timeouts in my test case are caused by Bug 146836.
Comment 24 Brent Fulgham 2015-07-10 15:35:51 PDT
Created attachment 256619 [details]
Patch
Comment 25 Brent Fulgham 2015-07-10 16:12:04 PDT
Created attachment 256622 [details]
Patch (Reuploaded to run EWS now that Bug 146695 is fixed)
Comment 26 Tim Horton 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?
Comment 27 Brent Fulgham 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.
Comment 28 Brent Fulgham 2015-07-10 17:06:04 PDT
Committed r186696: <http://trac.webkit.org/changeset/186696>