@memlab/e2e 1.0.22 → 1.0.24
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/NetworkManager.js +23 -6
- package/dist/ScriptManager.d.ts +2 -1
- package/dist/ScriptManager.js +15 -2
- package/dist/lib/E2EUtils.js +1 -1
- package/package.json +1 -1
package/dist/NetworkManager.js
CHANGED
|
@@ -49,11 +49,28 @@ class NetworkManager {
|
|
|
49
49
|
const requestCache = this.requestCache;
|
|
50
50
|
yield session.send('Network.enable');
|
|
51
51
|
yield session.send('Network.setRequestInterception', {
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
52
|
+
// when extending the interception scope, make sure
|
|
53
|
+
// also update the resourceTypeToSuffix function in ScriptManager
|
|
54
|
+
patterns: [
|
|
55
|
+
// .js scripts
|
|
56
|
+
...patterns.map(pattern => ({
|
|
57
|
+
urlPattern: pattern,
|
|
58
|
+
resourceType: 'Script',
|
|
59
|
+
interceptionStage: 'HeadersReceived',
|
|
60
|
+
})),
|
|
61
|
+
// .css stylesheets
|
|
62
|
+
...patterns.map(pattern => ({
|
|
63
|
+
urlPattern: pattern,
|
|
64
|
+
resourceType: 'Stylesheet',
|
|
65
|
+
interceptionStage: 'HeadersReceived',
|
|
66
|
+
})),
|
|
67
|
+
// .html documents
|
|
68
|
+
...patterns.map(pattern => ({
|
|
69
|
+
urlPattern: pattern,
|
|
70
|
+
resourceType: 'Document',
|
|
71
|
+
interceptionStage: 'HeadersReceived',
|
|
72
|
+
})),
|
|
73
|
+
],
|
|
57
74
|
});
|
|
58
75
|
session.on('Network.requestIntercepted', ({ interceptionId, request, responseHeaders, resourceType }) => __awaiter(this, void 0, void 0, function* () {
|
|
59
76
|
var _a;
|
|
@@ -87,7 +104,7 @@ class NetworkManager {
|
|
|
87
104
|
this.networkLog(`Failed to process ${request.url} {interception id: ${interceptionId}}: ${e}`);
|
|
88
105
|
}
|
|
89
106
|
requestCache.set(response.body, newBody);
|
|
90
|
-
this.scriptManager.logScript(request.url, newBody);
|
|
107
|
+
this.scriptManager.logScript(request.url, newBody, resourceType);
|
|
91
108
|
}
|
|
92
109
|
const newHeaders = [
|
|
93
110
|
'Date: ' + new Date().toUTCString(),
|
package/dist/ScriptManager.d.ts
CHANGED
|
@@ -22,7 +22,8 @@ export default class ScriptManager {
|
|
|
22
22
|
loadCodeForUrl(url: string): Nullable<string>;
|
|
23
23
|
getClosureScopeTreeForUrl(url: string): Nullable<ClosureScope>;
|
|
24
24
|
rewriteScript(code: string, options?: RewriteScriptOption): Promise<string>;
|
|
25
|
-
|
|
25
|
+
resourceTypeToSuffix(resourceType: string): string;
|
|
26
|
+
logScript(url: string, code: string, resourceType: string): Promise<void>;
|
|
26
27
|
private debounce;
|
|
27
28
|
}
|
|
28
29
|
//# sourceMappingURL=ScriptManager.d.ts.map
|
package/dist/ScriptManager.js
CHANGED
|
@@ -96,17 +96,30 @@ class ScriptManager {
|
|
|
96
96
|
return newCode;
|
|
97
97
|
});
|
|
98
98
|
}
|
|
99
|
-
|
|
99
|
+
resourceTypeToSuffix(resourceType) {
|
|
100
|
+
switch (resourceType) {
|
|
101
|
+
case 'Script':
|
|
102
|
+
return '.js';
|
|
103
|
+
case 'Stylesheet':
|
|
104
|
+
return '.css';
|
|
105
|
+
case 'Document':
|
|
106
|
+
return '.html';
|
|
107
|
+
default:
|
|
108
|
+
return '.unknown';
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
logScript(url, code, resourceType) {
|
|
100
112
|
return __awaiter(this, void 0, void 0, function* () {
|
|
101
113
|
if (this.urlToScriptMap.has(url)) {
|
|
102
114
|
return;
|
|
103
115
|
}
|
|
104
116
|
const metaFile = core_1.fileManager.getWebSourceMetaFile();
|
|
105
|
-
const file = path_1.default.join(core_1.fileManager.getWebSourceDir(), `${++this.fileId}.
|
|
117
|
+
const file = path_1.default.join(core_1.fileManager.getWebSourceDir(), `${++this.fileId}${this.resourceTypeToSuffix(resourceType)}`);
|
|
106
118
|
const scriptInfo = {
|
|
107
119
|
url,
|
|
108
120
|
fileId: this.fileId,
|
|
109
121
|
codePath: file,
|
|
122
|
+
resourceType,
|
|
110
123
|
};
|
|
111
124
|
this.urlToScriptMap.set(url, scriptInfo);
|
|
112
125
|
this.scriptInfos.push(scriptInfo);
|
package/dist/lib/E2EUtils.js
CHANGED