webdriverio 9.5.4 → 9.5.7
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/build/index.js +36 -11
- package/build/session/polyfill.d.ts +9 -0
- package/build/session/polyfill.d.ts.map +1 -1
- package/package.json +2 -2
package/build/index.js
CHANGED
|
@@ -3026,7 +3026,7 @@ var SessionManager = class {
|
|
|
3026
3026
|
}
|
|
3027
3027
|
}
|
|
3028
3028
|
removeListeners() {
|
|
3029
|
-
this.#browser.off("
|
|
3029
|
+
this.#browser.off("command", this.#onCommand.bind(this));
|
|
3030
3030
|
}
|
|
3031
3031
|
initialize() {
|
|
3032
3032
|
return void 0;
|
|
@@ -3225,23 +3225,48 @@ var log5 = logger5("webdriverio:PolyfillManager");
|
|
|
3225
3225
|
var NAME_POLYFILL = "var __defProp = Object.defineProperty;var __name = function (target, value) { return __defProp(target, 'name', { value: value, configurable: true }); };var __globalThis = (typeof globalThis === 'object' && globalThis) || (typeof window === 'object' && window);__globalThis.__name = __name;";
|
|
3226
3226
|
var PolyfillManager = class _PolyfillManager extends SessionManager {
|
|
3227
3227
|
#initialize;
|
|
3228
|
+
#browser;
|
|
3229
|
+
#scriptsRegisteredInContexts = /* @__PURE__ */ new Set();
|
|
3228
3230
|
constructor(browser) {
|
|
3229
3231
|
super(browser, _PolyfillManager.name);
|
|
3232
|
+
this.#browser = browser;
|
|
3230
3233
|
if (!this.isEnabled()) {
|
|
3231
3234
|
this.#initialize = Promise.resolve(true);
|
|
3232
3235
|
return;
|
|
3233
3236
|
}
|
|
3234
|
-
const polyfill = (polyfill2) => {
|
|
3235
|
-
const closure = new Function(polyfill2);
|
|
3236
|
-
return closure();
|
|
3237
|
-
};
|
|
3238
3237
|
this.#initialize = Promise.all([
|
|
3239
|
-
browser.
|
|
3240
|
-
|
|
3241
|
-
|
|
3242
|
-
|
|
3243
|
-
|
|
3244
|
-
|
|
3238
|
+
this.#browser.browsingContextGetTree({}).then(({ contexts }) => {
|
|
3239
|
+
return Promise.all(contexts.map((context) => this.#registerScripts(context)));
|
|
3240
|
+
}),
|
|
3241
|
+
this.#browser.sessionSubscribe({
|
|
3242
|
+
events: ["browsingContext.contextCreated"]
|
|
3243
|
+
})
|
|
3244
|
+
]).then(() => true, () => false);
|
|
3245
|
+
this.#browser.on("browsingContext.contextCreated", this.#registerScripts.bind(this));
|
|
3246
|
+
}
|
|
3247
|
+
removeListeners() {
|
|
3248
|
+
super.removeListeners();
|
|
3249
|
+
this.#browser.off("browsingContext.contextCreated", this.#registerScripts.bind(this));
|
|
3250
|
+
}
|
|
3251
|
+
#registerScripts(context) {
|
|
3252
|
+
if (this.#scriptsRegisteredInContexts.has(context.context)) {
|
|
3253
|
+
return;
|
|
3254
|
+
}
|
|
3255
|
+
const functionDeclaration = `(() => {${NAME_POLYFILL}})()`;
|
|
3256
|
+
log5.info(`Adding polyfill script to context with id ${context.context}`);
|
|
3257
|
+
this.#scriptsRegisteredInContexts.add(context.context);
|
|
3258
|
+
return Promise.all([
|
|
3259
|
+
!context.parent ? this.#browser.scriptAddPreloadScript({
|
|
3260
|
+
functionDeclaration,
|
|
3261
|
+
contexts: [context.context]
|
|
3262
|
+
}) : Promise.resolve(),
|
|
3263
|
+
this.#browser.scriptCallFunction({
|
|
3264
|
+
functionDeclaration,
|
|
3265
|
+
target: context,
|
|
3266
|
+
awaitPromise: false
|
|
3267
|
+
}).catch(() => {
|
|
3268
|
+
})
|
|
3269
|
+
]);
|
|
3245
3270
|
}
|
|
3246
3271
|
async initialize() {
|
|
3247
3272
|
return this.#initialize;
|
|
@@ -1,5 +1,13 @@
|
|
|
1
1
|
import { SessionManager } from './session.js';
|
|
2
2
|
export declare function getPolyfillManager(browser: WebdriverIO.Browser): PolyfillManager;
|
|
3
|
+
/**
|
|
4
|
+
* A polyfill to set `__name` to the global scope which is needed for WebdriverIO to properly
|
|
5
|
+
* execute custom (preload) scripts. When using `tsx` Esbuild runs some optimizations which
|
|
6
|
+
* assume that the file contains these global variables. This is a workaround until this issue
|
|
7
|
+
* is fixed.
|
|
8
|
+
*
|
|
9
|
+
* @see https://github.com/evanw/esbuild/issues/2605
|
|
10
|
+
*/
|
|
3
11
|
export declare const NAME_POLYFILL: string;
|
|
4
12
|
/**
|
|
5
13
|
* This class is responsible for setting polyfill scripts in the browser.
|
|
@@ -7,6 +15,7 @@ export declare const NAME_POLYFILL: string;
|
|
|
7
15
|
export declare class PolyfillManager extends SessionManager {
|
|
8
16
|
#private;
|
|
9
17
|
constructor(browser: WebdriverIO.Browser);
|
|
18
|
+
removeListeners(): void;
|
|
10
19
|
initialize(): Promise<boolean>;
|
|
11
20
|
}
|
|
12
21
|
//# sourceMappingURL=polyfill.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"polyfill.d.ts","sourceRoot":"","sources":["../../src/session/polyfill.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"polyfill.d.ts","sourceRoot":"","sources":["../../src/session/polyfill.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,cAAc,EAAE,MAAM,cAAc,CAAA;AAE7C,wBAAgB,kBAAkB,CAAC,OAAO,EAAE,WAAW,CAAC,OAAO,mBAE9D;AAID;;;;;;;GAOG;AACH,eAAO,MAAM,aAAa,QAKzB,CAAA;AAED;;GAEG;AACH,qBAAa,eAAgB,SAAQ,cAAc;;gBAKnC,OAAO,EAAE,WAAW,CAAC,OAAO;IA2BxC,eAAe;IAgCT,UAAU;CAGnB"}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "webdriverio",
|
|
3
3
|
"description": "Next-gen browser and mobile automation test framework for Node.js",
|
|
4
|
-
"version": "9.5.
|
|
4
|
+
"version": "9.5.7",
|
|
5
5
|
"homepage": "https://webdriver.io",
|
|
6
6
|
"author": "Christian Bromann <mail@bromann.dev>",
|
|
7
7
|
"license": "MIT",
|
|
@@ -110,5 +110,5 @@
|
|
|
110
110
|
"optional": true
|
|
111
111
|
}
|
|
112
112
|
},
|
|
113
|
-
"gitHead": "
|
|
113
|
+
"gitHead": "a273d38d5724c27656fa6e8d7b8b79a716a9f00a"
|
|
114
114
|
}
|