Skip to content

Commit

Permalink
Merge b1233cf into 8acd2be
Browse files Browse the repository at this point in the history
  • Loading branch information
xvrh committed Jul 26, 2019
2 parents 8acd2be + b1233cf commit 94c432b
Show file tree
Hide file tree
Showing 17 changed files with 1,306 additions and 80 deletions.
74 changes: 74 additions & 0 deletions doc/api.md
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@
* [page.title](#pagetitle)
* [page.type](#pagetype)
* [page.url](#pageurl)
* [page.waitForFileChooser](#pagewaitforfilechooserduration-timeout)
* [page.waitForFunction](#pagewaitforfunction)
* [page.waitForNavigation](#pagewaitfornavigationduration-timeout-until-wait)
* [page.waitForRequest](#pagewaitforrequeststring-url-duration-timeout)
Expand Down Expand Up @@ -231,6 +232,10 @@
* [coverage.startJSCoverage](#coveragestartjscoverage)
* [coverage.stopCSSCoverage](#coveragestopcsscoverage)
* [coverage.stopJSCoverage](#coveragestopjscoverage)
- [class: FileChooser](#class-filechooser)
* [fileChooser.accept](#filechooseracceptlistfile-files)
* [fileChooser.cancel](#filechoosercancel)
* [fileChooser.isMultiple](#filechooserismultiple)

### class: Puppeteer
Launch or connect to a chrome instance
Expand Down Expand Up @@ -1806,6 +1811,34 @@ This is a shortcut for [page.mainFrame.url]
page.url → String
```

#### page.waitForFileChooser({Duration timeout})
> **NOTE** In non-headless Chromium, this method results in the native file picker dialog **not showing up** for the user.
This method is typically coupled with an action that triggers file choosing.
The following example clicks a button that issues a file chooser, and then
responds with `/tmp/myfile.pdf` as if a user has selected this file.

```dart
var futureFileChooser = page.waitForFileChooser();
// some button that triggers file selection
await page.click('#upload-file-button');
var fileChooser = await futureFileChooser;
await fileChooser.accept([File('myfile.pdf')]);
```

> **NOTE** This must be called *before* the file chooser is launched. It will not return a currently active file chooser.
Parameters:
- `timeout` Maximum wait time in milliseconds, defaults to 30
seconds, pass `0` to disable the timeout. The default value can be
changed by using the [page.defaultTimeout] property.
- returns: [Future<FileChooser>] A promise that resolves after a page requests a file picker.

```dart
page.waitForFileChooser({Duration timeout}) → Future<FileChooser>
```

#### page.waitForFunction(...)
Parameters:
- [pageFunction]: Function to be evaluated in browser context
Expand Down Expand Up @@ -3765,3 +3798,44 @@ Returns a Future that resolves to the array of coverage reports for all scripts
coverage.stopJSCoverage() → Future<List<CoverageEntry>>
```

### class: FileChooser
[FileChooser] objects are returned via the ['page.waitForFileChooser'] method.

File choosers let you react to the page requesting for a file.

An example of using [FileChooser]:

```dart
var futureFileChooser = page.waitForFileChooser();
// some button that triggers file selection
await page.click('#upload-file-button');
var fileChooser = await futureFileChooser;
await fileChooser.accept([File('myfile.pdf')]);
```

> **NOTE** In browsers, only one file chooser can be opened at a time.
> All file choosers must be accepted or canceled. Not doing so will prevent subsequent file choosers from appearing.
#### fileChooser.accept(List\<File> files)
Accept the file chooser request with given files.

```dart
fileChooser.accept(List<File> files) → Future<void>
```

#### fileChooser.cancel()
Closes the file chooser without selecting any files.

```dart
fileChooser.cancel() → Future<void>
```

#### fileChooser.isMultiple
Whether file chooser allow for [multiple](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input/file#attr-multiple)
file selection.

```dart
fileChooser.isMultiple → bool
```

4 changes: 4 additions & 0 deletions lib/protocol/background_service.dart
Original file line number Diff line number Diff line change
Expand Up @@ -83,11 +83,15 @@ class ServiceName {
static const backgroundSync = ServiceName._('backgroundSync');
static const pushMessaging = ServiceName._('pushMessaging');
static const notifications = ServiceName._('notifications');
static const paymentHandler = ServiceName._('paymentHandler');
static const periodicBackgroundSync = ServiceName._('periodicBackgroundSync');
static const values = {
'backgroundFetch': backgroundFetch,
'backgroundSync': backgroundSync,
'pushMessaging': pushMessaging,
'notifications': notifications,
'paymentHandler': paymentHandler,
'periodicBackgroundSync': periodicBackgroundSync,
};

final String value;
Expand Down

0 comments on commit 94c432b

Please sign in to comment.