Open Bug 1279771 Opened 8 years ago Updated 2 years ago

Issue with execCommand('copy') in change events in e10s

Categories

(Core :: DOM: Events, defect, P3)

49 Branch
x86
Windows 8.1
defect

Tracking

()

Tracking Status
e10s + ---
firefox48 --- affected
firefox49 --- affected
firefox50 --- affected

People

(Reporter: ulrich.b, Unassigned)

References

Details

Attachments

(1 file, 1 obsolete file)

User Agent: Mozilla/5.0 (Windows NT 6.3; WOW64; rv:47.0) Gecko/20100101 Firefox/47.0
Build ID: 20160604131506

Steps to reproduce:

See the following reproduction sample.

https://jsfiddle.net/Ulrich/8qd5x23h/


Actual results:

In Firefox 49a2 (2016-06-11) *with enabled e10s* the "execCommand('copy')" in the "change" event handler returns "false" and doesn't copy the value to the clipboard.

With disabled e10s it works.

Note that the "execCommand('copy')" during an "input" event works with e10s.

Tested on Windows 8.1.


Expected results:

"execCommand('copy')" should work with enabled e10s in an user induced "change" event.
OS: Unspecified → Windows 8.1
Hardware: Unspecified → x86
tracking-e10s: --- → ?
Component: Untriaged → Editor
Product: Firefox → Core
Bug 1012662 fixed the "execCommand('copy')" in non-e10s mode, but not fixed in e10s mode.
Blocks: 1012662
Status: UNCONFIRMED → NEW
Component: Editor → DOM: Events
Ever confirmed: true
Flags: needinfo?(michael)
Flags: needinfo?(ehsan)
The problem in this case is that the execCommand('copy') event requires EventStateManager::StartHandlingUserInput(); to have been called higher in the stack.

This isn't happening with the select element because the dropdown is displayed in the parent process, and thus the input event is only occurring in the parent process. The child process isn't recorded as handling input when the callback is being run.

To fix this this handler: https://dxr.mozilla.org/mozilla-central/source/toolkit/modules/SelectContentHelper.jsm#114 needs to be wrapped in calls to StartHandlingUserInput and StopHandlingUserInput. Unfortunately currently those functions are only visible to C++.

Ideally we'd expose a `withHandlingUserInput(cb)` function which would call the cb closure surrounding it with calls to StartHandlingUserInput and StopHandlingUserInput to chrome JS. I'm not sure what the best way to do this would be right now, as we'd need to expose it on some object, and I'm not sure which one to choose.
Flags: needinfo?(michael)
Flags: needinfo?(ehsan)
Mike, how serious is this in your opinion?
Flags: needinfo?(miket)
Here's what I'm seeing on my machine:
              

                   | change | input |
-------------------------------------
Mac Fx 49 e10s     | false  | true  |
Mac Fx 49 non-e10s | true   | true  |
Win Fx 49 e10s     | false  | true  |
Win Fx 49 non-e10s | true   | true  |
Mac Chrome 53      | false  | true  |
Mac Safari Te.Prev | false  | true  |
Win Chrome 53      | true   | true  |
Edge 38            | false  | false |


So on Mac, e10s aligns with what Chrome and Safari do today. 

On Windows, e10s diverges from what Chrome does. I'm guessing Edge just doesn't support execCommand('copy') yet.

Given the divergence between platforms, I'd be surprised if this breaks web-facing content (unless that relied heavily on UA sniffing).

ulrichb, are you aware of any sites that this change breaks?
Flags: needinfo?(miket) → needinfo?(ulrich.b)
@Mike 
I mentioned this issue during testing an internal application in Fx Dev Edition with enabled e10s. The application uses the same pattern with a `select`-element and the `change`-event as in my repro sample.

Please note that on the Windows platform the `execCommand('copy')` inside of a `change`-event is supported in Chrome, Fx w/o e10s, and IE (11). => In the vast majority of used browsers, and therefor I would expect more users facing this issue as soon a e10s gets into production. 

BTW: The fact, that Microsoft dropped support for `execCommand('copy')` in Edge at all is now a second issue in our internal application :)
Flags: needinfo?(ulrich.b)
Thanks Ulrich. I'm curious how you all are working around Chrome and Safari on Mac, since they don't support this using a change event?
Flags: needinfo?(ulrich.b)
>                    | change | input |
> -------------------------------------
> Mac Fx 49 e10s     | false  | true  |
> Mac Fx 49 non-e10s | true   | true  |
> Win Fx 49 e10s     | false  | true  |
> Win Fx 49 non-e10s | true   | true  |
> Mac Chrome 53      | false  | true  |
> Mac Safari Te.Prev | false  | true  |
> Win Chrome 53      | true   | true  |
> Edge 38            | false  | false |

We need to fix the difference between e10s and non-e10s, but due to the mixed results not blocking.
Priority: -- → P2
I should have a patch for this up shortly, just need to write some tests etc.
Assignee: nobody → michael
Attachment #8767725 - Flags: review?(enndeakin) → review+
Pushed by michael@thelayzells.com:
https://hg.mozilla.org/integration/mozilla-inbound/rev/fe73f3d7e160
Treat change events triggered by changing <select> element selections as user-initiated in e10s, r=enndeakin
I notice that nsIDOMWindowUtils already has a setHandlingUserInput method. This patch should be changed to just use the existing method rather than add a new one.
(In reply to Neil Deakin from comment #12)
> I notice that nsIDOMWindowUtils already has a setHandlingUserInput method.
> This patch should be changed to just use the existing method rather than add
> a new one.

Thank you for noticing that! I can't believe I missed it when I was writing the initial patch.
I'll have a new patch up in a minute.
This new patch should theoretically fix both the timeout issues on infra, as well as remove the unnecessary new idl functions on nsDOMWindowUtils
Attachment #8768954 - Flags: review?(enndeakin)
Attachment #8767725 - Attachment is obsolete: true
Attachment #8768954 - Flags: review?(enndeakin) → review+
(In reply to Michael Layzell [:mystor] [:mrl] from comment #14)
> Created attachment 8768954 [details] [diff] [review]
> Treat change events triggered by changing <select> element selections as
> user-initiated in e10s
> 
> This new patch should theoretically fix both the timeout issues on infra, as
> well as remove the unnecessary new idl functions on nsDOMWindowUtils

I'm coming back to this patch for the first time in a while. IIRC I stopped working on this patch because the test consistently failed on infra, but not in my local builds, and I had no idea what to do. The problem was that when the test was running the parent process would try to discover the context menu to click on it, but the context menu would not be there. 

Neil, do you have any ideas about how we could potentially redesign the test such that it doesn't depend on unreliable timing of things such as context menus appearing in the chrome process?
Flags: needinfo?(enndeakin)
I'm unclear how the patch here relates to context menus. Do you mean the popup for the <select>? Do you want to wait for the popup to open? Perhaps load the chrome script before clicking and have it wait for the popupshown event.

Alternatively, maybe it would be easier to make this a browser test (part of browser_selectpopup.js)
Flags: needinfo?(enndeakin)
Moving to p3 because no activity for at least 1 year(s).
See https://github.com/mozilla/bug-handling/blob/master/policy/triage-bugzilla.md#how-do-you-triage for more information
Priority: P2 → P3
Flags: needinfo?(ulrich.b)

Unassigning as I don't have time to work on this.

Assignee: nika → nobody
Severity: normal → S3
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: