Implement MediaCapabilities: HDR decoding query

This CL allows for HDR to be queried with MediaCapabilities.decodingInfo
with hdrMetadataType, colorGamut, and transferFunction. Both Blink- and
Media-side changes are included. The feature is flagged by
MediaCapabilitiesDynamicRange.

Bug: 1048045
Change-Id: I9f144726bbc7aaead4dcc1c9f69cf536da1bf2a9
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2035053
Commit-Queue: Vi Nguyen <ving@microsoft.com>
Reviewed-by: Yuchen Liu <yucliu@chromium.org>
Reviewed-by: Dave Tapuska <dtapuska@chromium.org>
Reviewed-by: Mounir Lamouri <mlamouri@chromium.org>
Reviewed-by: Chrome Cunningham <chcunningham@chromium.org>
Cr-Commit-Position: refs/heads/master@{#756829}
diff --git a/media-capabilities/decodingInfo.any.js b/media-capabilities/decodingInfo.any.js
index 2d74d30..772d47e 100644
--- a/media-capabilities/decodingInfo.any.js
+++ b/media-capabilities/decodingInfo.any.js
@@ -23,6 +23,19 @@
   spatialRendering: true,
 };
 
+// VideoConfiguration with optional hdrMetadataType, colorGamut, and
+// transferFunction properties.
+var videoConfigurationWithDynamicRange = {
+  contentType: 'video/webm; codecs="vp09.00.10.08"',
+  width: 800,
+  height: 600,
+  bitrate: 3000,
+  framerate: 24,
+  hdrMetadataType: "smpteSt2086",
+  colorGamut: "srgb",
+  transferFunction: "srgb",
+}
+
 promise_test(t => {
   return promise_rejects_js(t, TypeError, navigator.mediaCapabilities.decodingInfo());
 }, "Test that decodingInfo rejects if it doesn't get a configuration");
@@ -314,3 +327,57 @@
     assert_equals(typeof ability.keySystemAccess, "object");
   });
 }, "Test that decodingInfo with spatialRendering set returns a valid MediaCapabilitiesInfo objects");
+
+promise_test(t => {
+  return navigator.mediaCapabilities.decodingInfo({
+    type: 'file',
+    video: videoConfigurationWithDynamicRange,
+  }).then(ability => {
+    assert_equals(typeof ability.supported, "boolean");
+    assert_equals(typeof ability.smooth, "boolean");
+    assert_equals(typeof ability.powerEfficient, "boolean");
+    assert_equals(typeof ability.keySystemAccess, "object");
+  });
+}, "Test that decodingInfo with hdrMetadataType, colorGamut, and transferFunction set returns a valid MediaCapabilitiesInfo objects");
+
+promise_test(t => {
+  return promise_rejects_js(t, TypeError, navigator.mediaCapabilities.decodingInfo({
+    type: 'file',
+    video: {
+      contentType: 'video/webm; codecs="vp09.00.10.08"',
+      width: 800,
+      height: 600,
+      bitrate: 3000,
+      framerate: 24,
+      hdrMetadataType: ""
+    },
+  }));
+}, "Test that decodingInfo rejects if the video configuration has an empty hdrMetadataType");
+
+promise_test(t => {
+  return promise_rejects_js(t, TypeError, navigator.mediaCapabilities.decodingInfo({
+    type: 'file',
+    video: {
+      contentType: 'video/webm; codecs="vp09.00.10.08"',
+      width: 800,
+      height: 600,
+      bitrate: 3000,
+      framerate: 24,
+      colorGamut: true
+    },
+  }));
+}, "Test that decodingInfo rejects if the video configuration has a colorGamut set to true");
+
+promise_test(t => {
+  return promise_rejects_js(t, TypeError, navigator.mediaCapabilities.decodingInfo({
+    type: 'file',
+    video: {
+      contentType: 'video/webm; codecs="vp09.00.10.08"',
+      width: 800,
+      height: 600,
+      bitrate: 3000,
+      framerate: 24,
+      transferFunction: 3
+    },
+  }));
+}, "Test that decodingInfo rejects if the video configuration has a transferFunction set to 3");