Skip to content
Merged
28 changes: 14 additions & 14 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -72,5 +72,8 @@
"lines": 89
}
}
},
"allowScripts": {
"puppeteer@25.2.1": true
}
}
12 changes: 6 additions & 6 deletions test/integration-spec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -864,31 +864,31 @@
options:
phone: true
metrics:
device: "Linux; Android 10; SM-G981B"
device: "Linux; Android 5.0; SM-G900P Build/LRX21T"
viewport: "360x640"

- url: "/devices.html"
label: "/devices.html (with --phone-landscape)"
options:
"phone-landscape": true
metrics:
device: "Linux; Android 10; SM-G981B"
device: "Linux; Android 5.0; SM-G900P Build/LRX21T"
viewport: "640x360"

- url: "/devices.html"
label: "/devices.html (with --tablet)"
options:
tablet: true
metrics:
device: "Linux; Android 10; SM-T870"
device: "Linux; U; en-us; KFAPWI Build/JDQ39"
viewport: "800x1280"

- url: "/devices.html"
label: "/devices.html (with --tablet-landscape)"
options:
"tablet-landscape": true
metrics:
device: "Linux; Android 10; SM-T870"
device: "Linux; U; en-us; KFAPWI Build/JDQ39"
viewport: "1280x800"

# viewport
Expand Down Expand Up @@ -1039,15 +1039,15 @@
options:
phone: true
metrics:
device: 'Linux; Android 10; SM-G981B'
device: 'Linux; Android 5.0; SM-G900P Build/LRX21T'

#user-agent
- url: "/user-agent.html"
label: "tablet user agent"
options:
tablet: true
metrics:
device: 'Linux; Android 10; SM-T870'
device: 'Linux; U; en-us; KFAPWI Build/JDQ39'

# user-agent
- url: "/user-agent.html"
Expand Down
7 changes: 5 additions & 2 deletions test/webroot/devices.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,13 @@
console.log(navigator.userAgent);
console.log(window.outerWidth, window.outerHeight);

const match = navigator.userAgent.match(/Mozilla\/5\.0 \((.*)\) AppleWebKit\/(.*) \(KHTML, like Gecko\) Chrome\/(.*) Safari\/(.*) Phantomas\/(.*)/);
// e.g. Mozilla/5.0 (Linux; Android 5.0; SM-G900P Build/LRX21T) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/75.0.3765.0 Mobile Safari/537.36
// e.g. Mozilla/5.0 (Linux; U; en-us; KFAPWI Build/JDQ39) AppleWebKit/535.19 (KHTML, like Gecko) Silk/3.13 Safari/535.19 Silk-Accelerated=true
const match = navigator.userAgent.match(/Mozilla\/5\.0 \(([^)]+)\)/);

(phantomas => {
phantomas.setMetric('device', match[1]);
phantomas.log('User agent: ', navigator.userAgent);
phantomas.setMetric('device', match && match[1] || 'n/a');
phantomas.setMetric('viewport', window.outerWidth + 'x' + window.outerHeight);
})(window.__phantomas);
</script>
Expand Down
2 changes: 1 addition & 1 deletion test/webroot/user-agent.html
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<body>
<script>
const match = navigator.userAgent.match(/Mozilla\/5\.0 \((.*)\) AppleWebKit\/(.*) \(KHTML, like Gecko\) Chrome\/(.*) Safari\/(.*) Phantomas\/(.*)/);
const match = navigator.userAgent.match(/Mozilla\/5\.0 \(([^)]+)\)/);

(phantomas => {
if (match !== null) {
Expand Down
Loading