lint: eslint fixes

This commit is contained in:
Pavel Feldman 2019-12-12 20:21:29 -08:00
parent c7cf4886ea
commit 5377f7a2d8
4 changed files with 27 additions and 25 deletions

View File

@ -32,10 +32,10 @@
* [browser.browserContexts()](#browserbrowsercontexts)
* [browser.chromium](#browserchromium)
* [browser.close()](#browserclose)
* [browser.newContext()](#browsernewcontext)
* [browser.defaultBrowserContext()](#browserdefaultbrowsercontext)
* [browser.disconnect()](#browserdisconnect)
* [browser.isConnected()](#browserisconnected)
* [browser.newContext()](#browsernewcontext)
* [browser.newPage()](#browsernewpage)
* [browser.pages()](#browserpages)
* [browser.process()](#browserprocess)
@ -160,6 +160,8 @@
* [mouse.up([options])](#mouseupoptions)
- [class: PDF](#class-pdf)
* [pdf.generate([options])](#pdfgenerateoptions)
- [class: Firefox](#class-firefox)
* [firefox.wsEndpoint()](#firefoxwsendpoint)
- [class: Chromium](#class-chromium)
* [event: 'targetchanged'](#event-targetchanged)
* [event: 'targetcreated'](#event-targetcreated)
@ -625,23 +627,6 @@ a single instance of [BrowserContext].
Closes Chromium and all of its pages (if any were opened). The [Browser] object itself is considered to be disposed and cannot be used anymore.
#### browser.newContext()
- returns: <[Promise]<[BrowserContext]>>
Creates a new incognito browser context. This won't share cookies/cache with other browser contexts.
```js
(async () => {
const browser = await playwright.launch();
// Create a new incognito browser context.
const context = await browser.newContext();
// Create a new page in a pristine context.
const page = await context.newPage();
// Do stuff
await page.goto('https://example.com');
})();
```
#### browser.defaultBrowserContext()
- returns: <[BrowserContext]>
@ -657,6 +642,23 @@ Disconnects Playwright from the browser, but leaves the Chromium process running
Indicates that the browser is connected.
#### browser.newContext()
- returns: <[Promise]<[BrowserContext]>>
Creates a new browser context. It won't share cookies/cache with other browser contexts.
```js
(async () => {
const browser = await playwright.launch();
// Create a new incognito browser context.
const context = await browser.newContext();
// Create a new page in a pristine context.
const page = await context.newPage();
// Do stuff
await page.goto('https://example.com');
})();
```
#### browser.newPage()
- returns: <[Promise]<[Page]>>

View File

@ -250,17 +250,17 @@ export class Frame {
return this._raceWithCSPError(async () => {
if (url !== null)
return (await context.evaluateHandle(addStyleUrl, url)).asElement();
if (path !== null) {
let contents = await readFileAsync(path, 'utf8');
contents += '/*# sourceURL=' + path.replace(/\n/g, '') + '*/';
return (await context.evaluateHandle(addStyleContent, contents)).asElement();
}
if (content !== null)
return (await context.evaluateHandle(addStyleContent, content)).asElement();
});
async function addStyleUrl(url: string): Promise<HTMLElement> {
const link = document.createElement('link');
link.rel = 'stylesheet';
@ -293,7 +293,7 @@ export class Frame {
let result: dom.ElementHandle | undefined;
let error: Error | undefined;
let cspMessage: ConsoleMessage | undefined;
const actionPromise = new Promise<dom.ElementHandle>(async (resolve) => {
const actionPromise = new Promise<dom.ElementHandle>(async resolve => {
try {
result = await func();
} catch (e) {

View File

@ -72,9 +72,9 @@ export class Connection extends EventEmitter {
}
private _onMessage(message: string) {
if (this._sameDispatchTask || this._incomingMessageQueue.length || this._delay)
if (this._sameDispatchTask || this._incomingMessageQueue.length || this._delay) {
this._enqueueMessage(message);
else {
} else {
this._sameDispatchTask = true;
// This is for the case when several messages come in a batch and read
// in a loop by transport ending up in the same task.

View File

@ -19,7 +19,7 @@ import { Browser } from './Browser';
import { BrowserContext } from '../browserContext';
import { Page } from '../page';
import { Protocol } from './protocol';
import { isSwappedOutError, TargetSession, TargetSessionEvents } from './Connection';
import { TargetSession, TargetSessionEvents } from './Connection';
import { FrameManager } from './FrameManager';
const targetSymbol = Symbol('target');