New issue
Advanced search Search tips

Issue 831462 link

Starred by 1 user

Issue metadata

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



Sign in to add a comment

Developer Tools "capture screenshot" unexpectedly triggers a window "beforeunload" event

Reported by kan...@cakoose.com, Apr 11 2018

Issue description

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

Steps to reproduce the problem:
1. Open a tab with the following HTML:

<html>
<script>
window.onbeforeunload = ev => console.log('beforeunload');
</script>
</html>

2. Press Cmd-Option-J to open the JavaScript console.

3. Press Cmd-Shift-P to show the command menu.  Type in "Capture Screenshot" and select that option.

4. The screenshot will be taken (expected).

5. 'beforeunload' is printed to the console (unexpected).

What is the expected behavior?

What went wrong?
I didn't expect "Capture Screenshot" to trigger "beforeunload".  Is that by design?

We use 'beforeunload' to trigger certain app shutdown behaviors.  Is that a mistake?

Did this work before? N/A 

Chrome version: 65.0.3325.181  Channel: stable
OS Version: OS X 10.13.3
Flash Version:
 
Cc: caseq@chromium.org dgozman@chromium.org
Owner: pfeldman@chromium.org
Status: Assigned (was: Unconfirmed)
This one is kind of fun:

- as per the spec (dunno why), beforeunload needs to be issued prior to the navigation request
- screenshot capture is implemented as clicking the download link in devtools
- devtools delegates all OpenURL requests including this download one into the inspected page

Owner: dgozman@chromium.org
Cc: -dgozman@chromium.org japhet@chromium.org
Nate, do you have an idea why clicking on a link which results in a download triggers beforeunload handler? We have <a download="filename"> link, so it should be crystal clear there is no navigation involved.

Sign in to add a comment