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 3, 2020
1 parent b32ae7b commit b14db07
Show file tree
Hide file tree
Showing 3 changed files with 28 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,27 @@
<!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("getUserAgent" in navigator);
}, "navigator.getUserAgent() is exposed.");

promise_test(t => {
return new Promise(async (resolve) => {
const ua = navigator.getUserAgent();
for (brand of ua.brand) {
assert_equals(typeof brand.brand, 'string', "brand should be a string");
assert_equals(typeof brand.version, 'string', "version should be a string");
}
const platform = await ua.getPlatform();
assert_equals(typeof platform.brand, 'string', "Platform brand should be a string");
assert_equals(typeof platform.version, 'string', "Platform version should be a string");
const architecture = await ua.getArchitecture();
assert_equals(typeof architecture, 'string', "Architecture should be a string");
const model = await ua.getModel();
assert_equals(typeof model, 'string', "Model should be a string");
resolve();
});
}, "navigator.getUserAgent() returns a UserAgentMetadata object.");
</script>

This file was deleted.

0 comments on commit b14db07

Please sign in to comment.