phantomas 2.4.0 → 2.6.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/Dockerfile +9 -3
- package/lib/browser.js +7 -10
- package/lib/index.js +1 -1
- package/lib/metadata/metadata.json +17 -7
- package/modules/protocols/protocols.js +1 -1
- package/package.json +14 -10
package/Dockerfile
CHANGED
|
@@ -41,9 +41,15 @@ COPY package.json .
|
|
|
41
41
|
COPY package-lock.json .
|
|
42
42
|
RUN npm ci
|
|
43
43
|
|
|
44
|
-
#
|
|
45
|
-
|
|
46
|
-
|
|
44
|
+
# find the chrome binary and symlink it to the PATH
|
|
45
|
+
# e.g. ./.cache/puppeteer/chrome/linux-112.0.5615.121/chrome-linux64/chrome
|
|
46
|
+
RUN echo "Chrome found in: " $(find . -wholename '*chrome-linux64/chrome') && \
|
|
47
|
+
ln -s $(find . -wholename '*chrome-linux64/chrome') .
|
|
48
|
+
|
|
49
|
+
ENV PATH ${PATH}":/opt/phantomas"
|
|
50
|
+
|
|
51
|
+
RUN ldd chrome && \
|
|
52
|
+
chrome --version
|
|
47
53
|
|
|
48
54
|
ARG GITHUB_SHA="dev"
|
|
49
55
|
ENV COMMIT_SHA ${GITHUB_SHA}
|
package/lib/browser.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
// @ts-check
|
|
1
2
|
/**
|
|
2
3
|
* Expose puppeteer API and events emitter object for lib/index.js
|
|
3
4
|
*/
|
|
@@ -11,7 +12,7 @@ function Browser() {
|
|
|
11
12
|
|
|
12
13
|
/**
|
|
13
14
|
* Use the provided events emitter
|
|
14
|
-
* @param {EventEmitter} events
|
|
15
|
+
* @param {puppeteer.EventEmitter} events
|
|
15
16
|
*/
|
|
16
17
|
Browser.prototype.bind = (events) => (this.events = events);
|
|
17
18
|
|
|
@@ -25,11 +26,6 @@ Browser.prototype.init = async (phantomasOptions) => {
|
|
|
25
26
|
// page.evaluate throw "Protocol error (Runtime.callFunctionOn): Target closed." without the following
|
|
26
27
|
// https://github.com/GoogleChrome/puppeteer/issues/1175#issuecomment-369728215
|
|
27
28
|
"--disable-dev-shm-usage",
|
|
28
|
-
|
|
29
|
-
// enable http/3 support
|
|
30
|
-
// https://www.bram.us/2020/04/08/how-to-enable-http3-in-chrome-firefox-safari/
|
|
31
|
-
"--enable-quic",
|
|
32
|
-
"--quic-version=h3-29",
|
|
33
29
|
],
|
|
34
30
|
};
|
|
35
31
|
|
|
@@ -83,7 +79,7 @@ Browser.prototype.init = async (phantomasOptions) => {
|
|
|
83
79
|
}
|
|
84
80
|
|
|
85
81
|
// A Chrome Devtools Protocol session attached to the target
|
|
86
|
-
this.cdp = this.page._client;
|
|
82
|
+
this.cdp = this.page._client();
|
|
87
83
|
|
|
88
84
|
debug("Using binary from: %s", this.browser.process().spawnfile);
|
|
89
85
|
|
|
@@ -102,13 +98,14 @@ Browser.prototype.init = async (phantomasOptions) => {
|
|
|
102
98
|
this.page.on("dialog", async (dialog) => {
|
|
103
99
|
// https://github.com/GoogleChrome/puppeteer/blob/v1.11.0/docs/api.md#class-dialog
|
|
104
100
|
const message = dialog.message();
|
|
105
|
-
|
|
101
|
+
const type = dialog.type();
|
|
102
|
+
debug("dialog: %s [%s]", type, message);
|
|
106
103
|
|
|
107
|
-
switch (
|
|
104
|
+
switch (type) {
|
|
108
105
|
case "alert":
|
|
109
106
|
case "confirm":
|
|
110
107
|
case "prompt":
|
|
111
|
-
this.events.emit(
|
|
108
|
+
this.events.emit(type, message); // @desc Emitted when a JavaScript dialog appears: alert, prompt or confirm
|
|
112
109
|
break;
|
|
113
110
|
}
|
|
114
111
|
|
package/lib/index.js
CHANGED
|
@@ -63,7 +63,7 @@
|
|
|
63
63
|
"init": {
|
|
64
64
|
"file": "/lib/index.js",
|
|
65
65
|
"desc": "Browser's scope and modules are set up, the page is about to be loaded",
|
|
66
|
-
"arguments": "page, browser"
|
|
66
|
+
"arguments": "page, browser.getPuppeteerBrowser("
|
|
67
67
|
},
|
|
68
68
|
"beforeClose": {
|
|
69
69
|
"file": "/lib/index.js",
|
|
@@ -102,6 +102,11 @@
|
|
|
102
102
|
"desc": "Saves the source of page being loaded to a file\nPlease note that saving each file takes a few ms.\nConsider increasing default timeout.\nRun phantomas with --page-source option to use this module.",
|
|
103
103
|
"options": []
|
|
104
104
|
},
|
|
105
|
+
"pageStorage": {
|
|
106
|
+
"file": "/extensions/pageStorage/pageStorage.js",
|
|
107
|
+
"desc": "",
|
|
108
|
+
"options": []
|
|
109
|
+
},
|
|
105
110
|
"postLoadDelay": {
|
|
106
111
|
"file": "/extensions/postLoadDelay/postLoadDelay.js",
|
|
107
112
|
"desc": "Delays report generation for a given time",
|
|
@@ -117,6 +122,11 @@
|
|
|
117
122
|
"desc": "Allow page to be scrolled after it is loaded\nPass --scroll as an option in CLI mode",
|
|
118
123
|
"options": []
|
|
119
124
|
},
|
|
125
|
+
"userAgent": {
|
|
126
|
+
"file": "/extensions/userAgent/userAgent.js",
|
|
127
|
+
"desc": "Sets a user agent according to --user-agent or --phone or --tablet options",
|
|
128
|
+
"options": []
|
|
129
|
+
},
|
|
120
130
|
"viewport": {
|
|
121
131
|
"file": "/extensions/viewport/viewport.js",
|
|
122
132
|
"desc": "Provides the --viewport option to set any device resolution and pixel density ratio.\nIf the user sets a viewport size as well as a device option (--phone, --tablet, ...),\nwe assume that he or she wants to overwrite the device values.\nTwo syntaxes are supported:\n - 1200x800 will set a 1x pixel density ratio\n - 1200x800x2 will set the given ratio (float values such as 1.5 are accepted)",
|
|
@@ -1050,13 +1060,13 @@
|
|
|
1050
1060
|
"offenders": true,
|
|
1051
1061
|
"unit": "number",
|
|
1052
1062
|
"module": "assetsTypes",
|
|
1053
|
-
"testsCovered":
|
|
1063
|
+
"testsCovered": true
|
|
1054
1064
|
},
|
|
1055
1065
|
"videoSize": {
|
|
1056
1066
|
"desc": "size of video responses (with compression)",
|
|
1057
1067
|
"unit": "bytes",
|
|
1058
1068
|
"module": "assetsTypes",
|
|
1059
|
-
"testsCovered":
|
|
1069
|
+
"testsCovered": true
|
|
1060
1070
|
},
|
|
1061
1071
|
"base64Count": {
|
|
1062
1072
|
"desc": "number of base64 encoded \"responses\" (no HTTP request was actually made)",
|
|
@@ -1206,7 +1216,7 @@
|
|
|
1206
1216
|
"testsCovered": false
|
|
1207
1217
|
},
|
|
1208
1218
|
"recalcStyleDuration": {
|
|
1209
|
-
"desc": "combined duration of
|
|
1219
|
+
"desc": "combined duration of style recalculations",
|
|
1210
1220
|
"unit": "ms",
|
|
1211
1221
|
"module": "cpuTasks",
|
|
1212
1222
|
"testsCovered": false
|
|
@@ -1620,7 +1630,7 @@
|
|
|
1620
1630
|
"testsCovered": true
|
|
1621
1631
|
},
|
|
1622
1632
|
"oldTlsProtocol": {
|
|
1623
|
-
"desc": "number of domains using TLS 1.
|
|
1633
|
+
"desc": "number of domains using TLS 1.2",
|
|
1624
1634
|
"offenders": true,
|
|
1625
1635
|
"unit": "number",
|
|
1626
1636
|
"module": "protocols",
|
|
@@ -1868,6 +1878,6 @@
|
|
|
1868
1878
|
},
|
|
1869
1879
|
"metricsCount": 187,
|
|
1870
1880
|
"modulesCount": 36,
|
|
1871
|
-
"extensionsCount":
|
|
1872
|
-
"version": "2.
|
|
1881
|
+
"extensionsCount": 14,
|
|
1882
|
+
"version": "2.4.0"
|
|
1873
1883
|
}
|
|
@@ -11,7 +11,7 @@ module.exports = function (phantomas) {
|
|
|
11
11
|
phantomas.setMetric("mainDomainHttpProtocol"); // @desc HTTP protocol used by the main domain [string]
|
|
12
12
|
phantomas.setMetric("oldHttpProtocol"); // @desc number of domains using HTTP/1.0 or 1.1
|
|
13
13
|
phantomas.setMetric("mainDomainTlsProtocol"); // @desc TLS protocol used by the main domain [string]
|
|
14
|
-
phantomas.setMetric("oldTlsProtocol"); // @desc number of domains using TLS 1.
|
|
14
|
+
phantomas.setMetric("oldTlsProtocol"); // @desc number of domains using TLS 1.2
|
|
15
15
|
|
|
16
16
|
// spy all requests
|
|
17
17
|
phantomas.on("recv", (entry) => {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "phantomas",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.6.0",
|
|
4
4
|
"author": "macbre <maciej.brencz@gmail.com> (http://macbre.net)",
|
|
5
5
|
"description": "Headless Chromium-based web performance metrics collector and monitoring tool",
|
|
6
6
|
"main": "./lib/index.js",
|
|
@@ -28,21 +28,21 @@
|
|
|
28
28
|
},
|
|
29
29
|
"dependencies": {
|
|
30
30
|
"analyze-css": "^2.0.0",
|
|
31
|
-
"commander": "^
|
|
31
|
+
"commander": "^9.0.0",
|
|
32
32
|
"debug": "^4.1.1",
|
|
33
33
|
"decamelize": "^5.0.0",
|
|
34
34
|
"fast-stats": "0.0.6",
|
|
35
35
|
"js-yaml": "^4.0.0",
|
|
36
|
-
"puppeteer": "^
|
|
36
|
+
"puppeteer": "^20.0.0"
|
|
37
37
|
},
|
|
38
38
|
"devDependencies": {
|
|
39
|
-
"@jest/globals": "^
|
|
39
|
+
"@jest/globals": "^28.0.0",
|
|
40
40
|
"eslint": "^8.0.0",
|
|
41
41
|
"eslint-config-prettier": "^8.1.0",
|
|
42
42
|
"eslint-plugin-node": "^11.1.0",
|
|
43
|
-
"glob": "^
|
|
44
|
-
"jest": "^
|
|
45
|
-
"prettier": "2.
|
|
43
|
+
"glob": "^8.0.1",
|
|
44
|
+
"jest": "^28.0.0",
|
|
45
|
+
"prettier": "2.7.1"
|
|
46
46
|
},
|
|
47
47
|
"scripts": {
|
|
48
48
|
"test": "node --trace-warnings node_modules/.bin/jest test/ --coverage --detectOpenHandles --forceExit",
|
|
@@ -54,12 +54,16 @@
|
|
|
54
54
|
},
|
|
55
55
|
"jest": {
|
|
56
56
|
"verbose": true,
|
|
57
|
+
"reporters": [
|
|
58
|
+
"default",
|
|
59
|
+
"github-actions"
|
|
60
|
+
],
|
|
57
61
|
"coverageThreshold": {
|
|
58
62
|
"global": {
|
|
59
|
-
"statements":
|
|
63
|
+
"statements": 89,
|
|
60
64
|
"branches": 85,
|
|
61
|
-
"functions":
|
|
62
|
-
"lines":
|
|
65
|
+
"functions": 89,
|
|
66
|
+
"lines": 89
|
|
63
67
|
}
|
|
64
68
|
}
|
|
65
69
|
}
|