diff --git a/core/tests/Drupal/Tests/Core/Cache/Context/HeadersCacheContextTest.php b/core/tests/Drupal/Tests/Core/Cache/Context/HeadersCacheContextTest.php
new file mode 100644
index 0000000..a457695
--- /dev/null
+++ b/core/tests/Drupal/Tests/Core/Cache/Context/HeadersCacheContextTest.php
@@ -0,0 +1,49 @@
+<?php
+
+namespace Drupal\Tests\Core\Cache\Context;
+
+use Drupal\Core\Cache\Context\HeadersCacheContext;
+use Drupal\Tests\UnitTestCase;
+use Symfony\Component\HttpFoundation\Request;
+use Symfony\Component\HttpFoundation\RequestStack;
+
+/**
+ * @coversDefaultClass \Drupal\Core\Cache\Context\HeadersCacheContext
+ * @group Cache
+ */
+class HeadersCacheContextTest extends UnitTestCase {
+
+  /**
+   * @covers ::getContext
+   *
+   * @dataProvider providerTestGetContext
+   */
+  public function testGetContext($header_name, $header_value, $context) {
+    $request_stack = new RequestStack();
+    $request = Request::create('/', 'GET');
+    if ($header_name) {
+      $request->headers->set($header_name, $header_value);
+    }
+    $request_stack->push($request);
+    $cache_context = new HeadersCacheContext($request_stack);
+    if (!$header_name) {
+      // Request defaults could change, so compare with default values instead
+      // of passed in context value.
+      $context = $request->headers->all();
+    }
+    $this->assertSame($cache_context->getContext($header_name), $context);
+  }
+
+  /**
+   * Provides a list of headers and expected cache contexts.
+   */
+  public function providerTestGetContext() {
+    return [
+      [NULL, NULL, NULL],
+      ['x-custom-header', NULL, NULL],
+      ['x-custom-header', '123', '123'],
+      ['x-custom-header', ['123'], '123'],
+    ];
+  }
+
+}
