New issue
Advanced search Search tips
Note: Color blocks (like or ) mean that a user may not be available. Tooltip shows the reason.

Issue 677512 link

Starred by 2 users

Issue metadata

Status: Available
Owner: ----
Cc:
Components:
EstimatedDays: ----
NextAction: ----
OS: Mac
Pri: 2
Type: Bug-Regression



Sign in to add a comment

Closing a dialog can lose the user gesture

Reported by kyaw...@yathit.com, Dec 29 2016

Issue description

UserAgent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/55.0.2883.95 Safari/537.36

Steps to reproduce the problem:
1. install https://chrome.google.com/webstore/detail/yathit-sugarcrm-for-gmail/iccdnijlhdogaccaiafdpjmbakdcdakk
2. Setup sugarcrm and login to gmail
3. upload an attachment

What is the expected behavior?
Prompt permission dialog

What went wrong?
"This function must be called during a user gesture" Error thrown in background page.

Did this work before? N/A 

Does this work in other browsers? No
 chrome.permissions.request must be called during user gesture. User gesture are carried from Chrome UI to background page. If a permission require, it bering up permission dialog box.

My extension used to work fine for years, now last two week, the function throw with "This function must be called during a user gesture" even though it is called with dialog.close button click. 

the issue is not appear in Chromium Version 53.0.2766.0 (64-bit), but appear in Version 57.0.2958.0 canary (64-bit) and Version 55.0.2883.95 (64-bit)

Chrome version: 55.0.2883.95  Channel: stable
OS Version: OS X 10.11.6
Flash Version: Shockwave Flash 24.0 r0

It is possible but very time consuming to make minimal chrome extension which has persistent channel, ui and permission request. 

I am *pretty* sure this is Chrome regression since I do not update my extension during the time.

Anyways, just drop a comment here, if a minimal test case is necessary to reproduce the issue.

thanks.
 
Cc: brajkumar@chromium.org
Components: Platform>Extensions
Labels: Needs-Feedback
Tested this issue on Ubuntu 14.04 using chrome stable M55-55.0.2883.87 by following steps mentioned below.

1. Installed chrome extension https://chrome.google.com/webstore/detail/yathit-sugarcrm-for-gmail/iccdnijlhdogaccaiafdpjmbakdcdakk
2. Clicked on the extension icon and navigated to options
3. Clicked on Login and selected gmail account
4. Observed no behavior after selecting the gmail account.

kyawtun@ As you mentioned in the original comment, Could you please provide a minimal test case of this issue for further triaging.

Thanks!

Comment 2 by kyaw...@yathit.com, Jan 25 2017

Here is solid proof of recent bug. Screenshoot http://g.recordit.co/HasKzDtlFI.gif 

Please install attached extension. 

A Positive and an Test buttons should show on any web page from the content script.

Click 'Positive', it request optional permission.

Click 'Test', it fail to request optional permission saying "This function must be called during a user gesture", even though it is invoked by user gesture. 

This is working before around Chrome 53. 




permission-req-bug.zip
11.7 KB Download

Comment 3 by kyaw...@yathit.com, Jan 25 2017

Tinkering workaround with window.confirm https://github.com/yathit/permission-req-bug

Clearly it is user gesture, but working :-(

I should go with <all_urls> permission. Sweet!!!

Comment 4 by woxxom@gmail.com, Jan 25 2017

Bisect using the extension from #2:
420838 (good) - 420839 (bad), 55.0.2872.0
https://chromium.googlesource.com/chromium/src/+log/2e70970b..9027b8ba?pretty=fuller
The only change in the range is r420839 "Queue a close event for dialog.close" -  issue 380087 .
Project Member

Comment 5 by sheriffbot@chromium.org, Feb 1 2017

Labels: -Needs-Feedback Needs-Review
Owner: brajkumar@chromium.org
Thank you for providing more feedback. Adding requester "brajkumar@chromium.org" for another review and adding "Needs-Review" label for tracking.

For more details visit https://www.chromium.org/issue-tracking/autotriage - Your friendly Sheriffbot

Comment 6 by cda...@chromium.org, Mar 13 2017

Cleaning up "Needs-Review" label as we are not using this label for triage. Ref  bug 684919 

Comment 7 by cda...@chromium.org, Mar 13 2017

Labels: -Needs-Review

Comment 8 by kyaw...@yathit.com, Apr 17 2017

Could someone take a look?
Cc: xing...@intel.com
Labels: hasbisect
Owner: ----
Status: Untriaged (was: Unconfirmed)
As per bisect information provided in comment #4 adding @xing.xu for more updates on this issue.

Thanks!
Labels: -Type-Bug Type-Bug-Regression
Owner: skobes@chromium.org
Status: Assigned (was: Untriaged)
Summary: Closing a dialog can lose the user gesture (was: This function must be called during a user gesture)
Thanks for the bisect, woxxom@!  That definitely sounds like the culprit.

By asynchronously closing the dialog, I'm suspecting we lose track of the fact that there was a user gesture being processed, which is what we use to determine if an extension function is called with a user gesture.  We need to curry that information through to the dialog close (e.g. with user gesture tokens).

Assigning to skobes@, who reviewed r420839, and updating the summary.

Comment 11 by xing...@intel.com, May 19 2017

Hi, I tried to revert this patch locally on Ubuntu as follows, "This function must be called during a user gesture" will gone:
--- a/third_party/WebKit/Source/core/html/HTMLDialogElement.cpp
+++ b/third_party/WebKit/Source/core/html/HTMLDialogElement.cpp
@@ -125,7 +125,7 @@ void HTMLDialogElement::CloseDialog(const String& return_value) {
   if (!return_value.IsNull())
     return_value_ = return_value;
 
-  ScheduleCloseEvent();
+  DispatchScopedEvent(Event::Create(EventTypeNames::close));
 }

Issue analyze:
PermissionsRequestFunction::RunAsync(chrome\browser\extensions\api\permissions\Permissions_api.cc) will check if current call is inside a user_gesture(). If not, will throw this error.

So If we queue the dialog.close as https://html.spec.whatwg.org/multipage/forms.html#close-the-dialog does, this dialog.close will be outside of a user_gesture(). That's why error being throw.

I have little about the extension permission, any other idea about this?
Cc: skobes@chromium.org
Owner: ----
Status: Available (was: Assigned)
Project Member

Comment 13 by sheriffbot@chromium.org, May 24 2018

Labels: Hotlist-Recharge-Cold
Status: Untriaged (was: Available)
This issue has been Available for over a year. If it's no longer important or seems unlikely to be fixed, please consider closing it out. If it is important, please re-triage the issue.

Sorry for the inconvenience if the bug really should have been left as Available.

For more details visit https://www.chromium.org/issue-tracking/autotriage - Your friendly Sheriffbot
Status: Available (was: Untriaged)
This still needs to be fixed. Marking available.

Sign in to add a comment