@memlab/e2e 1.0.41 → 1.0.43

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.
@@ -97,8 +97,8 @@ class E2EInteractionManager {
97
97
  }
98
98
  });
99
99
  }
100
- initialLoad(page_1, url_1) {
101
- return __awaiter(this, arguments, void 0, function* (page, url, opArgs = {}) {
100
+ initialLoad(page, url, opArgs = {}) {
101
+ return __awaiter(this, void 0, void 0, function* () {
102
102
  if (core_1.config.verbose) {
103
103
  core_1.info.lowLevel(`loading: ${url}`);
104
104
  }
@@ -134,9 +134,9 @@ class E2EInteractionManager {
134
134
  }
135
135
  });
136
136
  }
137
- visitAndGetSnapshots() {
138
- return __awaiter(this, arguments, void 0, function* (options = {}) {
139
- var _a;
137
+ visitAndGetSnapshots(options = {}) {
138
+ var _a;
139
+ return __awaiter(this, void 0, void 0, function* () {
140
140
  const visitPlan = options.testPlanner
141
141
  ? options.testPlanner.getVisitPlan()
142
142
  : TestPlanner_1.default.getVisitPlan();
@@ -223,8 +223,8 @@ class E2EInteractionManager {
223
223
  }
224
224
  });
225
225
  }
226
- visitPage(url_1) {
227
- return __awaiter(this, arguments, void 0, function* (url, options = {}) {
226
+ visitPage(url, options = {}) {
227
+ return __awaiter(this, void 0, void 0, function* () {
228
228
  try {
229
229
  yield this.page.goto(url, {
230
230
  timeout: core_1.config.warmupPageLoadTimeout,
@@ -237,9 +237,9 @@ class E2EInteractionManager {
237
237
  }
238
238
  });
239
239
  }
240
- getPageStatistics(url_1, tabInfo_1) {
241
- return __awaiter(this, arguments, void 0, function* (url, tabInfo, opArgs = {}) {
242
- var _a, _b;
240
+ getPageStatistics(url, tabInfo, opArgs = {}) {
241
+ var _a, _b;
242
+ return __awaiter(this, void 0, void 0, function* () {
243
243
  if (core_1.config.verbose) {
244
244
  core_1.info.lowLevel('url: ' + url);
245
245
  }
@@ -293,8 +293,8 @@ class E2EInteractionManager {
293
293
  }
294
294
  });
295
295
  }
296
- interactWithPage(page_1, operations_1) {
297
- return __awaiter(this, arguments, void 0, function* (page, operations, opArgs = {}) {
296
+ interactWithPage(page, operations, opArgs = {}) {
297
+ return __awaiter(this, void 0, void 0, function* () {
298
298
  const args = Object.assign(Object.assign({}, opArgs), { pageHistoryLength: this.pageHistoryLength });
299
299
  if (typeof operations === 'function') {
300
300
  yield operations(page, args);
@@ -390,8 +390,8 @@ class E2EInteractionManager {
390
390
  yield this.forceMainThreadGC(6);
391
391
  });
392
392
  }
393
- forceMainThreadGC() {
394
- return __awaiter(this, arguments, void 0, function* (repeat = 1) {
393
+ forceMainThreadGC(repeat = 1) {
394
+ return __awaiter(this, void 0, void 0, function* () {
395
395
  const client = yield this.getMainThreadCDPSession();
396
396
  for (let i = 0; i < repeat; i++) {
397
397
  yield client.send('HeapProfiler.collectGarbage');
@@ -402,8 +402,8 @@ class E2EInteractionManager {
402
402
  });
403
403
  }
404
404
  collectMetrics(tabInfo) {
405
+ var _a;
405
406
  return __awaiter(this, void 0, void 0, function* () {
406
- var _a;
407
407
  // collect navigation history info
408
408
  const historyLength = yield getNavigationHistoryLength(this.page);
409
409
  this.pageHistoryLength.push(historyLength);
@@ -72,15 +72,15 @@ class NetworkManager {
72
72
  })),
73
73
  ],
74
74
  });
75
- session.on('Network.requestIntercepted', (_a) => __awaiter(this, [_a], void 0, function* ({ interceptionId, request, responseHeaders, resourceType }) {
76
- var _b;
75
+ session.on('Network.requestIntercepted', ({ interceptionId, request, responseHeaders, resourceType }) => __awaiter(this, void 0, void 0, function* () {
76
+ var _a;
77
77
  this.networkLog(`Intercepted ${request.url} {interception id: ${interceptionId}}`);
78
78
  const response = (yield session.send('Network.getResponseBodyForInterception', { interceptionId }));
79
79
  // responseHeaders could be null if requesting from
80
80
  // local files (i.e., urls starting with 'file:///')
81
81
  let contentType = null;
82
82
  if (responseHeaders) {
83
- const contentTypeHeader = (_b = Object.keys(responseHeaders).find(k => k.toLowerCase() === 'content-type')) !== null && _b !== void 0 ? _b : '';
83
+ const contentTypeHeader = (_a = Object.keys(responseHeaders).find(k => k.toLowerCase() === 'content-type')) !== null && _a !== void 0 ? _a : '';
84
84
  contentType = responseHeaders[contentTypeHeader];
85
85
  }
86
86
  let newBody = '';
@@ -87,8 +87,8 @@ class ScriptManager {
87
87
  }
88
88
  return null;
89
89
  }
90
- rewriteScript(code_1) {
91
- return __awaiter(this, arguments, void 0, function* (code, options = {}) {
90
+ rewriteScript(code, options = {}) {
91
+ return __awaiter(this, void 0, void 0, function* () {
92
92
  if (!core_1.config.instrumentJS) {
93
93
  return code;
94
94
  }
@@ -3,14 +3,14 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.testScopeAnalysis = testScopeAnalysis;
7
- exports.removeLoc = removeLoc;
6
+ exports.removeLoc = exports.testScopeAnalysis = void 0;
8
7
  const Script_1 = __importDefault(require("../../code-analysis/Script"));
9
8
  function testScopeAnalysis(code, expectedScope) {
10
9
  const script = new Script_1.default(code);
11
10
  const scope = script.getClosureScopeTree();
12
11
  expect(removeLoc(scope)).toEqual(removeLoc(expectedScope));
13
12
  }
13
+ exports.testScopeAnalysis = testScopeAnalysis;
14
14
  function removeLoc(entity) {
15
15
  const visited = new Set();
16
16
  function remove(e) {
@@ -30,3 +30,4 @@ function removeLoc(entity) {
30
30
  remove(entity);
31
31
  return entity;
32
32
  }
33
+ exports.removeLoc = removeLoc;
package/dist/index.js CHANGED
@@ -35,8 +35,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
35
35
  return (mod && mod.__esModule) ? mod : { "default": mod };
36
36
  };
37
37
  Object.defineProperty(exports, "__esModule", { value: true });
38
- exports.ScriptManager = exports.E2EUtils = exports.BaseSynthesizer = exports.E2EInteractionManager = exports.Xvfb = exports.defaultTestPlanner = void 0;
39
- exports.registerPackage = registerPackage;
38
+ exports.ScriptManager = exports.E2EUtils = exports.BaseSynthesizer = exports.E2EInteractionManager = exports.Xvfb = exports.defaultTestPlanner = exports.registerPackage = void 0;
40
39
  const path_1 = __importDefault(require("path"));
41
40
  const core_1 = require("@memlab/core");
42
41
  /** @internal */
@@ -45,6 +44,7 @@ function registerPackage() {
45
44
  return core_1.PackageInfoLoader.registerPackage(path_1.default.join(__dirname, '..'));
46
45
  });
47
46
  }
47
+ exports.registerPackage = registerPackage;
48
48
  var TestPlanner_1 = require("./lib/operations/TestPlanner");
49
49
  Object.defineProperty(exports, "defaultTestPlanner", { enumerable: true, get: function () { return __importDefault(TestPlanner_1).default; } });
50
50
  __exportStar(require("./lib/operations/TestPlanner"), exports);
@@ -20,10 +20,10 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
20
20
  Object.defineProperty(exports, "__esModule", { value: true });
21
21
  const core_1 = require("@memlab/core");
22
22
  class BaseAstTransform {
23
- transform(ast_1) {
24
- return __awaiter(this, arguments, void 0, function* (ast,
25
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
26
- options = {}) {
23
+ transform(ast,
24
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
25
+ options = {}) {
26
+ return __awaiter(this, void 0, void 0, function* () {
27
27
  throw core_1.utils.haltOrThrow('BaseAstTransform.transform is not implemented');
28
28
  });
29
29
  }
@@ -25,8 +25,8 @@ const parser_1 = require("@babel/parser");
25
25
  const generator_1 = __importDefault(require("@babel/generator"));
26
26
  const TransformLoader_1 = __importDefault(require("./TransformLoader"));
27
27
  class ScriptRewriteManager {
28
- rewriteScript(code_1) {
29
- return __awaiter(this, arguments, void 0, function* (code, options = {}) {
28
+ rewriteScript(code, options = {}) {
29
+ return __awaiter(this, void 0, void 0, function* () {
30
30
  // parse code
31
31
  const ast = (0, parser_1.parse)(code, {
32
32
  sourceType: 'script',
@@ -16,9 +16,9 @@ const traverse_1 = __importDefault(require("@babel/traverse"));
16
16
  const template_1 = __importDefault(require("@babel/template"));
17
17
  const BaseAstTransform_1 = __importDefault(require("../BaseAstTransform"));
18
18
  class InjectSourceInfoTranform extends BaseAstTransform_1.default {
19
- transform(ast_1) {
20
- return __awaiter(this, arguments, void 0, function* (ast, options = {}) {
21
- var _a;
19
+ transform(ast, options = {}) {
20
+ var _a;
21
+ return __awaiter(this, void 0, void 0, function* () {
22
22
  const url = (_a = options.url) !== null && _a !== void 0 ? _a : '';
23
23
  const instrumentFunction = function (path) {
24
24
  var _a, _b;
@@ -16,9 +16,9 @@ const traverse_1 = __importDefault(require("@babel/traverse"));
16
16
  const template_1 = __importDefault(require("@babel/template"));
17
17
  const BaseAstTransform_1 = __importDefault(require("../BaseAstTransform"));
18
18
  class InjectSourceInfoTransform extends BaseAstTransform_1.default {
19
- transform(ast_1) {
20
- return __awaiter(this, arguments, void 0, function* (ast, options = {}) {
21
- var _a;
19
+ transform(ast, options = {}) {
20
+ var _a;
21
+ return __awaiter(this, void 0, void 0, function* () {
22
22
  const url = (_a = options.url) !== null && _a !== void 0 ? _a : '';
23
23
  const instrumentFunction = function (path) {
24
24
  var _a, _b;
@@ -134,12 +134,12 @@ function maybeWaitForConsoleInput(stepId) {
134
134
  }
135
135
  });
136
136
  }
137
- function applyAsyncWithGuard(f_1, self_1, args_1) {
138
- return __awaiter(this, arguments, void 0, function* (f, self, args,
139
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
140
- exceptionHandler = (_ex) => {
141
- /*noop*/
142
- }) {
137
+ function applyAsyncWithGuard(f, self, args,
138
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
139
+ exceptionHandler = (_ex) => {
140
+ /*noop*/
141
+ }) {
142
+ return __awaiter(this, void 0, void 0, function* () {
143
143
  let ret;
144
144
  try {
145
145
  ret = yield f.apply(self, args);
@@ -150,8 +150,8 @@ function applyAsyncWithGuard(f_1, self_1, args_1) {
150
150
  return ret;
151
151
  });
152
152
  }
153
- function applyAsyncWithRetry(f_1, self_1, args_1) {
154
- return __awaiter(this, arguments, void 0, function* (f, self, args, options = {}) {
153
+ function applyAsyncWithRetry(f, self, args, options = {}) {
154
+ return __awaiter(this, void 0, void 0, function* () {
155
155
  options.retry = options.retry || 0;
156
156
  const retry = options.retry;
157
157
  const exceptionHandler = (ex) => __awaiter(this, void 0, void 0, function* () {
@@ -38,8 +38,8 @@ class BaseOperation {
38
38
  core_1.info.overwrite(msg);
39
39
  }
40
40
  }
41
- do(page_1) {
42
- return __awaiter(this, arguments, void 0, function* (page, opArgs = {}) {
41
+ do(page, opArgs = {}) {
42
+ return __awaiter(this, void 0, void 0, function* () {
43
43
  if (core_1.config.verbose && core_1.config.runningMode.shouldTakeScreenShot()) {
44
44
  yield InteractionUtils_1.default.screenshot(page, `${++opId}-${this.kind}`);
45
45
  }
@@ -56,8 +56,8 @@ class BaseOperation {
56
56
  });
57
57
  }
58
58
  // eslint-disable-next-line @typescript-eslint/no-unused-vars
59
- act(_page_1) {
60
- return __awaiter(this, arguments, void 0, function* (_page, _opArgs = {}) {
59
+ act(_page, _opArgs = {}) {
60
+ return __awaiter(this, void 0, void 0, function* () {
61
61
  const error = new Error('BaseOperation.act can not be called.');
62
62
  error.stack;
63
63
  throw error;
@@ -28,9 +28,9 @@ function waitFor(delay) {
28
28
  setTimeout(resolve, delay);
29
29
  });
30
30
  }
31
- function WaitUntilCallbackReturnsTrue(page_1, isPageLoaded_1) {
32
- return __awaiter(this, arguments, void 0, function* (page, isPageLoaded, options = {}) {
33
- var _a;
31
+ function WaitUntilCallbackReturnsTrue(page, isPageLoaded, options = {}) {
32
+ var _a;
33
+ return __awaiter(this, void 0, void 0, function* () {
34
34
  if (options.showProgress) {
35
35
  core_1.info.overwrite('waiting for page load...');
36
36
  }
@@ -73,9 +73,9 @@ function WaitUntilCallbackReturnsTrue(page_1, isPageLoaded_1) {
73
73
  }
74
74
  });
75
75
  }
76
- function waitUntilLoaded(page_1) {
77
- return __awaiter(this, arguments, void 0, function* (page, options = {}) {
78
- var _a;
76
+ function waitUntilLoaded(page, options = {}) {
77
+ var _a;
78
+ return __awaiter(this, void 0, void 0, function* () {
79
79
  // manual delay supercedes page load checker
80
80
  let delay = (_a = options.delay) !== null && _a !== void 0 ? _a : 0;
81
81
  if (delay > 0) {
@@ -115,8 +115,8 @@ function getWaitTimeout(optional) {
115
115
  }
116
116
  return core_1.config.presenceCheckTimeout || 60000;
117
117
  }
118
- function waitForSelector(page_1, selector_1) {
119
- return __awaiter(this, arguments, void 0, function* (page, selector, whatToWaitForSelectorToDo = 'exist', optional = false) {
118
+ function waitForSelector(page, selector, whatToWaitForSelectorToDo = 'exist', optional = false) {
119
+ return __awaiter(this, void 0, void 0, function* () {
120
120
  const timeout = getWaitTimeout(optional);
121
121
  let waitConfig = null;
122
122
  switch (whatToWaitForSelectorToDo) {
@@ -157,8 +157,8 @@ function waitForSelector(page_1, selector_1) {
157
157
  }
158
158
  });
159
159
  }
160
- function keepTryingUntil(checkCallback_1) {
161
- return __awaiter(this, arguments, void 0, function* (checkCallback, timeout = 2000) {
160
+ function keepTryingUntil(checkCallback, timeout = 2000) {
161
+ return __awaiter(this, void 0, void 0, function* () {
162
162
  const startTimestamp = Date.now();
163
163
  let currentTimestamp = Date.now();
164
164
  while (currentTimestamp - startTimestamp < timeout) {
@@ -172,18 +172,18 @@ function keepTryingUntil(checkCallback_1) {
172
172
  return false;
173
173
  });
174
174
  }
175
- function checkIfPresent(page_1, selector_1) {
176
- return __awaiter(this, arguments, void 0, function* (page, selector, optional = false) {
175
+ function checkIfPresent(page, selector, optional = false) {
176
+ return __awaiter(this, void 0, void 0, function* () {
177
177
  return waitForSelector(page, selector, 'exist', optional);
178
178
  });
179
179
  }
180
- function checkIfVisible(page_1, selector_1) {
181
- return __awaiter(this, arguments, void 0, function* (page, selector, optional = false) {
180
+ function checkIfVisible(page, selector, optional = false) {
181
+ return __awaiter(this, void 0, void 0, function* () {
182
182
  return waitForSelector(page, selector, 'appear', optional);
183
183
  });
184
184
  }
185
- function waitForDisappearance(page_1, selector_1) {
186
- return __awaiter(this, arguments, void 0, function* (page, selector, optional = false) {
185
+ function waitForDisappearance(page, selector, optional = false) {
186
+ return __awaiter(this, void 0, void 0, function* () {
187
187
  return waitForSelector(page, selector, 'disappear', optional);
188
188
  });
189
189
  }
@@ -194,8 +194,8 @@ function getElementsContainingText(page, text) {
194
194
  });
195
195
  }
196
196
  function findBySelector(page, xpath) {
197
+ var _a;
197
198
  return __awaiter(this, void 0, void 0, function* () {
198
- var _a;
199
199
  const _page = page;
200
200
  if (typeof _page.$x === 'function') {
201
201
  return ((_a = (yield _page.$x(xpath))) !== null && _a !== void 0 ? _a : []);
@@ -30,8 +30,8 @@ class RevertOperation extends BaseOperation_1.default {
30
30
  super();
31
31
  this.kind = 'revert';
32
32
  }
33
- act(page_1) {
34
- return __awaiter(this, arguments, void 0, function* (page, opArgs = {}) {
33
+ act(page, opArgs = {}) {
34
+ return __awaiter(this, void 0, void 0, function* () {
35
35
  let historyLen = opArgs.pageHistoryLength;
36
36
  if (Array.isArray(historyLen) && historyLen.length > 1) {
37
37
  historyLen = historyLen;
@@ -36,8 +36,8 @@ class ScrollOperation extends BaseOperation_1.default {
36
36
  this.scrollBack =
37
37
  typeof opt.scrollBack === 'boolean' ? opt.scrollBack : true;
38
38
  }
39
- act(page_1) {
40
- return __awaiter(this, arguments, void 0, function* (page, opArgs = {}) {
39
+ act(page, opArgs = {}) {
40
+ return __awaiter(this, void 0, void 0, function* () {
41
41
  if (core_1.config.disableScroll || !core_1.config.runningMode.shouldScroll()) {
42
42
  return;
43
43
  }
@@ -59,8 +59,8 @@ class ScrollOperation extends BaseOperation_1.default {
59
59
  });
60
60
  }
61
61
  }
62
- function scroll(page_1, dist_1) {
63
- return __awaiter(this, arguments, void 0, function* (page, dist, idx = 0, opArgs) {
62
+ function scroll(page, dist, idx = 0, opArgs) {
63
+ return __awaiter(this, void 0, void 0, function* () {
64
64
  core_1.info.beginSection('scroll');
65
65
  yield InteractionUtils_1.default.waitUntilLoaded(page, opArgs);
66
66
  if (idx > 1) {
@@ -1 +1 @@
1
- {"version":3,"file":"XVirtualFrameBuffer.d.ts","sourceRoot":"","sources":["../../../src/lib/operations/XVirtualFrameBuffer.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAGH,OAAO,KAAK,EAAC,QAAQ,EAAE,QAAQ,EAAC,MAAM,cAAc,CAAC;;sBAIjC,QAAQ,CAAC,QAAQ,CAAC;;AADtC,wBA0BE"}
1
+ {"version":3,"file":"XVirtualFrameBuffer.d.ts","sourceRoot":"","sources":["../../../src/lib/operations/XVirtualFrameBuffer.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAGH,OAAO,KAAK,EAAC,QAAQ,EAAE,QAAQ,EAAC,MAAM,cAAc,CAAC;;sBAIjC,SAAS,QAAQ,CAAC;;AADtC,wBA0BE"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@memlab/e2e",
3
- "version": "1.0.41",
3
+ "version": "1.0.43",
4
4
  "license": "MIT",
5
5
  "description": "memlab browser E2E interaction libraries",
6
6
  "author": "Liang Gong <lgong@meta.com>",
@@ -25,8 +25,8 @@
25
25
  "@babel/parser": "^7.16.4",
26
26
  "@babel/template": "^7.16.0",
27
27
  "@babel/traverse": "^7.16.3",
28
- "@memlab/core": "^1.1.41",
29
- "@memlab/lens": "^1.0.0",
28
+ "@memlab/core": "^1.1.43",
29
+ "@memlab/lens": "^1.0.3",
30
30
  "ansi": "^0.3.1",
31
31
  "babar": "^0.2.0",
32
32
  "chalk": "^4.0.0",
@@ -9,7 +9,7 @@
9
9
  "lint": "next lint"
10
10
  },
11
11
  "dependencies": {
12
- "next": ">=14.2.25",
12
+ "next": ">=15.2.3",
13
13
  "react": "18.2.0",
14
14
  "react-dom": "18.2.0"
15
15
  },
@@ -17,7 +17,7 @@ export default function DetachedDom() {
17
17
  window.leakedObjects.push(document.createElement('div'));
18
18
  }
19
19
  console.log(
20
- 'Detached DOMs are created. Please check Memory tab in devtools',
20
+ 'Detached DOMs are created. Please check Memory tab in Chrome DevTools',
21
21
  );
22
22
  };
23
23
 
@@ -30,7 +30,7 @@ export default function OversizedObject() {
30
30
  <br />
31
31
  <div className="row">
32
32
  Object<code>bigArray</code>is leaked. Please check <code>Memory</code>{' '}
33
- tab in devtools
33
+ tab in DevTools
34
34
  </div>
35
35
  </div>
36
36
  );
@@ -29,7 +29,7 @@ export default function Home() {
29
29
  </div>
30
30
  </div>
31
31
  <div className="row alert alert-secondary" role="alert">
32
- Make sure to open your <code>Console</code> tab in devtools.
32
+ Make sure to open your <code>Console</code> tab in DevTools.
33
33
  </div>
34
34
  </>
35
35
  );