WorkerNavigator_userAgentData.https.html (2928B)
1 <!DOCTYPE html> 2 <title> WorkerNavigator.userAgentData </title> 3 <script src="/resources/testharness.js"></script> 4 <script src="/resources/testharnessreport.js"></script> 5 <script> 6 7 promise_test(async () => { 8 const e = await new Promise((resolve, reject) => { 9 const worker = new Worker("./support/WorkerNavigator.js"); 10 worker.onmessage = resolve; 11 }); 12 13 assert_equals(e.data.brands.length, navigator.userAgentData.brands.length); 14 for (let i = 0; i < e.data.brands.length; ++i) { 15 const workerUA = e.data.brands[i]; 16 const windowUA = navigator.userAgentData.brands[i]; 17 assert_equals(workerUA.brand, windowUA.brand); 18 assert_equals(workerUA.version, windowUA.version); 19 } 20 assert_equals(e.data.mobile, navigator.userAgentData.mobile); 21 assert_equals(e.data.platform, navigator.userAgentData.platform); 22 const highEntropyValues = await navigator.userAgentData.getHighEntropyValues([ 23 "architecture", "bitness", "fullVersionList", "model", 24 "platformVersion", "uaFullVersion", "wow64", "formFactors", 25 ]); 26 27 assert_equals(e.data.fullVersionList.length, 28 highEntropyValues.fullVersionList.length); 29 for (let i = 0; i < e.data.fullVersionList.length; ++i) { 30 const workerFV = e.data.fullVersionList[i]; 31 const windowFV = highEntropyValues.fullVersionList[i]; 32 assert_equals(workerFV.brand, windowFV.brand); 33 assert_equals(workerFV.version, windowFV.version); 34 } 35 36 assert_equals(e.data.architecture, highEntropyValues.architecture); 37 assert_equals(e.data.bitness, highEntropyValues.bitness); 38 assert_equals(e.data.model, highEntropyValues.model); 39 assert_equals(e.data.platformVersion, highEntropyValues.platformVersion); 40 assert_equals(e.data.uaFullVersion, highEntropyValues.uaFullVersion); 41 assert_equals(e.data.wow64, highEntropyValues.wow64); 42 assert_equals(e.data.formFactors.join(','), highEntropyValues.formFactors.join(',')); 43 assert_equals(e.data.NavigatorUADataExposed, true); 44 45 // Architecture should be one of two permitted values. 46 assert_true(["x86", "arm"].some(arch => arch == e.data.architecture)) 47 }, "Test that userAgentData is available in workers in secure contexts"); 48 49 promise_test(async () => { 50 const e = await new Promise((resolve) => { 51 const worker = new Worker("./support/WorkerNavigator.js"); 52 worker.onmessage = resolve; 53 }); 54 const highEntropyValues = await navigator.userAgentData.getHighEntropyValues([ 55 "platformVersion", "wow64" 56 ]); 57 58 if (["Fuchsia", "Linux"].includes(navigator.userAgentData.platform)) { 59 assert_true(e.data.platformVersion === ""); 60 assert_equals(e.data.wow64, false); 61 assert_true(highEntropyValues.platformVersion === ""); 62 assert_equals(highEntropyValues.wow64, false); 63 } 64 }, "Platform version and wow64-ness on Linux and Fuchsia should contain fixed values"); 65 </script>