Improve device.type detection using client hints "form-factor" data

This commit is contained in:
Faisal Salman
2023-08-20 13:41:03 +07:00
parent d168b75a3a
commit 2046b77ede
2 changed files with 34 additions and 0 deletions

View File

@@ -462,4 +462,23 @@ describe('Map UA-CH headers', function () {
assert.strictEqual(ua.device.is("tablet"), false);
});
});
it('Can detect form-factor from client-hints', function () {
const FFVR = {
'sec-ch-ua-form-factor' : 'VR'
};
const FFUnknown = {
'sec-ch-ua-form-factor' : 'Unknown'
};
UAParser(FFVR).withClientHints().then(function (ua) {
assert.strictEqual(ua.device.type, 'wearable');
});
UAParser(FFUnknown).withClientHints().then(function (ua) {
assert.strictEqual(ua.device.type, undefined);
});
});
});