Skip to content

Commit

Permalink
Fix: Improve documentation for connectors
Browse files Browse the repository at this point in the history
* Document the common and specific properties of connectors.
* Remove `loadCompleteRetryInterval` and `maxLoadWaitTime`
  from the code as they weren't used anymore.
* Normalize `waitFor` to `1000` for all connectors.

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

Fix #500
Close #522
  • Loading branch information
Anton Molleda authored and alrra committed Sep 16, 2017
1 parent 534d7c0 commit ff45cb6
Show file tree
Hide file tree
Showing 4 changed files with 47 additions and 21 deletions.
4 changes: 1 addition & 3 deletions .sonarrc
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,7 @@
"connector": {
"name": "chrome",
"options": {
"waitFor": 1000,
"loadCompleteRetryInterval": 500,
"maxLoadWaitTime": 30000
"waitFor": 1000
}
},
"formatters": "stylish",
Expand Down
58 changes: 45 additions & 13 deletions docs/user-guide/connectors/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,43 +4,75 @@ The current supported connectors are:

* `jsdom`: Your website will be loaded using [`jsdom`][jsdom].
* `chrome`: Your website will be loaded using Chrome and the Chrome
Debugging Protocol.
Debugging Protocol. This is one of the `remote-debugging-connector`s

## chrome
## Configuration

The `chrome` connector uses the [Chrome Debugging Protocol][cdp] to
communicate with the browser.

### chrome configuration

The following properties can be customized in your `.sonarrc` file, under the
`options` property of the `connector`:
The following properties can be customized in your `.sonarrc` file,
under the `options` property of the `connector` for any of the
officially supported ones:

* `waitFor` time in milliseconds the connector will wait after the site is
ready before starting the DOM traversing. The default value is `5000`
ready before starting the DOM traversing. The default value is `1000`
milliseconds.

The following is the default configuration:

```json
{
"connector": {
"name": "chrome",
"name": "chrome|jsdom",
"options": {
"waitFor": 5000
"waitFor": 1000
}
}
}
```

### jsdom configuration

`jsdom` allows you to configure the following:

* `headers`: the headers used to fetch the resources. By default they are:

```json
{
"Accept-Language": "en-US,en;q=0.8,es;q=0.6,fr;q=0.4",
"Cache-Control": "no-cache",
"DNT": 1,
"Pragma": "no-cache",
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/56.0.2924.87 Safari/537.36"
}
```

### remote-debugging-connector configuration

There are some `connector`s built on top of the [chrome debugging
protocol][cdp]. `chrome` is one of these `connector`s.

The set of settings specific for them are:

* `useTabUrl`: Indicates if the browser should navigate first to a
given page before going to the final target. `false` by default.
* `tabUrl`: The URL to visit before the final target in case
`useTabUrl` is `true`. `https://empty.sonarwhal.com/` is the
default value.

```json
{
"tabUrl": "https://empty.sonarwhal.com/",
"useTabUrl": false
}
```

## Differences among connectors

Connectors are expected to implement at least some basic functionality
(see [how to develop a connector](../../developer-guide/connectors/index.md))
but expose more events or have some extra functionality. The following
document details the known differences among the official connectors.

### JSDOM
### jsdom

* It will not send the events for:

Expand Down
4 changes: 1 addition & 3 deletions src/lib/connectors/shared/remote-debugging-connector.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,13 +75,11 @@ export class Connector implements IConnector {

public constructor(server: Sonar, config: object, launcher: ILauncher) {
const defaultOptions = {
loadCompleteRetryInterval: 250,
maxLoadWaitTime: 30000,
// tabUrl is a empty html site used to avoid edge diagnostics adapter to receive unexpeted onLoadEventFired
// and onRequestWillBeSent events from the default url opened when you create a new tab in Edge.
tabUrl: 'https://empty.sonarwhal.com/',
useTabUrl: false,
waitFor: 5000
waitFor: 1000
};

this._server = server;
Expand Down
2 changes: 0 additions & 2 deletions src/lib/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,6 @@ export interface IRuleConfigList {

export interface IConnectorOptionsConfig {
waitFor?: number;
loadCompleteRetryInterval?: number;
maxLoadWaitTime?: number;
}

export interface IConnectorConfig {
Expand Down

0 comments on commit ff45cb6

Please sign in to comment.