Skip to content

Commit

Permalink
[UA client hints] Align implementation with PR#46, #48 & #70
Browse files Browse the repository at this point in the history
This CL aligns the UA-CH implementation with PR#46[1], #48[2] and
#70[3].

[1] WICG/ua-client-hints#46
[2] WICG/ua-client-hints#48
[3] WICG/ua-client-hints#70

Change-Id: I8221d8a967213180a1aa1d9ef23f17e6f95718b7
  • Loading branch information
Yoav Weiss authored and chromium-wpt-export-bot committed Mar 5, 2020
1 parent d8dea9c commit 547d6aa
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 22 deletions.
2 changes: 1 addition & 1 deletion client-hints/resources/sec-ch-ua.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ def main(request, response):
response.headers.set("Accept-CH-Lifetime", "10")
response.content = '''
<script>
window.opener.postMessage({ header: "%s" }, "*");
window.opener.postMessage({ header: '%s' }, "*");
</script>
Sec-CH-UA: %s
''' % (ua, ua)
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<!DOCTYPE html>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="/webrtc/dictionary-helper.js"></script>
<script>
test(t => {
assert_true("userAgentData" in navigator);
}, "navigator.getUserAgent() is exposed.");

promise_test(async t => {
const uaData = navigator.userAgentData;
for (ua of uaData.uaList) {
assert_equals(typeof ua.brand, "string", "brand should be a string");
assert_equals(typeof ua.version, "string", "version should be a string");
}
assert_equals(typeof uaData.mobile, "boolean", "mobile should be a boolean");
const highEntropyData = await uaData.getHighEntropyValues(["platform", "platformVersion", "architecture", "model"]);
assert_equals(typeof highEntropyData["platform"], "string", "Platform brand should be a string");
assert_equals(typeof highEntropyData["platformVersion"], "string", "Platform version should be a string");
assert_equals(typeof highEntropyData["architecture"], "string", "Architecture should be a string");
assert_equals(typeof highEntropyData["model"], "string", "Model should be a string");
const highEntropyData2 = await uaData.getHighEntropyValues([]);
assert_equals(highEntropyData2["platform"], "", "Platform brand should be an empty string");
assert_equals(highEntropyData2["platformVersion"], "", "Platform version should be an empty string");
assert_equals(highEntropyData2["architecture"], "", "Architecture should be an empty string");
assert_equals(highEntropyData2["model"], "", "Model should be an empty string");
}, "navigator.getUserAgent() returns a UserAgentMetadata object.");
</script>

This file was deleted.

0 comments on commit 547d6aa

Please sign in to comment.