@axe-core/watcher 1.8.2 → 2.0.0-next.3e4ae779
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/dist/cypress.d.ts +0 -4
- package/dist/cypress.js +1 -58
- package/dist/cypress.js.map +1 -1
- package/dist/cypressCommands.d.ts +6 -0
- package/dist/cypressCommands.js +101 -21
- package/dist/cypressCommands.js.map +1 -1
- package/dist/index.d.ts +4 -3
- package/dist/index.js +8 -2
- package/dist/index.js.map +1 -1
- package/dist/playwright.d.ts +6 -2
- package/dist/playwright.js +9 -2
- package/dist/playwright.js.map +1 -1
- package/dist/playwrightTest.d.ts +16 -0
- package/dist/playwrightTest.js +153 -0
- package/dist/playwrightTest.js.map +1 -0
- package/dist/playwrightWrapping.d.ts +14 -0
- package/dist/playwrightWrapping.js +852 -0
- package/dist/playwrightWrapping.js.map +1 -0
- package/dist/puppeteer.d.ts +1 -1
- package/dist/puppeteer.js +3 -1
- package/dist/puppeteer.js.map +1 -1
- package/dist/puppeteerWrapping.d.ts +14 -0
- package/dist/puppeteerWrapping.js +700 -0
- package/dist/puppeteerWrapping.js.map +1 -0
- package/dist/util.d.ts +8 -0
- package/dist/util.js +19 -1
- package/dist/util.js.map +1 -1
- package/extension/background.js +1 -1
- package/extension/content.js +1 -1
- package/extension/manifest.json +1 -1
- package/package.json +6 -6
|
@@ -0,0 +1,700 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
12
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
13
|
+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
14
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
15
|
+
function step(op) {
|
|
16
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
17
|
+
while (_) try {
|
|
18
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
19
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
20
|
+
switch (op[0]) {
|
|
21
|
+
case 0: case 1: t = op; break;
|
|
22
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
23
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
24
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
25
|
+
default:
|
|
26
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
27
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
28
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
29
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
30
|
+
if (t[2]) _.ops.pop();
|
|
31
|
+
_.trys.pop(); continue;
|
|
32
|
+
}
|
|
33
|
+
op = body.call(thisArg, _);
|
|
34
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
35
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
36
|
+
}
|
|
37
|
+
};
|
|
38
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
|
+
exports.wrapJSHandle = exports.wrapFrame = exports.wrapDialog = exports.wrapTouchscreen = exports.wrapMouse = exports.wrapKeyboard = exports.wrapElementHandle = exports.wrapTarget = exports.wrapPage = exports.wrapBrowser = exports.wrapBrowserContext = void 0;
|
|
40
|
+
var util_1 = require("./util");
|
|
41
|
+
var wrappedCallWithSideEffects = function (target, prop, controller) {
|
|
42
|
+
return function () {
|
|
43
|
+
var args = [];
|
|
44
|
+
for (var _i = 0; _i < arguments.length; _i++) {
|
|
45
|
+
args[_i] = arguments[_i];
|
|
46
|
+
}
|
|
47
|
+
return __awaiter(void 0, void 0, void 0, function () {
|
|
48
|
+
var result;
|
|
49
|
+
return __generator(this, function (_a) {
|
|
50
|
+
switch (_a.label) {
|
|
51
|
+
case 0: return [4 /*yield*/, target[prop].apply(target, args)];
|
|
52
|
+
case 1:
|
|
53
|
+
result = _a.sent();
|
|
54
|
+
return [4 /*yield*/, controller.analyze()];
|
|
55
|
+
case 2:
|
|
56
|
+
_a.sent();
|
|
57
|
+
return [2 /*return*/, result];
|
|
58
|
+
}
|
|
59
|
+
});
|
|
60
|
+
});
|
|
61
|
+
};
|
|
62
|
+
};
|
|
63
|
+
var wrapBrowserContext = function (browserContext, controller) {
|
|
64
|
+
if ((0, util_1.isWrapped)(browserContext)) {
|
|
65
|
+
return browserContext;
|
|
66
|
+
}
|
|
67
|
+
var proxy = new Proxy(browserContext, {
|
|
68
|
+
get: function (host, prop, receiver) {
|
|
69
|
+
var _this = this;
|
|
70
|
+
switch (prop) {
|
|
71
|
+
case 'newPage':
|
|
72
|
+
return function () {
|
|
73
|
+
var args = [];
|
|
74
|
+
for (var _i = 0; _i < arguments.length; _i++) {
|
|
75
|
+
args[_i] = arguments[_i];
|
|
76
|
+
}
|
|
77
|
+
return __awaiter(_this, void 0, void 0, function () {
|
|
78
|
+
var page;
|
|
79
|
+
return __generator(this, function (_a) {
|
|
80
|
+
switch (_a.label) {
|
|
81
|
+
case 0: return [4 /*yield*/, host.newPage.apply(host, args)];
|
|
82
|
+
case 1:
|
|
83
|
+
page = _a.sent();
|
|
84
|
+
return [2 /*return*/, (0, exports.wrapPage)(page, controller)];
|
|
85
|
+
}
|
|
86
|
+
});
|
|
87
|
+
});
|
|
88
|
+
};
|
|
89
|
+
case 'pages':
|
|
90
|
+
return function () {
|
|
91
|
+
var args = [];
|
|
92
|
+
for (var _i = 0; _i < arguments.length; _i++) {
|
|
93
|
+
args[_i] = arguments[_i];
|
|
94
|
+
}
|
|
95
|
+
return __awaiter(_this, void 0, void 0, function () {
|
|
96
|
+
var pages;
|
|
97
|
+
return __generator(this, function (_a) {
|
|
98
|
+
switch (_a.label) {
|
|
99
|
+
case 0: return [4 /*yield*/, host.pages.apply(host, args)];
|
|
100
|
+
case 1:
|
|
101
|
+
pages = _a.sent();
|
|
102
|
+
return [2 /*return*/, pages.map(function (p) { return (0, exports.wrapPage)(p, controller); })];
|
|
103
|
+
}
|
|
104
|
+
});
|
|
105
|
+
});
|
|
106
|
+
};
|
|
107
|
+
case 'targets':
|
|
108
|
+
return function () { return host.targets().map(function (t) { return (0, exports.wrapTarget)(t, controller); }); };
|
|
109
|
+
case 'browser':
|
|
110
|
+
return function () { return (0, exports.wrapBrowser)(host.browser(), controller); };
|
|
111
|
+
case 'waitForTarget':
|
|
112
|
+
return function () {
|
|
113
|
+
var args = [];
|
|
114
|
+
for (var _i = 0; _i < arguments.length; _i++) {
|
|
115
|
+
args[_i] = arguments[_i];
|
|
116
|
+
}
|
|
117
|
+
return __awaiter(_this, void 0, void 0, function () {
|
|
118
|
+
var target;
|
|
119
|
+
return __generator(this, function (_a) {
|
|
120
|
+
switch (_a.label) {
|
|
121
|
+
case 0: return [4 /*yield*/, host.waitForTarget.apply(host, args)];
|
|
122
|
+
case 1:
|
|
123
|
+
target = _a.sent();
|
|
124
|
+
return [2 /*return*/, (0, exports.wrapTarget)(target, controller)];
|
|
125
|
+
}
|
|
126
|
+
});
|
|
127
|
+
});
|
|
128
|
+
};
|
|
129
|
+
case 'close':
|
|
130
|
+
return function () { return __awaiter(_this, void 0, void 0, function () {
|
|
131
|
+
return __generator(this, function (_a) {
|
|
132
|
+
switch (_a.label) {
|
|
133
|
+
case 0: return [4 /*yield*/, controller.flush()];
|
|
134
|
+
case 1:
|
|
135
|
+
_a.sent();
|
|
136
|
+
return [4 /*yield*/, host.close()];
|
|
137
|
+
case 2:
|
|
138
|
+
_a.sent();
|
|
139
|
+
return [2 /*return*/];
|
|
140
|
+
}
|
|
141
|
+
});
|
|
142
|
+
}); };
|
|
143
|
+
default:
|
|
144
|
+
return Reflect.get(host, prop, receiver);
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
});
|
|
148
|
+
(0, util_1.markAsWrapped)(proxy);
|
|
149
|
+
return proxy;
|
|
150
|
+
};
|
|
151
|
+
exports.wrapBrowserContext = wrapBrowserContext;
|
|
152
|
+
var wrapBrowser = function (browser, controller) {
|
|
153
|
+
if ((0, util_1.isWrapped)(browser)) {
|
|
154
|
+
return browser;
|
|
155
|
+
}
|
|
156
|
+
var proxy = new Proxy(browser, {
|
|
157
|
+
get: function (host, prop, receiver) {
|
|
158
|
+
var _this = this;
|
|
159
|
+
switch (prop) {
|
|
160
|
+
case 'newPage':
|
|
161
|
+
return function () {
|
|
162
|
+
var args = [];
|
|
163
|
+
for (var _i = 0; _i < arguments.length; _i++) {
|
|
164
|
+
args[_i] = arguments[_i];
|
|
165
|
+
}
|
|
166
|
+
return __awaiter(_this, void 0, void 0, function () {
|
|
167
|
+
var page;
|
|
168
|
+
return __generator(this, function (_a) {
|
|
169
|
+
switch (_a.label) {
|
|
170
|
+
case 0: return [4 /*yield*/, host.newPage.apply(host, args)];
|
|
171
|
+
case 1:
|
|
172
|
+
page = _a.sent();
|
|
173
|
+
return [2 /*return*/, (0, exports.wrapPage)(page, controller)];
|
|
174
|
+
}
|
|
175
|
+
});
|
|
176
|
+
});
|
|
177
|
+
};
|
|
178
|
+
case 'createIncognitoBrowserContext':
|
|
179
|
+
return function () {
|
|
180
|
+
var args = [];
|
|
181
|
+
for (var _i = 0; _i < arguments.length; _i++) {
|
|
182
|
+
args[_i] = arguments[_i];
|
|
183
|
+
}
|
|
184
|
+
return __awaiter(_this, void 0, void 0, function () {
|
|
185
|
+
var context;
|
|
186
|
+
return __generator(this, function (_a) {
|
|
187
|
+
switch (_a.label) {
|
|
188
|
+
case 0: return [4 /*yield*/, host.createIncognitoBrowserContext.apply(host, args)];
|
|
189
|
+
case 1:
|
|
190
|
+
context = _a.sent();
|
|
191
|
+
return [2 /*return*/, (0, exports.wrapBrowserContext)(context, controller)];
|
|
192
|
+
}
|
|
193
|
+
});
|
|
194
|
+
});
|
|
195
|
+
};
|
|
196
|
+
case 'defaultBrowserContext':
|
|
197
|
+
return function () {
|
|
198
|
+
return (0, exports.wrapBrowserContext)(host.defaultBrowserContext(), controller);
|
|
199
|
+
};
|
|
200
|
+
case 'pages':
|
|
201
|
+
return function () { return __awaiter(_this, void 0, void 0, function () {
|
|
202
|
+
var pages;
|
|
203
|
+
return __generator(this, function (_a) {
|
|
204
|
+
switch (_a.label) {
|
|
205
|
+
case 0: return [4 /*yield*/, host.pages()];
|
|
206
|
+
case 1:
|
|
207
|
+
pages = _a.sent();
|
|
208
|
+
return [2 /*return*/, pages.map(function (p) { return (0, exports.wrapPage)(p, controller); })];
|
|
209
|
+
}
|
|
210
|
+
});
|
|
211
|
+
}); };
|
|
212
|
+
case 'target':
|
|
213
|
+
return function () { return (0, exports.wrapTarget)(host.target(), controller); };
|
|
214
|
+
case 'targets':
|
|
215
|
+
return function () { return host.targets().map(function (t) { return (0, exports.wrapTarget)(t, controller); }); };
|
|
216
|
+
case 'waitForTarget':
|
|
217
|
+
return function () {
|
|
218
|
+
var args = [];
|
|
219
|
+
for (var _i = 0; _i < arguments.length; _i++) {
|
|
220
|
+
args[_i] = arguments[_i];
|
|
221
|
+
}
|
|
222
|
+
return __awaiter(_this, void 0, void 0, function () {
|
|
223
|
+
var target;
|
|
224
|
+
return __generator(this, function (_a) {
|
|
225
|
+
switch (_a.label) {
|
|
226
|
+
case 0: return [4 /*yield*/, host.waitForTarget.apply(host, args)];
|
|
227
|
+
case 1:
|
|
228
|
+
target = _a.sent();
|
|
229
|
+
return [2 /*return*/, (0, exports.wrapTarget)(target, controller)];
|
|
230
|
+
}
|
|
231
|
+
});
|
|
232
|
+
});
|
|
233
|
+
};
|
|
234
|
+
case 'browserContexts':
|
|
235
|
+
return function () {
|
|
236
|
+
return host.browserContexts().map(function (c) { return (0, exports.wrapBrowserContext)(c, controller); });
|
|
237
|
+
};
|
|
238
|
+
case 'close':
|
|
239
|
+
return function () { return __awaiter(_this, void 0, void 0, function () {
|
|
240
|
+
return __generator(this, function (_a) {
|
|
241
|
+
switch (_a.label) {
|
|
242
|
+
case 0: return [4 /*yield*/, controller.flush()];
|
|
243
|
+
case 1:
|
|
244
|
+
_a.sent();
|
|
245
|
+
return [4 /*yield*/, host.close()];
|
|
246
|
+
case 2:
|
|
247
|
+
_a.sent();
|
|
248
|
+
return [2 /*return*/];
|
|
249
|
+
}
|
|
250
|
+
});
|
|
251
|
+
}); };
|
|
252
|
+
default:
|
|
253
|
+
return Reflect.get(host, prop, receiver);
|
|
254
|
+
}
|
|
255
|
+
}
|
|
256
|
+
});
|
|
257
|
+
(0, util_1.markAsWrapped)(proxy);
|
|
258
|
+
return proxy;
|
|
259
|
+
};
|
|
260
|
+
exports.wrapBrowser = wrapBrowser;
|
|
261
|
+
var wrapPage = function (page, controller) {
|
|
262
|
+
if ((0, util_1.isWrapped)(page)) {
|
|
263
|
+
return page;
|
|
264
|
+
}
|
|
265
|
+
var proxy = new Proxy(page, {
|
|
266
|
+
get: function (host, prop, receiver) {
|
|
267
|
+
var _this = this;
|
|
268
|
+
switch (prop) {
|
|
269
|
+
case 'browserContext':
|
|
270
|
+
return function () { return (0, exports.wrapBrowserContext)(host.browserContext(), controller); };
|
|
271
|
+
case '$':
|
|
272
|
+
case 'addScriptTag':
|
|
273
|
+
case 'addStyleTag':
|
|
274
|
+
case 'waitForSelector':
|
|
275
|
+
case 'waitForXPath':
|
|
276
|
+
return function () {
|
|
277
|
+
var args = [];
|
|
278
|
+
for (var _i = 0; _i < arguments.length; _i++) {
|
|
279
|
+
args[_i] = arguments[_i];
|
|
280
|
+
}
|
|
281
|
+
return __awaiter(_this, void 0, void 0, function () {
|
|
282
|
+
var el;
|
|
283
|
+
return __generator(this, function (_a) {
|
|
284
|
+
switch (_a.label) {
|
|
285
|
+
case 0: return [4 /*yield*/, host[prop].apply(host, args)];
|
|
286
|
+
case 1:
|
|
287
|
+
el = _a.sent();
|
|
288
|
+
return [2 /*return*/, el ? (0, exports.wrapElementHandle)(el, controller) : null];
|
|
289
|
+
}
|
|
290
|
+
});
|
|
291
|
+
});
|
|
292
|
+
};
|
|
293
|
+
case '$$':
|
|
294
|
+
case '$x':
|
|
295
|
+
return function () {
|
|
296
|
+
var args = [];
|
|
297
|
+
for (var _i = 0; _i < arguments.length; _i++) {
|
|
298
|
+
args[_i] = arguments[_i];
|
|
299
|
+
}
|
|
300
|
+
return __awaiter(_this, void 0, void 0, function () {
|
|
301
|
+
var els;
|
|
302
|
+
return __generator(this, function (_a) {
|
|
303
|
+
switch (_a.label) {
|
|
304
|
+
case 0: return [4 /*yield*/, host[prop].apply(host, args)];
|
|
305
|
+
case 1:
|
|
306
|
+
els = _a.sent();
|
|
307
|
+
return [2 /*return*/, els.map(function (el) { return (0, exports.wrapElementHandle)(el, controller); })];
|
|
308
|
+
}
|
|
309
|
+
});
|
|
310
|
+
});
|
|
311
|
+
};
|
|
312
|
+
case 'authenticate':
|
|
313
|
+
case 'bringToFront':
|
|
314
|
+
case 'click':
|
|
315
|
+
case 'deleteCookie':
|
|
316
|
+
case 'evaluate':
|
|
317
|
+
case 'focus':
|
|
318
|
+
case 'goBack':
|
|
319
|
+
case 'goForward':
|
|
320
|
+
case 'goto':
|
|
321
|
+
case 'hover':
|
|
322
|
+
case 'reload':
|
|
323
|
+
case 'select':
|
|
324
|
+
case 'setContent':
|
|
325
|
+
case 'setCookie':
|
|
326
|
+
case 'setViewport':
|
|
327
|
+
case 'tap':
|
|
328
|
+
case 'type':
|
|
329
|
+
return wrappedCallWithSideEffects(host, prop, controller);
|
|
330
|
+
case 'browser':
|
|
331
|
+
return function () { return (0, exports.wrapBrowser)(host.browser(), controller); };
|
|
332
|
+
case 'target':
|
|
333
|
+
return function () { return (0, exports.wrapTarget)(host.target(), controller); };
|
|
334
|
+
case 'frames':
|
|
335
|
+
return function () { return host.frames().map(function (f) { return (0, exports.wrapFrame)(f, controller); }); };
|
|
336
|
+
case 'keyboard':
|
|
337
|
+
return (0, exports.wrapKeyboard)(host.keyboard, controller);
|
|
338
|
+
case 'mouse':
|
|
339
|
+
return (0, exports.wrapMouse)(host.mouse, controller);
|
|
340
|
+
case 'touchscreen':
|
|
341
|
+
return (0, exports.wrapTouchscreen)(host.touchscreen, controller);
|
|
342
|
+
case 'mainFrame':
|
|
343
|
+
return function () { return (0, exports.wrapFrame)(host.mainFrame(), controller); };
|
|
344
|
+
case 'close':
|
|
345
|
+
return function () {
|
|
346
|
+
var args = [];
|
|
347
|
+
for (var _i = 0; _i < arguments.length; _i++) {
|
|
348
|
+
args[_i] = arguments[_i];
|
|
349
|
+
}
|
|
350
|
+
return __awaiter(_this, void 0, void 0, function () {
|
|
351
|
+
return __generator(this, function (_a) {
|
|
352
|
+
switch (_a.label) {
|
|
353
|
+
case 0: return [4 /*yield*/, controller.flush()];
|
|
354
|
+
case 1:
|
|
355
|
+
_a.sent();
|
|
356
|
+
return [2 /*return*/, host.close.apply(host, args)];
|
|
357
|
+
}
|
|
358
|
+
});
|
|
359
|
+
});
|
|
360
|
+
};
|
|
361
|
+
default:
|
|
362
|
+
return Reflect.get(host, prop, receiver);
|
|
363
|
+
}
|
|
364
|
+
}
|
|
365
|
+
});
|
|
366
|
+
(0, util_1.markAsWrapped)(proxy);
|
|
367
|
+
return proxy;
|
|
368
|
+
};
|
|
369
|
+
exports.wrapPage = wrapPage;
|
|
370
|
+
var wrapTarget = function (target, controller) {
|
|
371
|
+
if ((0, util_1.isWrapped)(target)) {
|
|
372
|
+
return target;
|
|
373
|
+
}
|
|
374
|
+
var proxy = new Proxy(target, {
|
|
375
|
+
get: function (host, prop, receiver) {
|
|
376
|
+
var _this = this;
|
|
377
|
+
switch (prop) {
|
|
378
|
+
case 'browserContext':
|
|
379
|
+
return function () { return (0, exports.wrapBrowserContext)(host.browserContext(), controller); };
|
|
380
|
+
case 'browser':
|
|
381
|
+
return function () { return (0, exports.wrapBrowser)(host.browser(), controller); };
|
|
382
|
+
case 'opener':
|
|
383
|
+
return function () {
|
|
384
|
+
var opener = host.opener();
|
|
385
|
+
return opener ? (0, exports.wrapTarget)(opener, controller) : null;
|
|
386
|
+
};
|
|
387
|
+
case 'page':
|
|
388
|
+
return function () { return __awaiter(_this, void 0, void 0, function () {
|
|
389
|
+
var page;
|
|
390
|
+
return __generator(this, function (_a) {
|
|
391
|
+
switch (_a.label) {
|
|
392
|
+
case 0: return [4 /*yield*/, host.page()];
|
|
393
|
+
case 1:
|
|
394
|
+
page = _a.sent();
|
|
395
|
+
return [2 /*return*/, page ? (0, exports.wrapPage)(page, controller) : null];
|
|
396
|
+
}
|
|
397
|
+
});
|
|
398
|
+
}); };
|
|
399
|
+
default:
|
|
400
|
+
return Reflect.get(host, prop, receiver);
|
|
401
|
+
}
|
|
402
|
+
}
|
|
403
|
+
});
|
|
404
|
+
(0, util_1.markAsWrapped)(proxy);
|
|
405
|
+
return proxy;
|
|
406
|
+
};
|
|
407
|
+
exports.wrapTarget = wrapTarget;
|
|
408
|
+
var wrapElementHandle = function (
|
|
409
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
410
|
+
elementHandle, controller) {
|
|
411
|
+
if ((0, util_1.isWrapped)(elementHandle)) {
|
|
412
|
+
return elementHandle;
|
|
413
|
+
}
|
|
414
|
+
var proxy = new Proxy(elementHandle, {
|
|
415
|
+
get: function (host, prop, receiver) {
|
|
416
|
+
var _this = this;
|
|
417
|
+
switch (prop) {
|
|
418
|
+
case '$':
|
|
419
|
+
case 'waitForSelector':
|
|
420
|
+
case 'waitForXPath':
|
|
421
|
+
return function () {
|
|
422
|
+
var args = [];
|
|
423
|
+
for (var _i = 0; _i < arguments.length; _i++) {
|
|
424
|
+
args[_i] = arguments[_i];
|
|
425
|
+
}
|
|
426
|
+
return __awaiter(_this, void 0, void 0, function () {
|
|
427
|
+
var el;
|
|
428
|
+
return __generator(this, function (_a) {
|
|
429
|
+
switch (_a.label) {
|
|
430
|
+
case 0: return [4 /*yield*/, host.$.apply(host, args)];
|
|
431
|
+
case 1:
|
|
432
|
+
el = _a.sent();
|
|
433
|
+
return [2 /*return*/, el ? (0, exports.wrapElementHandle)(el, controller) : null];
|
|
434
|
+
}
|
|
435
|
+
});
|
|
436
|
+
});
|
|
437
|
+
};
|
|
438
|
+
case '$$':
|
|
439
|
+
case '$x':
|
|
440
|
+
return function () {
|
|
441
|
+
var args = [];
|
|
442
|
+
for (var _i = 0; _i < arguments.length; _i++) {
|
|
443
|
+
args[_i] = arguments[_i];
|
|
444
|
+
}
|
|
445
|
+
return __awaiter(_this, void 0, void 0, function () {
|
|
446
|
+
var els;
|
|
447
|
+
return __generator(this, function (_a) {
|
|
448
|
+
switch (_a.label) {
|
|
449
|
+
case 0: return [4 /*yield*/, host[prop].apply(host, args)];
|
|
450
|
+
case 1:
|
|
451
|
+
els = _a.sent();
|
|
452
|
+
return [2 /*return*/, els.map(function (el) { return (0, exports.wrapElementHandle)(el, controller); })];
|
|
453
|
+
}
|
|
454
|
+
});
|
|
455
|
+
});
|
|
456
|
+
};
|
|
457
|
+
case 'asElement':
|
|
458
|
+
return function () { return (0, exports.wrapElementHandle)(host.asElement(), controller); };
|
|
459
|
+
case 'contentFrame':
|
|
460
|
+
return function () { return __awaiter(_this, void 0, void 0, function () {
|
|
461
|
+
var frame;
|
|
462
|
+
return __generator(this, function (_a) {
|
|
463
|
+
switch (_a.label) {
|
|
464
|
+
case 0: return [4 /*yield*/, host.contentFrame()];
|
|
465
|
+
case 1:
|
|
466
|
+
frame = _a.sent();
|
|
467
|
+
return [2 /*return*/, frame ? (0, exports.wrapFrame)(frame, controller) : null];
|
|
468
|
+
}
|
|
469
|
+
});
|
|
470
|
+
}); };
|
|
471
|
+
case 'frame':
|
|
472
|
+
return (0, exports.wrapFrame)(host.frame, controller);
|
|
473
|
+
case 'toElement':
|
|
474
|
+
return function () {
|
|
475
|
+
var args = [];
|
|
476
|
+
for (var _i = 0; _i < arguments.length; _i++) {
|
|
477
|
+
args[_i] = arguments[_i];
|
|
478
|
+
}
|
|
479
|
+
return __awaiter(_this, void 0, void 0, function () { var _a; return __generator(this, function (_b) {
|
|
480
|
+
switch (_b.label) {
|
|
481
|
+
case 0:
|
|
482
|
+
_a = exports.wrapElementHandle;
|
|
483
|
+
return [4 /*yield*/, host.toElement.apply(host, args)];
|
|
484
|
+
case 1: return [2 /*return*/, _a.apply(void 0, [_b.sent(), controller])];
|
|
485
|
+
}
|
|
486
|
+
}); });
|
|
487
|
+
};
|
|
488
|
+
case 'click':
|
|
489
|
+
case 'drag':
|
|
490
|
+
case 'dragAndDrop':
|
|
491
|
+
case 'dragEnter':
|
|
492
|
+
case 'dragOver':
|
|
493
|
+
case 'drop':
|
|
494
|
+
case 'focus':
|
|
495
|
+
case 'hover':
|
|
496
|
+
case 'press':
|
|
497
|
+
case 'scrollIntoView':
|
|
498
|
+
case 'select':
|
|
499
|
+
case 'tap':
|
|
500
|
+
case 'touchEnd':
|
|
501
|
+
case 'touchMove':
|
|
502
|
+
case 'touchStart':
|
|
503
|
+
case 'type':
|
|
504
|
+
return wrappedCallWithSideEffects(host, prop, controller);
|
|
505
|
+
default:
|
|
506
|
+
return Reflect.get(host, prop, receiver);
|
|
507
|
+
}
|
|
508
|
+
}
|
|
509
|
+
});
|
|
510
|
+
(0, util_1.markAsWrapped)(proxy);
|
|
511
|
+
return proxy;
|
|
512
|
+
};
|
|
513
|
+
exports.wrapElementHandle = wrapElementHandle;
|
|
514
|
+
var wrapKeyboard = function (keyboard, controller) {
|
|
515
|
+
if ((0, util_1.isWrapped)(keyboard)) {
|
|
516
|
+
return keyboard;
|
|
517
|
+
}
|
|
518
|
+
var proxy = new Proxy(keyboard, {
|
|
519
|
+
get: function (host, prop, receiver) {
|
|
520
|
+
switch (prop) {
|
|
521
|
+
case 'down':
|
|
522
|
+
case 'press':
|
|
523
|
+
case 'up':
|
|
524
|
+
case 'sendCharacter':
|
|
525
|
+
case 'type':
|
|
526
|
+
return wrappedCallWithSideEffects(host, prop, controller);
|
|
527
|
+
default:
|
|
528
|
+
return Reflect.get(host, prop, receiver);
|
|
529
|
+
}
|
|
530
|
+
}
|
|
531
|
+
});
|
|
532
|
+
(0, util_1.markAsWrapped)(proxy);
|
|
533
|
+
return proxy;
|
|
534
|
+
};
|
|
535
|
+
exports.wrapKeyboard = wrapKeyboard;
|
|
536
|
+
var wrapMouse = function (mouse, controller) {
|
|
537
|
+
if ((0, util_1.isWrapped)(mouse)) {
|
|
538
|
+
return mouse;
|
|
539
|
+
}
|
|
540
|
+
var proxy = new Proxy(mouse, {
|
|
541
|
+
get: function (host, prop, receiver) {
|
|
542
|
+
switch (prop) {
|
|
543
|
+
case 'click':
|
|
544
|
+
case 'down':
|
|
545
|
+
case 'drag':
|
|
546
|
+
case 'dragAndDrop':
|
|
547
|
+
case 'dragEnter':
|
|
548
|
+
case 'dragOver':
|
|
549
|
+
case 'drop':
|
|
550
|
+
case 'move':
|
|
551
|
+
case 'up':
|
|
552
|
+
case 'wheel':
|
|
553
|
+
return wrappedCallWithSideEffects(host, prop, controller);
|
|
554
|
+
default:
|
|
555
|
+
return Reflect.get(host, prop, receiver);
|
|
556
|
+
}
|
|
557
|
+
}
|
|
558
|
+
});
|
|
559
|
+
(0, util_1.markAsWrapped)(proxy);
|
|
560
|
+
return proxy;
|
|
561
|
+
};
|
|
562
|
+
exports.wrapMouse = wrapMouse;
|
|
563
|
+
var wrapTouchscreen = function (touchscreen, controller) {
|
|
564
|
+
if ((0, util_1.isWrapped)(touchscreen)) {
|
|
565
|
+
return touchscreen;
|
|
566
|
+
}
|
|
567
|
+
var proxy = new Proxy(touchscreen, {
|
|
568
|
+
get: function (host, prop, receiver) {
|
|
569
|
+
switch (prop) {
|
|
570
|
+
case 'tap':
|
|
571
|
+
case 'touchEnd':
|
|
572
|
+
case 'touchMove':
|
|
573
|
+
case 'touchStart':
|
|
574
|
+
return wrappedCallWithSideEffects(host, prop, controller);
|
|
575
|
+
default:
|
|
576
|
+
return Reflect.get(host, prop, receiver);
|
|
577
|
+
}
|
|
578
|
+
}
|
|
579
|
+
});
|
|
580
|
+
(0, util_1.markAsWrapped)(proxy);
|
|
581
|
+
return proxy;
|
|
582
|
+
};
|
|
583
|
+
exports.wrapTouchscreen = wrapTouchscreen;
|
|
584
|
+
var wrapDialog = function (dialog, controller) {
|
|
585
|
+
if ((0, util_1.isWrapped)(dialog)) {
|
|
586
|
+
return dialog;
|
|
587
|
+
}
|
|
588
|
+
var proxy = new Proxy(dialog, {
|
|
589
|
+
get: function (host, prop, receiver) {
|
|
590
|
+
switch (prop) {
|
|
591
|
+
case 'accept':
|
|
592
|
+
case 'dismiss':
|
|
593
|
+
return wrappedCallWithSideEffects(host, prop, controller);
|
|
594
|
+
default:
|
|
595
|
+
return Reflect.get(host, prop, receiver);
|
|
596
|
+
}
|
|
597
|
+
}
|
|
598
|
+
});
|
|
599
|
+
(0, util_1.markAsWrapped)(proxy);
|
|
600
|
+
return proxy;
|
|
601
|
+
};
|
|
602
|
+
exports.wrapDialog = wrapDialog;
|
|
603
|
+
var wrapFrame = function (frame, controller) {
|
|
604
|
+
if ((0, util_1.isWrapped)(frame)) {
|
|
605
|
+
return frame;
|
|
606
|
+
}
|
|
607
|
+
var proxy = new Proxy(frame, {
|
|
608
|
+
get: function (host, prop, receiver) {
|
|
609
|
+
var _this = this;
|
|
610
|
+
switch (prop) {
|
|
611
|
+
case '$':
|
|
612
|
+
case 'addScriptTag':
|
|
613
|
+
case 'addStyleTag':
|
|
614
|
+
case 'waitForSelector':
|
|
615
|
+
case 'waitForXPath':
|
|
616
|
+
return function () {
|
|
617
|
+
var args = [];
|
|
618
|
+
for (var _i = 0; _i < arguments.length; _i++) {
|
|
619
|
+
args[_i] = arguments[_i];
|
|
620
|
+
}
|
|
621
|
+
return __awaiter(_this, void 0, void 0, function () {
|
|
622
|
+
var el;
|
|
623
|
+
return __generator(this, function (_a) {
|
|
624
|
+
switch (_a.label) {
|
|
625
|
+
case 0: return [4 /*yield*/, host[prop].apply(host, args)];
|
|
626
|
+
case 1:
|
|
627
|
+
el = _a.sent();
|
|
628
|
+
return [2 /*return*/, el ? (0, exports.wrapElementHandle)(el, controller) : null];
|
|
629
|
+
}
|
|
630
|
+
});
|
|
631
|
+
});
|
|
632
|
+
};
|
|
633
|
+
case '$$':
|
|
634
|
+
case '$x':
|
|
635
|
+
return function () {
|
|
636
|
+
var args = [];
|
|
637
|
+
for (var _i = 0; _i < arguments.length; _i++) {
|
|
638
|
+
args[_i] = arguments[_i];
|
|
639
|
+
}
|
|
640
|
+
return __awaiter(_this, void 0, void 0, function () {
|
|
641
|
+
var els;
|
|
642
|
+
return __generator(this, function (_a) {
|
|
643
|
+
switch (_a.label) {
|
|
644
|
+
case 0: return [4 /*yield*/, host[prop].apply(host, args)];
|
|
645
|
+
case 1:
|
|
646
|
+
els = _a.sent();
|
|
647
|
+
return [2 /*return*/, els.map(function (el) { return (0, exports.wrapElementHandle)(el, controller); })];
|
|
648
|
+
}
|
|
649
|
+
});
|
|
650
|
+
});
|
|
651
|
+
};
|
|
652
|
+
case 'childFrames':
|
|
653
|
+
return function () { return host.childFrames().map(function (f) { return (0, exports.wrapFrame)(f, controller); }); };
|
|
654
|
+
case 'page':
|
|
655
|
+
return function () { return (0, exports.wrapPage)(host.page(), controller); };
|
|
656
|
+
case 'parentFrame':
|
|
657
|
+
return function () {
|
|
658
|
+
var f = host.parentFrame();
|
|
659
|
+
return f ? (0, exports.wrapFrame)(f, controller) : null;
|
|
660
|
+
};
|
|
661
|
+
case 'click':
|
|
662
|
+
case 'focus':
|
|
663
|
+
case 'goto':
|
|
664
|
+
case 'hover':
|
|
665
|
+
case 'select':
|
|
666
|
+
case 'setContent':
|
|
667
|
+
case 'tap':
|
|
668
|
+
case 'type':
|
|
669
|
+
return wrappedCallWithSideEffects(host, prop, controller);
|
|
670
|
+
default:
|
|
671
|
+
return Reflect.get(host, prop, receiver);
|
|
672
|
+
}
|
|
673
|
+
}
|
|
674
|
+
});
|
|
675
|
+
(0, util_1.markAsWrapped)(proxy);
|
|
676
|
+
return proxy;
|
|
677
|
+
};
|
|
678
|
+
exports.wrapFrame = wrapFrame;
|
|
679
|
+
var wrapJSHandle = function (frame, controller) {
|
|
680
|
+
if ((0, util_1.isWrapped)(frame)) {
|
|
681
|
+
return frame;
|
|
682
|
+
}
|
|
683
|
+
var proxy = new Proxy(frame, {
|
|
684
|
+
get: function (host, prop, receiver) {
|
|
685
|
+
switch (prop) {
|
|
686
|
+
case 'asElement':
|
|
687
|
+
return function () {
|
|
688
|
+
var el = host.asElement();
|
|
689
|
+
return el ? (0, exports.wrapElementHandle)(el, controller) : null;
|
|
690
|
+
};
|
|
691
|
+
default:
|
|
692
|
+
return Reflect.get(host, prop, receiver);
|
|
693
|
+
}
|
|
694
|
+
}
|
|
695
|
+
});
|
|
696
|
+
(0, util_1.markAsWrapped)(proxy);
|
|
697
|
+
return proxy;
|
|
698
|
+
};
|
|
699
|
+
exports.wrapJSHandle = wrapJSHandle;
|
|
700
|
+
//# sourceMappingURL=puppeteerWrapping.js.map
|