-
-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: added playwright/client to exposes browser context methods to t…
…he tests closes #540
- Loading branch information
1 parent
b3710e1
commit 7111801
Showing
9 changed files
with
208 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
const config = /** @type { import('../src/types.js').RunnerOptions} */ ( | ||
/** @type { unknown } */ (process.env.PW_TEST) | ||
) | ||
|
||
export const mode = config.mode | ||
|
||
export const options = config | ||
|
||
export const context = { | ||
/** @type {import('playwright-core').BrowserContext['setOffline']} */ | ||
setOffline(offline) { | ||
if ('pwContextSetOffline' in globalThis === false) { | ||
return Promise.resolve() | ||
} | ||
return globalThis.pwContextSetOffline(offline) | ||
}, | ||
|
||
/** @type {import('playwright-core').BrowserContext['grantPermissions']} */ | ||
grantPermissions(permissions, options) { | ||
return globalThis.pwContextGrantPermissions(permissions, options) | ||
}, | ||
|
||
/** @type {import('playwright-core').BrowserContext['setGeolocation']} */ | ||
setGeolocation(geolocation) { | ||
return globalThis.pwContextSetGeolocation(geolocation) | ||
}, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
declare global { | ||
function pwContextSetOffline(offline: boolean): Promise<void> | ||
/** | ||
* Grants specified permissions to the browser context. Only grants corresponding permissions to the given origin if | ||
* specified. | ||
* | ||
* @param permissions A permission or an array of permissions to grant. Permissions can be one of the following values: | ||
* - `'geolocation'` | ||
* - `'midi'` | ||
* - `'midi-sysex'` (system-exclusive midi) | ||
* - `'notifications'` | ||
* - `'camera'` | ||
* - `'microphone'` | ||
* - `'background-sync'` | ||
* - `'ambient-light-sensor'` | ||
* - `'accelerometer'` | ||
* - `'gyroscope'` | ||
* - `'magnetometer'` | ||
* - `'accessibility-events'` | ||
* - `'clipboard-read'` | ||
* - `'clipboard-write'` | ||
* - `'payment-handler'` | ||
* @param options | ||
* @param options.origin | ||
*/ | ||
function pwContextGrantPermissions( | ||
permissions: string[], | ||
options?: { | ||
/** | ||
* The [origin] to grant permissions to, e.g. "https://example.com". | ||
*/ | ||
origin?: string | ||
} | ||
): Promise<void> | ||
|
||
/** | ||
* | ||
* @param geolocation | ||
*/ | ||
function pwContextSetGeolocation( | ||
geolocation: null | { | ||
/** | ||
* Latitude between -90 and 90. | ||
*/ | ||
latitude: number | ||
|
||
/** | ||
* Longitude between -180 and 180. | ||
*/ | ||
longitude: number | ||
|
||
/** | ||
* Non-negative accuracy value. Defaults to `0`. | ||
*/ | ||
accuracy?: number | ||
} | ||
): Promise<void> | ||
} | ||
|
||
export {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters