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 464620 9ba789d8e8d3
parent 464619 53d055724690
child 464621 fabf03c3df32
push id35717
push useraciure@mozilla.com
push dateSun, 17 Mar 2019 09:45:26 +0000
treeherdermozilla-central@e0861be8d6c0 [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>