Skip to content

Commit

Permalink
docs(api.md): clarify downloads lifetime (#1698)
Browse files Browse the repository at this point in the history
  • Loading branch information
aslushnikov committed Apr 8, 2020
1 parent 118333a commit d21e2c9
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions docs/api.md
Expand Up @@ -738,7 +738,9 @@ Emitted when the JavaScript [`DOMContentLoaded`](https://developer.mozilla.org/e
#### event: 'download'
- <[Download]>

Emitted when attachment is downloaded. User can access basic file operations on downloaded content via the passed [Download] instance. Browser context must be created with the `acceptDownloads` set to `true` when user needs access to the downloaded content. If `acceptDownloads` is not set or set to `false`, download events are emitted, but the actual download is not performed and user has no access to the downloaded files.
Emitted when attachment download started. User can access basic file operations on downloaded content via the passed [Download] instance.

> **NOTE** Browser context **must** be created with the `acceptDownloads` set to `true` when user needs access to the downloaded content. If `acceptDownloads` is not set or set to `false`, download events are emitted, but the actual download is not performed and user has no access to the downloaded files.
#### event: 'filechooser'
- <[Object]>
Expand Down Expand Up @@ -2994,20 +2996,23 @@ const { chromium } = require('playwright'); // Or 'firefox' or 'webkit'.

[Download] objects are dispatched by page via the ['download'](#event-download) event.

Note that browser context must be created with the `acceptDownloads` set to `true` when user needs access to the downloaded content. If `acceptDownloads` is not set or set to `false`, download events are emitted, but the actual download is not performed and user has no access to the downloaded files.

All the downloaded files belonging to the browser context are deleted when the browser context is closed. All downloaded files are deleted when the browser closes.

An example of using `Download` class:
Download event is emitted once the download starts. Download path becomes available
once download completes:

```js
const [ download ] = await Promise.all([
page.waitForEvent('download'),
page.waitForEvent('download'), // wait for download to start
page.click('a')
]);
// wait for download to complete
const path = await download.path();
...
```

> **NOTE** Browser context **must** be created with the `acceptDownloads` set to `true` when user needs access to the downloaded content. If `acceptDownloads` is not set or set to `false`, download events are emitted, but the actual download is not performed and user has no access to the downloaded files.
<!-- GEN:toc -->
- [download.createReadStream()](#downloadcreatereadstream)
- [download.delete()](#downloaddelete)
Expand Down

0 comments on commit d21e2c9

Please sign in to comment.