@wdio/firefox-profile-service 9.0.0-alpha.78 → 9.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -1,7 +1,7 @@
1
1
  WDIO Firefox Profile Service
2
2
  ============================
3
3
 
4
- You want to run your Firefox browser with a specific extension or need to set couple preferences? Selenium allows you to use a profile for the Firefox browser by passing this profile as `base64` string to the `firefox_profile` property in your desired capabilities. This requires building that profile and converting it into `base64`. This service for the [wdio testrunner](https://webdriver.io/docs/clioptions) takes the work of compiling the profile out of your hand and lets you define your desired options comfortably from the `wdio.conf.js` file.
4
+ You want to run your Firefox browser with a specific extension or need to set a couple preferences? Selenium allows you to use a profile for the Firefox browser by passing this profile as `base64` string to the `moz:firefoxOptions.profile` property in your desired capabilities. This requires building that profile and converting it into `base64`. This service for the [wdio testrunner](https://webdriver.io/docs/clioptions) takes the work of compiling the profile out of your hand and lets you define your desired options comfortably from the `wdio.conf.js` file.
5
5
 
6
6
  To find all possible options open [about:config](about:config) in your Firefox browser or go to [mozillaZine](http://kb.mozillazine.org/About:config_entries) website to find the whole documentation about each setting. In Addition to that, you can define compiled (as `*.xpi`) Firefox extensions that should get installed before the test starts.
7
7
 
package/build/index.js CHANGED
@@ -1,4 +1,78 @@
1
- /* istanbul ignore file */
2
- import FirefoxProfileLauncher from './launcher.js';
3
- export const launcher = FirefoxProfileLauncher;
4
- export * from './types.js';
1
+ // src/launcher.ts
2
+ import Profile from "firefox-profile";
3
+ import { promisify } from "node:util";
4
+ var FirefoxProfileLauncher = class {
5
+ constructor(_options) {
6
+ this._options = _options;
7
+ }
8
+ _profile;
9
+ async onPrepare(config, capabilities) {
10
+ if (Object.keys(this._options).length === 0) {
11
+ return;
12
+ }
13
+ this._profile = this._options.profileDirectory ? await promisify(Profile.copy)(this._options.profileDirectory) : new Profile();
14
+ if (!this._profile) {
15
+ return;
16
+ }
17
+ this._setPreferences();
18
+ if (!Array.isArray(this._options.extensions)) {
19
+ return this._buildExtension(capabilities);
20
+ }
21
+ await promisify(this._profile.addExtensions.bind(this._profile))(this._options.extensions);
22
+ return this._buildExtension(capabilities);
23
+ }
24
+ /**
25
+ * Sets any preferences and proxy
26
+ */
27
+ _setPreferences() {
28
+ if (!this._profile) {
29
+ return;
30
+ }
31
+ for (const [preference, value] of Object.entries(this._options)) {
32
+ if (["extensions", "proxy", "legacy", "profileDirectory"].includes(preference)) {
33
+ continue;
34
+ }
35
+ this._profile.setPreference(preference, value);
36
+ }
37
+ if (this._options.proxy) {
38
+ this._profile.setProxy(this._options.proxy);
39
+ }
40
+ this._profile.updatePreferences();
41
+ }
42
+ async _buildExtension(capabilities) {
43
+ if (!this._profile) {
44
+ return;
45
+ }
46
+ const zippedProfile = await promisify(this._profile.encoded.bind(this._profile))();
47
+ if (Array.isArray(capabilities)) {
48
+ capabilities.flatMap((c) => {
49
+ if (Object.values(c).length > 0 && Object.values(c).every((c2) => typeof c2 === "object" && c2.capabilities)) {
50
+ return Object.values(c).map((o) => o.capabilities);
51
+ }
52
+ return c;
53
+ }).filter((capability) => capability.browserName === "firefox").forEach((capability) => {
54
+ this._setProfile(capability, zippedProfile);
55
+ });
56
+ return;
57
+ }
58
+ for (const browser in capabilities) {
59
+ const capability = capabilities[browser].capabilities;
60
+ const cap = capability && ("alwaysMatch" in capability ? capability.alwaysMatch : capability);
61
+ if (!capability || cap.browserName !== "firefox") {
62
+ continue;
63
+ }
64
+ this._setProfile(capability, zippedProfile);
65
+ }
66
+ }
67
+ _setProfile(capability, zippedProfile) {
68
+ const cap = "alwaysMatch" in capability ? capability.alwaysMatch : capability;
69
+ cap["moz:firefoxOptions"] = cap["moz:firefoxOptions"] || {};
70
+ cap["moz:firefoxOptions"].profile = zippedProfile;
71
+ }
72
+ };
73
+
74
+ // src/index.ts
75
+ var launcher = FirefoxProfileLauncher;
76
+ export {
77
+ launcher
78
+ };
@@ -4,12 +4,12 @@ export default class FirefoxProfileLauncher {
4
4
  private _options;
5
5
  private _profile?;
6
6
  constructor(_options: FirefoxProfileOptions);
7
- onPrepare(config: never, capabilities: Capabilities.RemoteCapabilities): Promise<void>;
7
+ onPrepare(config: never, capabilities: Capabilities.TestrunnerCapabilities): Promise<void>;
8
8
  /**
9
9
  * Sets any preferences and proxy
10
10
  */
11
11
  _setPreferences(): void;
12
- _buildExtension(capabilities: Capabilities.RemoteCapabilities): Promise<void>;
13
- _setProfile(capability: WebdriverIO.Capabilities, zippedProfile: string): void;
12
+ _buildExtension(capabilities: Capabilities.TestrunnerCapabilities): Promise<void>;
13
+ _setProfile(capability: Capabilities.RequestedStandaloneCapabilities, zippedProfile: string): void;
14
14
  }
15
15
  //# sourceMappingURL=launcher.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"launcher.d.ts","sourceRoot":"","sources":["../src/launcher.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,aAAa,CAAA;AAE/C,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,YAAY,CAAA;AAEvD,MAAM,CAAC,OAAO,OAAO,sBAAsB;IAE3B,OAAO,CAAC,QAAQ;IAD5B,OAAO,CAAC,QAAQ,CAAC,CAAS;gBACN,QAAQ,EAAE,qBAAqB;IAE7C,SAAS,CAAC,MAAM,EAAE,KAAK,EAAE,YAAY,EAAE,YAAY,CAAC,kBAAkB;IA4B5E;;OAEG;IACH,eAAe;IAoBT,eAAe,CAAC,YAAY,EAAE,YAAY,CAAC,kBAAkB;IAkCnE,WAAW,CAAC,UAAU,EAAE,WAAW,CAAC,YAAY,EAAE,aAAa,EAAE,MAAM;CAU1E"}
1
+ {"version":3,"file":"launcher.d.ts","sourceRoot":"","sources":["../src/launcher.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,aAAa,CAAA;AAE/C,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,YAAY,CAAA;AAEvD,MAAM,CAAC,OAAO,OAAO,sBAAsB;IAE3B,OAAO,CAAC,QAAQ;IAD5B,OAAO,CAAC,QAAQ,CAAC,CAAS;gBACN,QAAQ,EAAE,qBAAqB;IAE7C,SAAS,CAAC,MAAM,EAAE,KAAK,EAAE,YAAY,EAAE,YAAY,CAAC,sBAAsB;IA4BhF;;OAEG;IACH,eAAe;IAoBT,eAAe,CAAC,YAAY,EAAE,YAAY,CAAC,sBAAsB;IAkCvE,WAAW,CAAC,UAAU,EAAE,YAAY,CAAC,+BAA+B,EAAE,aAAa,EAAE,MAAM;CAM9F"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wdio/firefox-profile-service",
3
- "version": "9.0.0-alpha.78+fee2f8a88",
3
+ "version": "9.0.0",
4
4
  "description": "WebdriverIO service that lets you define your Firefox profile in your wdio.conf.js",
5
5
  "author": "Christian Bromann <mail@bromann.dev>",
6
6
  "homepage": "https://github.com/webdriverio/webdriverio/tree/main/packages/wdio-firefox-profile-service",
@@ -31,16 +31,18 @@
31
31
  "type": "module",
32
32
  "types": "./build/index.d.ts",
33
33
  "exports": {
34
- ".": "./build/index.js",
35
- "./package.json": "./package.json"
34
+ ".": {
35
+ "import": "./build/index.js",
36
+ "types": "./build/index.d.ts"
37
+ }
36
38
  },
37
39
  "typeScriptVersion": "3.8.3",
38
40
  "dependencies": {
39
- "@wdio/types": "9.0.0-alpha.78+fee2f8a88",
41
+ "@wdio/types": "9.0.0",
40
42
  "firefox-profile": "^4.5.0"
41
43
  },
42
44
  "publishConfig": {
43
45
  "access": "public"
44
46
  },
45
- "gitHead": "fee2f8a88d132537795eaf144abf1a7e242f99ff"
47
+ "gitHead": "957693463371a4cb329395dcdbce8fb0c930ab93"
46
48
  }
package/build/launcher.js DELETED
@@ -1,87 +0,0 @@
1
- import Profile from 'firefox-profile';
2
- import { promisify } from 'node:util';
3
- export default class FirefoxProfileLauncher {
4
- _options;
5
- _profile;
6
- constructor(_options) {
7
- this._options = _options;
8
- }
9
- async onPrepare(config, capabilities) {
10
- /**
11
- * Return if no profile options were specified
12
- */
13
- if (Object.keys(this._options).length === 0) {
14
- return;
15
- }
16
- this._profile = this._options.profileDirectory
17
- ? await promisify(Profile.copy)(this._options.profileDirectory)
18
- : new Profile();
19
- if (!this._profile) {
20
- return;
21
- }
22
- // Set preferences and proxy
23
- this._setPreferences();
24
- if (!Array.isArray(this._options.extensions)) {
25
- return this._buildExtension(capabilities);
26
- }
27
- // Add the extension
28
- await promisify(this._profile.addExtensions.bind(this._profile))(this._options.extensions);
29
- return this._buildExtension(capabilities);
30
- }
31
- /**
32
- * Sets any preferences and proxy
33
- */
34
- _setPreferences() {
35
- if (!this._profile) {
36
- return;
37
- }
38
- for (const [preference, value] of Object.entries(this._options)) {
39
- if (['extensions', 'proxy', 'legacy', 'profileDirectory'].includes(preference)) {
40
- continue;
41
- }
42
- this._profile.setPreference(preference, value);
43
- }
44
- if (this._options.proxy) {
45
- this._profile.setProxy(this._options.proxy);
46
- }
47
- this._profile.updatePreferences();
48
- }
49
- async _buildExtension(capabilities) {
50
- if (!this._profile) {
51
- return;
52
- }
53
- const zippedProfile = await promisify(this._profile.encoded.bind(this._profile))();
54
- if (Array.isArray(capabilities)) {
55
- capabilities
56
- .flatMap((c) => {
57
- if (Object.values(c).length > 0 && Object.values(c).every(c => typeof c === 'object' && c.capabilities)) {
58
- return Object.values(c).map((o) => o.capabilities);
59
- }
60
- return c;
61
- })
62
- .filter((capability) => capability.browserName === 'firefox')
63
- .forEach((capability) => {
64
- this._setProfile(capability, zippedProfile);
65
- });
66
- return;
67
- }
68
- for (const browser in capabilities) {
69
- const capability = capabilities[browser].capabilities;
70
- if (!capability || capability.browserName !== 'firefox') {
71
- continue;
72
- }
73
- this._setProfile(capability, zippedProfile);
74
- }
75
- }
76
- _setProfile(capability, zippedProfile) {
77
- if (this._options.legacy) {
78
- // for older firefox and geckodriver versions
79
- capability.firefox_profile = zippedProfile;
80
- }
81
- else {
82
- // for firefox >= 56.0 and geckodriver >= 0.19.0
83
- capability['moz:firefoxOptions'] = capability['moz:firefoxOptions'] || {};
84
- capability['moz:firefoxOptions'].profile = zippedProfile;
85
- }
86
- }
87
- }
package/build/types.js DELETED
@@ -1 +0,0 @@
1
- export {};
File without changes