docs(api.md): fix missing await in examples (#1801)

`frame.executionContext()` returns a Promise, so running examples without `await` results in exceptions
This commit is contained in:
futpib 2018-01-17 03:59:00 +03:00 committed by Andrey Lushnikov
parent 8c93084316
commit 25b35c5789

View File

@ -1743,7 +1743,7 @@ The class represents a context for JavaScript execution. Examples of JavaScript
If the function, passed to the `executionContext.evaluate`, returns a [Promise], then `executionContext.evaluate` would wait for the promise to resolve and return its value.
```js
const executionContext = page.mainFrame().executionContext();
const executionContext = await page.mainFrame().executionContext();
const result = await executionContext.evaluate(() => Promise.resolve(8 * 7));
console.log(result); // prints "56"
```
@ -1772,7 +1772,7 @@ console.log(result); // prints '3'.
If the function, passed to the `executionContext.evaluateHandle`, returns a [Promise], then `executionContext.evaluteHandle` would wait for the promise to resolve and return its value.
```js
const context = page.mainFrame().executionContext();
const context = await page.mainFrame().executionContext();
const aHandle = await context.evaluateHandle(() => Promise.resolve(self));
aHandle; // Handle for the global object.
```