From 25b35c57898a8f2827dcb7208af14dd8f668eac8 Mon Sep 17 00:00:00 2001 From: futpib Date: Wed, 17 Jan 2018 03:59:00 +0300 Subject: [PATCH] docs(api.md): fix missing await in examples (#1801) `frame.executionContext()` returns a Promise, so running examples without `await` results in exceptions --- docs/api.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/api.md b/docs/api.md index 6fe857ed510..dae44bd2672 100644 --- a/docs/api.md +++ b/docs/api.md @@ -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. ```