Bug 1512347 [wpt PR 14383] - [eme] Check if encryption scheme is supported, a=testonly
authorJohn Rummell <jrummell@chromium.org>
Thu, 31 Jan 2019 19:00:21 +0000
changeset 458113 3a168bb7408f5e4a4e2e5104d18706c46355b2cf
parent 458112 72e9a9499acfde4258160e3875583ea6efa739d3
child 458114 1c48cb4373e5293453f7cfaa3d6d21c754ea0239
push id35518
push useropoprus@mozilla.com
push dateFri, 08 Feb 2019 09:55:14 +0000
treeherdermozilla-central@3a3e393396f4 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerstestonly
bugs1512347, 14383
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 1512347 [wpt PR 14383] - [eme] Check if encryption scheme is supported, a=testonly Automatic update from web-platform-tests [eme] Check if encryption scheme is supported (#14383) In [1] there is a proposal to add the ability for querying the encryption schemes supported by the CDM to MediaKeySystemConfiguration. Adding a test to check this. [1] https://github.com/WICG/encrypted-media-encryption-scheme/blob/master/explainer.md -- wpt-commits: 01e59d35144b76c85c48a6f2b742aee230194f79 wpt-pr: 14383
testing/web-platform/tests/encrypted-media/clearkey-check-encryption-scheme.https.html
testing/web-platform/tests/encrypted-media/drm-check-encryption-scheme.https.html
testing/web-platform/tests/encrypted-media/scripts/check-encryption-scheme.js
new file mode 100644
--- /dev/null
+++ b/testing/web-platform/tests/encrypted-media/clearkey-check-encryption-scheme.https.html
@@ -0,0 +1,32 @@
+<!doctype html>
+<html>
+  <head>
+    <meta charset=utf-8>
+    <title>Encrypted Media Extensions: Check encryptionScheme with Clear Key</title>
+    <link rel="help" href="https://w3c.github.io/encrypted-media/">
+
+    <!-- Web Platform Test Harness scripts -->
+    <script src=/resources/testharness.js></script>
+    <script src=/resources/testharnessreport.js></script>
+
+    <!-- Helper scripts for Encrypted Media Extensions tests  -->
+    <script src=/encrypted-media/util/utils.js></script>
+    <script src=/encrypted-media/util/utf8.js></script>
+
+    <!-- Content metadata -->
+    <!--<script src=/encrypted-media/content/content-metadata.js></script>-->
+
+    <!-- The script for this specific test -->
+    <script src=/encrypted-media/scripts/check-encryption-scheme.js></script>
+
+  </head>
+  <body>
+    <div id='log'></div>
+
+    <script>
+        var config = {  keysystem: 'org.w3.clearkey' }
+
+        runTest(config);
+    </script>
+  </body>
+</html>
new file mode 100644
--- /dev/null
+++ b/testing/web-platform/tests/encrypted-media/drm-check-encryption-scheme.https.html
@@ -0,0 +1,32 @@
+<!doctype html>
+<html>
+  <head>
+    <meta charset=utf-8>
+    <title>Encrypted Media Extensions: Check encryptionScheme with DRM</title>
+    <link rel="help" href="https://w3c.github.io/encrypted-media/">
+
+    <!-- Web Platform Test Harness scripts -->
+    <script src=/resources/testharness.js></script>
+    <script src=/resources/testharnessreport.js></script>
+
+    <!-- Helper scripts for Encrypted Media Extensions tests  -->
+    <script src=/encrypted-media/util/utils.js></script>
+    <script src=/encrypted-media/util/utf8.js></script>
+
+    <!-- Content metadata -->
+    <!--<script src=/encrypted-media/content/content-metadata.js></script>-->
+
+    <!-- The script for this specific test -->
+    <script src=/encrypted-media/scripts/check-encryption-scheme.js></script>
+
+  </head>
+  <body>
+    <div id='log'></div>
+
+    <script>
+        var config = {  keysystem: getSupportedKeySystem() }
+
+        runTest(config);
+    </script>
+  </body>
+</html>
new file mode 100644
--- /dev/null
+++ b/testing/web-platform/tests/encrypted-media/scripts/check-encryption-scheme.js
@@ -0,0 +1,41 @@
+function runTest(config, qualifier)
+{
+  function checkEncryptionScheme(encryptionScheme)
+  {
+    var simpleConfig = getSimpleConfiguration();
+    assert_greater_than(simpleConfig[0].audioCapabilities.length, 0);
+    simpleConfig[0].audioCapabilities.forEach(function(capability) {
+      capability.encryptionScheme = encryptionScheme;
+    });
+
+    return navigator.requestMediaKeySystemAccess(config.keysystem, simpleConfig)
+        .then(
+            function(access) {
+              var actualConfiguration = access.getConfiguration();
+              for (let i = 0; i < actualConfiguration.audioCapabilities.length; i++) {
+                const capability = actualConfiguration.audioCapabilities[i];
+
+                // If "encryptionScheme" is not supported, fail.
+                if (!('encryptionScheme' in capability)) {
+                  return Promise.reject('Not implemented');
+                }
+
+                // If "encryptionScheme" is supported, it should be returned.
+                assert_equals(capability.encryptionScheme, encryptionScheme);
+              }
+              return Promise.resolve('Supported');
+            },
+            function error() {
+              // CDM does not support "encryptionScheme". Test should still pass.
+              return Promise.resolve('Not supported');
+            });
+  }
+
+  promise_test(
+      () => checkEncryptionScheme('cenc'),
+      testnamePrefix(qualifier, config.keysystem) + ' support for "cenc" encryption scheme.');
+
+  promise_test(
+      () => checkEncryptionScheme('cbcs'),
+      testnamePrefix(qualifier, config.keysystem) + ' support for "cbcs" encryption scheme.');
+}