Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[UA client hints] Align implementation with PR#46, #48 & #70 #21428

Merged
merged 1 commit into from
Mar 6, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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.