Bug 1443647 [wpt PR 9888] - External WPT tests for Client hints, a=testonly
authorTarun Bansal <tbansal@chromium.org>
Mon, 09 Apr 2018 16:35:57 +0000
changeset 467017 1308745abfab7734148db8b7179ce392c2e84d00
parent 467016 8e1c3b842562bca17103a7949e91799635e16152
child 467018 40f0961962279593873bcd69cc981b5953e330c8
push id9165
push userasasaki@mozilla.com
push dateThu, 26 Apr 2018 21:04:54 +0000
treeherdermozilla-beta@064c3804de2e [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerstestonly
bugs1443647, 817049, 951867, 542724
milestone61.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 1443647 [wpt PR 9888] - External WPT tests for Client hints, a=testonly Automatic update from web-platform-testsExternal WPT tests for Client hints This CL includes the test for "Accept-CH" header. If the origin includes "Accept-CH" in the response header, then the browser should include the specified client hints in the HTTP request headers for the resources contained in that page. Bug: 817049 Change-Id: Id74193ab7a1cc3c4b03d66e080c43c64a6fcfbb2 Reviewed-on: https://chromium-review.googlesource.com/951867 Reviewed-by: Philip J├Ągenstedt <foolip@chromium.org> Reviewed-by: Kinuko Yasuda <kinuko@chromium.org> Commit-Queue: Tarun Bansal <tbansal@chromium.org> Cr-Commit-Position: refs/heads/master@{#542724} wpt-commits: 7879f0f9e76e214690e4dd38075004e903924f2b wpt-pr: 9888 wpt-commits: 7879f0f9e76e214690e4dd38075004e903924f2b wpt-pr: 9888
testing/web-platform/meta/MANIFEST.json
testing/web-platform/tests/client-hints/accept_ch.https.html
testing/web-platform/tests/client-hints/accept_ch.https.html.headers
testing/web-platform/tests/client-hints/echo_device_memory_header_received.py
--- a/testing/web-platform/meta/MANIFEST.json
+++ b/testing/web-platform/meta/MANIFEST.json
@@ -190527,16 +190527,26 @@
      {}
     ]
    ],
    "clear-site-data/support/test_utils.sub.js": [
     [
      {}
     ]
    ],
+   "client-hints/accept_ch.https.html.headers": [
+    [
+     {}
+    ]
+   ],
+   "client-hints/echo_device_memory_header_received.py": [
+    [
+     {}
+    ]
+   ],
    "clipboard-apis/OWNERS": [
     [
      {}
     ]
    ],
    "common/OWNERS": [
     [
      {}
@@ -308277,16 +308287,22 @@
     ]
    ],
    "clear-site-data/storage.https.html": [
     [
      "/clear-site-data/storage.https.html",
      {}
     ]
    ],
+   "client-hints/accept_ch.https.html": [
+    [
+     "/client-hints/accept_ch.https.html",
+     {}
+    ]
+   ],
    "clipboard-apis/async-interfaces.https.html": [
     [
      "/clipboard-apis/async-interfaces.https.html",
      {}
     ]
    ],
    "clipboard-apis/async-navigator-clipboard-basics.https.html": [
     [
@@ -401778,16 +401794,28 @@
   "clear-site-data/support/service_worker.js": [
    "eb87eb25d4b84ae78c57a7bd3cd3d43b4df99881",
    "support"
   ],
   "clear-site-data/support/test_utils.sub.js": [
    "10f5f9d409ef513edb129e0e8522aa5f74d51ce8",
    "support"
   ],
+  "client-hints/accept_ch.https.html": [
+   "b54ae9b17399e0fe4472fedbf1badd67d28e68f3",
+   "testharness"
+  ],
+  "client-hints/accept_ch.https.html.headers": [
+   "bf59baf9a030d117964df414efc11ddb07e7a7fa",
+   "support"
+  ],
+  "client-hints/echo_device_memory_header_received.py": [
+   "defa16c455bebc2589c058d0d888326d667e317a",
+   "support"
+  ],
   "clipboard-apis/OWNERS": [
    "bae753666bda85e9805a5e2fad80ba71459b8aba",
    "support"
   ],
   "clipboard-apis/async-interfaces.https.html": [
    "f0b8b999ac1a99d956fcfdd3ee52b4875d453974",
    "testharness"
   ],
new file mode 100644
--- /dev/null
+++ b/testing/web-platform/tests/client-hints/accept_ch.https.html
@@ -0,0 +1,30 @@
+<html>
+<body>
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+
+<script>
+
+// If the response for the HTML file contains "Accept-CH: device-memory" in
+// the response headers, then the browser should attach device-memory client
+// hint in the HTTP request headers. Test this functionality by fetching an
+// XHR from this page. The response headers for this page include
+// "Accept-CH: device-memory".
+//
+// echo_device_memory_header_received.py includes "device-memory-received" in
+// the response headers only if the request included "device-memory" in the
+// headers.
+
+  promise_test(t => {
+  return fetch("/client-hints/echo_device_memory_header_received.py").then(r => {
+    assert_equals(r.status, 200)
+    // Verify that the browser included "device-memory" in the headers when
+    // fetching the XHR.
+    assert_true(r.headers.has("device-memory-received"));
+  });
+}, "Accept-CH header test");
+
+</script>
+
+</body>
+</html>
new file mode 100644
--- /dev/null
+++ b/testing/web-platform/tests/client-hints/accept_ch.https.html.headers
@@ -0,0 +1,1 @@
+Accept-CH: device-memory
\ No newline at end of file
new file mode 100644
--- /dev/null
+++ b/testing/web-platform/tests/client-hints/echo_device_memory_header_received.py
@@ -0,0 +1,8 @@
+def main(request, response):
+    """
+    Simple handler that sets a response header based on if device-memory
+    request header was received or not.
+    """
+
+    if "device-memory" in request.headers:
+            response.headers.set("device-memory-received", "true")
\ No newline at end of file