JSDoc: Class: Context

# Class: Context

## browser.Context(win, driver)

Creates a browsing context wrapper.

Browsing contexts handle interactions with the browser, according to the current environment (Firefox, Fennec).

## Constructor

#### new Context(win, driver)

##### Parameters:

Name | Type | Description
--- | --- | ---
`win` | ChromeWindow | ChromeWindow that contains the top-level browsing context.
`driver` | GeckoDriver | Reference to driver instance.

Source:
  - browser.js, line 75

### Members

#### contentBrowser

Returns the content browser for the currently selected tab. If there is no tab selected, null will be returned.

Source:
  - browser.js, line 130

#### curFrameId

The current frame ID is managed per browser element on desktop in case the ID needs to be refreshed. The currently selected window is identified by a tab.

Source:
  - browser.js, line 150

#### currentTitle

Returns the current title of the content browser.

Source:
  - browser.js, line 167

#### currentURI

Returns the current URI of the content browser.

Source:
  - browser.js, line 186

#### rect

Gets the position and dimensions of the top-level browsing context.

Source:
  - browser.js, line 202

### Methods

#### addTab(uri)

Opens a tab with given URI.

##### Parameters:

Name | Type | Description
--- | --- | ---
`uri` | string | URI to open.

Source:
  - browser.js, line 291

#### closeTab() → {Promise}

Close the current tab.

Source:
  - browser.js, line 253

##### Throws:

UnsupportedOperationError If tab handling for the current application isn't supported.

##### Returns:

A promise which is resolved when the current tab has been closed.

Type
  Promise

#### closeWindow() → {Promise}

Close the current window.

Source:
  - browser.js, line 235

##### Returns:

A promise which is resolved when the current window has been closed.

Type
  Promise

#### executeWhenReady()

This function intercepts commands interacting with content and queues or executes them as needed.

No commands interacting with content are safe to process until the new listener script is loaded and registers itself. This occurs when a command whose effect is asynchronous (such as goBack) results in a reload of the frame script and new commands are subsequently posted to the server.

Source:
  - browser.js, line 396

#### flushPendingCommands()

Flushes any queued pending commands after a reload of the frame script.

Source:
  - browser.js, line 376

#### getTabModalUI()

Retrieves the current tabmodal UI object. According to the browser associated with the currently selected tab.

Source:
  - browser.js, line 216

#### register(uid, target)

Registers a new frame, and sets its current frame id to this frame if it is not already assigned, and if a) we already have a session or b) we're starting a new session and it is the right start frame.

##### Parameters:

Name | Type | Description
--- | --- | ---
`uid` | string | Frame uid for use by Marionette.
`target` | xul:browser | The that was the target of the originating message.

Source:
  - browser.js, line 355

#### switchToTab(indexopt, windowopt, focusopt)

Set the current tab.

##### Parameters:

Name | Type | Attributes | Default | Description
--- | --- | --- | --- | ---
`index` | number | <optional> |  | Tab index to switch to. If the parameter is undefined, the currently selected tab will be used.
`window` | ChromeWindow | <optional> |  | Switch to this window before selecting the tab.
`focus` | boolean | <optional> | true | A boolean value which determins whether to focus the window. Defaults to true.

Source:
  - browser.js, line 310

##### Throws:

UnsupportedOperationError If tab handling for the current application isn't supported.