useragentdata.https.any.js (3157B)
1 // META: title=tests for navigator.userAgentData 2 3 test(t => { 4 const brands = navigator.userAgentData.brands; 5 assert_true(brands.every(brand => brand.brand.length < 32), 6 "No brand should be longer than 32 characters."); 7 }); 8 9 test(t => { 10 const uaData = navigator.userAgentData.toJSON(); 11 assert_own_property(uaData, "brands", "toJSON() output has brands member"); 12 assert_own_property(uaData, "mobile", "toJSON() output has mobile member"); 13 assert_own_property(uaData, "platform", "toJSON() output has platform member"); 14 }, "test NavigatorUAData.toJSON() output"); 15 16 promise_test(() => { 17 return navigator.userAgentData.getHighEntropyValues([]).then(hints => { 18 assert_own_property(hints, "brands", "brands is returned by default"); 19 assert_own_property(hints, "mobile", "mobile is returned by default"); 20 assert_own_property(hints, "platform", "platform is returned by default"); 21 }); 22 }, "getHighEntropyValues() should return low-entropy hints by default (1)."); 23 24 promise_test(() => { 25 return navigator.userAgentData.getHighEntropyValues(["wow64"]).then(hints => { 26 assert_own_property( 27 hints, "wow64", "requested high-entropy hint is returned"); 28 assert_own_property(hints, "brands", "brands is returned by default"); 29 assert_own_property(hints, "mobile", "mobile is returned by default"); 30 assert_own_property(hints, "platform", "platform is returned by default"); 31 }); 32 }, "getHighEntropyValues() should return low-entropy hints by default (2)."); 33 34 promise_test(() => { 35 return navigator.userAgentData.getHighEntropyValues(["brands", "mobile"]) 36 .then(hints => { 37 assert_own_property(hints, "brands", "requested brands is returned"); 38 assert_own_property( 39 hints, "mobile", "requested mobile is returned by default"); 40 assert_own_property( 41 hints, "platform", "platform is returned by default"); 42 }); 43 }, "getHighEntropyValues() should return low-entropy hints by default (3)."); 44 45 promise_test(() => { 46 return navigator.userAgentData.getHighEntropyValues(["platform", "wow64"]) 47 .then(hints => { 48 assert_own_property(hints, "brands", "brands is returned by default"); 49 assert_own_property(hints, "mobile", "mobile is returned by default"); 50 assert_own_property( 51 hints, "platform", "requested platform is returned"); 52 assert_own_property(hints, "wow64", "requested wow64 is returned"); 53 }); 54 }, "getHighEntropyValues() should return low-entropy hints by default (4)."); 55 56 promise_test(() => { 57 return navigator.userAgentData.getHighEntropyValues(["architecture"]).then( 58 hints => assert_true(["x86", "arm"].some(item => item == hints.architecture)) 59 ); 60 }, "Arch should be one of two permitted values."); 61 62 promise_test(() => { 63 return navigator.userAgentData.getHighEntropyValues(["platformVersion", "wow64"]).then( 64 hints => { 65 if (["Fuchsia", "Linux"].includes(navigator.userAgentData.platform)) { 66 assert_true(hints.platformVersion === ""); 67 assert_equals(hints.wow64, false); 68 } 69 } 70 ); 71 }, "Platform version and wow64-ness on Fuchsia and Linux should be fixed values");