Bug 1528274 [wpt PR 15418] - Sec-CH-UA: Send only the major version by default., a=testonly
authorMike West <mkwst@chromium.org>
Wed, 06 Mar 2019 12:31:15 +0000
changeset 525515 9ba789d8e8d3c6fa7d6ba36d3fff09411e311e9c
parent 525514 53d055724690f5348ff99e07c2f1557f2e6c5b72
child 525516 fabf03c3df32ee82b484792597ca20cba816ecf5
push id2032
push userffxbld-merge
push dateMon, 13 May 2019 09:36:57 +0000
treeherdermozilla-release@455c1065dcbe [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerstestonly
bugs1528274, 15418, 928669, 1475438, 633726
milestone67.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1528274 [wpt PR 15418] - Sec-CH-UA: Send only the major version by default., a=testonly Automatic update from web-platform-tests Sec-CH-UA: Send only the major version by default. Rather than sending a `Sec-CH-UA` header containing the full version number by default (e.g. "Chromium 99.0.1232.12"), send only the major version (e.g. "Chromium 99"). This does not effect the value of `UserAgent.version` obtained from `navigator.getUserAgent()`, but only the HTTP request header. Bug: 928669 Change-Id: I074e244a3918b0bdab4453c2f56dc737c506f732 Reviewed-on: https://chromium-review.googlesource.com/c/1475438 Reviewed-by: Jochen Eisinger <jochen@chromium.org> Reviewed-by: Tarun Bansal <tbansal@chromium.org> Commit-Queue: Mike West <mkwst@chromium.org> Cr-Commit-Position: refs/heads/master@{#633726} -- wpt-commits: f70ff91fce2695f4303075b45eb8660f7a8d6508 wpt-pr: 15418
testing/web-platform/tests/client-hints/resources/sec-ch-ua.py
testing/web-platform/tests/client-hints/sec-ch-ua.http.html
testing/web-platform/tests/client-hints/sec-ch-ua.https.html
new file mode 100644
--- /dev/null
+++ b/testing/web-platform/tests/client-hints/resources/sec-ch-ua.py
@@ -0,0 +1,11 @@
+def main(request, response):
+    ua = request.headers.get('sec-ch-ua', '')
+    response.headers.set("Content-Type", "text/html")
+    response.headers.set("Accept-CH", "UA")
+    response.headers.set("Accept-CH-Lifetime", "10")
+    response.content = '''
+<script>
+  window.opener.postMessage({ header: "%s" }, "*");
+</script>
+Sec-CH-UA: %s
+''' % (ua, ua)
new file mode 100644
--- /dev/null
+++ b/testing/web-platform/tests/client-hints/sec-ch-ua.http.html
@@ -0,0 +1,16 @@
+<!DOCTYPE html>
+<script src=/resources/testharness.js></script>
+<script src=/resources/testharnessreport.js></script>
+<script>
+  promise_test(t => {
+    return new Promise((resolve, reject) => {
+      var w;
+      window.onmessage = e => {
+        assert_equals(e.data.header, "", "The `Sec-CH-UA` header is not delivered.");
+        w.close();
+        resolve();
+      };
+      w = window.open("./resources/sec-ch-ua.py");
+    });
+  }, "Open HTTP window: no `Sec-CH-UA` header.")
+</script>
new file mode 100644
--- /dev/null
+++ b/testing/web-platform/tests/client-hints/sec-ch-ua.https.html
@@ -0,0 +1,41 @@
+<!DOCTYPE html>
+<head>
+<script src=/resources/testharness.js></script>
+<script src=/resources/testharnessreport.js></script>
+<script>
+  var minor = "";
+  promise_test(t => {
+    return new Promise((resolve, reject) => {
+      var w;
+      window.onmessage = e => {
+        try {
+          assert_not_equals(e.data.header, "", "The `Sec-CH-UA` header is delivered.");
+          minor = e.data.header;
+        } catch (ex) {
+          reject(ex);
+        }
+        w.close();
+        resolve();
+      };
+      w = window.open("./resources/sec-ch-ua.py");
+    });
+  }, "Open HTTPS window prior to opt-in: `Sec-CH-UA` header with minor version.")
+
+  promise_test(t => {
+    return new Promise((resolve, reject) => {
+      var w;
+      window.onmessage = e => {
+        try {
+          assert_not_equals(e.data.header, "", "The `Sec-CH-UA` header is delivered.");
+          assert_not_equals(e.data.header, minor, "The `Sec-CH-UA` header is different after the opt-in than before.");
+        } catch (ex) {
+          reject(ex);
+        }
+        w.close();
+        resolve();
+      };
+      w = window.open("./resources/sec-ch-ua.py");
+    });
+  }, "Open HTTPS window post-opt-in: `Sec-CH-UA` header with minor version.")
+</script>
+</head>