Skip to content

Truly independent web browser

Tests: Import Encrypted Media Extensions WPT tests

Shannon Booth6604127f5cd3
diff --git a/Tests/LibWeb/TestConfig.ini b/Tests/LibWeb/TestConfig.ini
index 84c4b52d8ca..db7f13ac58c 100644
--- a/Tests/LibWeb/TestConfig.ini
+++ b/Tests/LibWeb/TestConfig.ini
@@ -1311,6 +1311,7 @@ Text/input/SiteIsolation/iframe/beforeunload-consulted-in-remote-iframe-on-back.
Text/input/shared-worker-is-not-shared-across-top-level-sites.html
Text/input/wpt-import/cookies/samesite/
Text/input/wpt-import/cookiestore/
+Text/input/wpt-import/encrypted-media/
[CapFrameRate]
; Ends a smooth scroll once 20 frames see no change, which frames faster than the compositor's ticks do
diff --git a/Tests/LibWeb/Text/expected/wpt-import/encrypted-media/clearkey-check-encryption-scheme.https.txt b/Tests/LibWeb/Text/expected/wpt-import/encrypted-media/clearkey-check-encryption-scheme.https.txt
new file mode 100644
index 00000000000..40a03a6fc0e
--- /dev/null
+++ b/Tests/LibWeb/Text/expected/wpt-import/encrypted-media/clearkey-check-encryption-scheme.https.txt
@@ -0,0 +1,8 @@
+Harness status: OK
+
+Found 3 tests
+
+3 Pass
+Pass org.w3.clearkey support for "cenc" encryption scheme.
+Pass org.w3.clearkey support for "cbcs" encryption scheme.
+Pass org.w3.clearkey support for "cbcs-1-9" encryption scheme.
\ No newline at end of file
diff --git a/Tests/LibWeb/Text/expected/wpt-import/encrypted-media/clearkey-check-initdata-type.https.txt b/Tests/LibWeb/Text/expected/wpt-import/encrypted-media/clearkey-check-initdata-type.https.txt
new file mode 100644
index 00000000000..cca5e1bcb68
--- /dev/null
+++ b/Tests/LibWeb/Text/expected/wpt-import/encrypted-media/clearkey-check-initdata-type.https.txt
@@ -0,0 +1,8 @@
+Harness status: OK
+
+Found 3 tests
+
+3 Pass
+Pass org.w3.clearkey support for "webm".
+Pass org.w3.clearkey support for "cenc".
+Pass org.w3.clearkey support for "keyids".
\ No newline at end of file
diff --git a/Tests/LibWeb/Text/expected/wpt-import/encrypted-media/clearkey-mp4-requestmediakeysystemaccess.https.txt b/Tests/LibWeb/Text/expected/wpt-import/encrypted-media/clearkey-mp4-requestmediakeysystemaccess.https.txt
new file mode 100644
index 00000000000..762dc1ae5d6
--- /dev/null
+++ b/Tests/LibWeb/Text/expected/wpt-import/encrypted-media/clearkey-mp4-requestmediakeysystemaccess.https.txt
@@ -0,0 +1,64 @@
+Harness status: OK
+
+Found 58 tests
+
+42 Pass
+16 Fail
+Pass org.w3.clearkey, requestMediaKeySystemAccess: Empty Key System should result in TypeError
+Pass org.w3.clearkey, requestMediaKeySystemAccess: Unsupported Key System should result in NotSupportedError
+Pass org.w3.clearkey, requestMediaKeySystemAccess: Key System ending in "." should result in NotSupportedError
+Pass org.w3.clearkey, requestMediaKeySystemAccess: Capitalized Key System should result in NotSupportedError
+Pass org.w3.clearkey, requestMediaKeySystemAccess: Non-ASCII Key System should result in NotSupportedError
+Pass org.w3.clearkey, requestMediaKeySystemAccess: Root domain of Key System alone should result in NotSupportedError
+Pass org.w3.clearkey, requestMediaKeySystemAccess: Root domain of Key System, with dot should result in NotSupportedError
+Pass org.w3.clearkey, requestMediaKeySystemAccess: Domain of Key System along should result in NotSupportedError
+Pass org.w3.clearkey, requestMediaKeySystemAccess: Domain of Key System, with dot should result in NotSupportedError
+Pass org.w3.clearkey, requestMediaKeySystemAccess: Child of Key System should result in NotSupportedError
+Pass org.w3.clearkey, requestMediaKeySystemAccess: Prefixed Key System should result in NotSupportedError
+Pass org.w3.clearkey, requestMediaKeySystemAccess: Missing characters in middle of Key System name should result in NotSupportedError
+Pass org.w3.clearkey, requestMediaKeySystemAccess: Missing characters at end of Key System name should result in NotSupportedError
+Pass org.w3.clearkey, requestMediaKeySystemAccess: Leading space in Key System name should result in NotSupportedError
+Pass org.w3.clearkey, requestMediaKeySystemAccess: Extra space in Key System name should result in NotSupportedError
+Pass org.w3.clearkey, requestMediaKeySystemAccess: Trailing space in Key System name should result in NotSupportedError
+Pass org.w3.clearkey, requestMediaKeySystemAccess: Leading dot in Key System name should result in NotSupportedError
+Pass org.w3.clearkey, requestMediaKeySystemAccess: Extra dot in middle of Key System name should result in NotSupportedError
+Pass org.w3.clearkey, requestMediaKeySystemAccess: Trailing dot in Key System name should result in NotSupportedError
+Pass org.w3.clearkey, requestMediaKeySystemAccess: Key System name is case sensitive should result in NotSupportedError
+Pass org.w3.clearkey, requestMediaKeySystemAccess: Empty supportedConfigurations should result in TypeError
+Pass org.w3.clearkey, requestMediaKeySystemAccess: Empty configuration should result in NotSupportedError
+Pass Basic supported configuration
+Pass Partially supported configuration
+Pass Supported audio codec
+Pass ContentType formatting must be preserved
+Fail org.w3.clearkey, requestMediaKeySystemAccess: Unsupported audio codec ('audio/webm; codecs=fake') should result in NotSupportedError
+Fail org.w3.clearkey, requestMediaKeySystemAccess: Unsupported video codec () should result in NotSupportedError
+Fail org.w3.clearkey, requestMediaKeySystemAccess: Mismatched audio container/codec ('audio/webm; codecs=mp4a','audio/webm; codecs=mp4a.40.2') should result in NotSupportedError
+Fail org.w3.clearkey, requestMediaKeySystemAccess: Video codec specified in audio field ('video/mp4;codecs="avc1.4d401e"') should result in NotSupportedError
+Fail org.w3.clearkey, requestMediaKeySystemAccess: Audio codec specified in video field ('audio/mp4;codecs="mp4a.40.2"') should result in NotSupportedError
+Fail org.w3.clearkey, requestMediaKeySystemAccess: Mismatched audio container/codec ('audio/webm; codecs=avc1','audio/webm; codecs=avc1.42e01e') should result in NotSupportedError
+Fail org.w3.clearkey, requestMediaKeySystemAccess: Mismatched audio container/codec ('audio/mp4; codecs=vorbis') should result in NotSupportedError
+Pass Two configurations, one supported
+Pass Two configurations, both supported
+Fail org.w3.clearkey, requestMediaKeySystemAccess: Audio MIME type does not support video codecs (webm) ('audio/webm; codecs="vp8,vorbis"','audio/webm; codecs="vorbis, vp8"','audio/webm; codecs="vp8"') should result in NotSupportedError
+Fail org.w3.clearkey, requestMediaKeySystemAccess: Audio MIME type does not support video codecs (mp4) ('audio/mp4; codecs="avc1"','audio/mp4; codecs="avc1.4d401e"') should result in NotSupportedError
+Fail org.w3.clearkey, requestMediaKeySystemAccess: Video MIME type does not support audio codecs (webm) ('video/webm; codecs="vp8,vorbis"','video/webm; codecs="vorbis, vp8"','video/webm; codecs="vorbis"') should result in NotSupportedError
+Fail org.w3.clearkey, requestMediaKeySystemAccess: Video MIME type does not support audio codecs (mp4) ('video/mp4; codecs="mp4a"','video/mp4; codecs="mp4a.40.2"') should result in NotSupportedError
+Fail org.w3.clearkey, requestMediaKeySystemAccess: WebM audio does not support AVC1/AAC ('audio/webm; codecs="aac"','audio/webm; codecs="avc1"','audio/webm; codecs="vp8,aac"') should result in NotSupportedError
+Fail org.w3.clearkey, requestMediaKeySystemAccess: WebM video does not support AVC1/AAC ('video/webm; codecs="aac"','video/webm; codecs="avc1"','video/webm; codecs="vp8,aac"') should result in NotSupportedError
+Pass Leading space in contentType
+Pass Space before ; in contentType
+Pass Trailing space in contentType
+Pass Space at start of codecs parameter
+Pass Space at end of codecs parameter
+Pass Video/
+Pass Codecs=
+Pass Upper case MIME type
+Pass CODECS=
+Pass org.w3.clearkey, requestMediaKeySystemAccess: Unrecognized foo with webm ('video/webm; foo="bar"') should result in NotSupportedError
+Pass org.w3.clearkey, requestMediaKeySystemAccess: Unrecognized foo with mp4 ('video/mp4; foo="bar"') should result in NotSupportedError
+Fail org.w3.clearkey, requestMediaKeySystemAccess: Unrecognized foo with codecs ('video/mp4;codecs="avc1.4d401e"; foo="bar"') should result in NotSupportedError
+Pass org.w3.clearkey, requestMediaKeySystemAccess: contentType: 'fake' should result in NotSupportedError
+Pass org.w3.clearkey, requestMediaKeySystemAccess: contentType: 'audio/fake' should result in NotSupportedError
+Pass org.w3.clearkey, requestMediaKeySystemAccess: contentType: 'video/fake' should result in NotSupportedError
+Fail org.w3.clearkey, requestMediaKeySystemAccess: contentType: 'video/mp4;codecs="AVC1.4D401E"' should result in NotSupportedError
+Fail org.w3.clearkey, requestMediaKeySystemAccess: contentType: 'video/mp4;codecs=",avc1.4d401e"' should result in NotSupportedError
\ No newline at end of file
diff --git a/Tests/LibWeb/Text/input/wpt-import/encrypted-media/clearkey-check-encryption-scheme.https.html b/Tests/LibWeb/Text/input/wpt-import/encrypted-media/clearkey-check-encryption-scheme.https.html
new file mode 100644
index 00000000000..442ca82d162
--- /dev/null
+++ b/Tests/LibWeb/Text/input/wpt-import/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>
diff --git a/Tests/LibWeb/Text/input/wpt-import/encrypted-media/clearkey-check-initdata-type.https.html b/Tests/LibWeb/Text/input/wpt-import/encrypted-media/clearkey-check-initdata-type.https.html
new file mode 100644
index 00000000000..62415238e67
--- /dev/null
+++ b/Tests/LibWeb/Text/input/wpt-import/encrypted-media/clearkey-check-initdata-type.https.html
@@ -0,0 +1,32 @@
+<!doctype html>
+<html>
+ <head>
+ <meta charset=utf-8>
+ <title>Encrypted Media Extensions: Successful Playback, Temporary session with Clear Key, mp4</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-initdata-type.js></script>
+
+ </head>
+ <body>
+ <div id='log'></div>
+
+ <script>
+ var config = { keysystem: 'org.w3.clearkey' }
+
+ runTest(config);
+ </script>
+ </body>
+</html>
diff --git a/Tests/LibWeb/Text/input/wpt-import/encrypted-media/clearkey-mp4-requestmediakeysystemaccess.https.html b/Tests/LibWeb/Text/input/wpt-import/encrypted-media/clearkey-mp4-requestmediakeysystemaccess.https.html
new file mode 100644
index 00000000000..b4536c62b0d
--- /dev/null
+++ b/Tests/LibWeb/Text/input/wpt-import/encrypted-media/clearkey-mp4-requestmediakeysystemaccess.https.html
@@ -0,0 +1,39 @@
+<!doctype html>
+<html>
+ <head>
+ <meta charset=utf-8>
+ <meta name="timeout" content="long">
+ <title>Encrypted Media Extensions: requestMediaKeySystemAccess tests, 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/testmediasource.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/requestmediakeysystemaccess.js></script>
+
+ </head>
+ <body>
+ <div id='log'></div>
+
+ <script>
+ var contentitem = content['mp4-basic'],
+ config = { keysystem: 'org.w3.clearkey',
+ audioType: contentitem.audio.type,
+ videoType: contentitem.video.type,
+ initDataType: 'keyids'
+ };
+
+ runTest(config);
+ </script>
+ </body>
+</html>
diff --git a/Tests/LibWeb/Text/input/wpt-import/encrypted-media/content/content-metadata.js b/Tests/LibWeb/Text/input/wpt-import/encrypted-media/content/content-metadata.js
new file mode 100644
index 00000000000..0ee7b65f01b
--- /dev/null
+++ b/Tests/LibWeb/Text/input/wpt-import/encrypted-media/content/content-metadata.js
@@ -0,0 +1,281 @@
+content = addMemberListToObject( {
+
+ 'mp4-clear' : { initDataType: 'cenc',
+ audio : { type: 'audio/mp4;codecs="mp4a.40.2"',
+ path: '/encrypted-media/content/audio_aac-lc_128k_dashinit.mp4' },
+ video : { type: 'video/mp4;codecs="avc1.4d401e"',
+ path: '/encrypted-media/content/video_512x288_h264-360k_clear_dashinit.mp4' }
+ },
+
+ 'mp4-basic' : { assetId: 'mp4-basic',
+ initDataType: 'cenc',
+ audio : { type: 'audio/mp4;codecs="mp4a.40.2"',
+ path: '/encrypted-media/content/audio_aac-lc_128k_dashinit.mp4' },
+ video : { type: 'video/mp4;codecs="avc1.4d401e"',
+ path: '/encrypted-media/content/video_512x288_h264-360k_enc_dashinit.mp4' },
+ keys : [ { kid: [ 0xad, 0x13, 0xf9, 0xea, 0x2b, 0xe6, 0x98, 0xb8, 0x75, 0xf5, 0x04, 0xa8, 0xe3, 0xcc, 0xea, 0x64 ],
+ key: [ 0xbe, 0x7d, 0xf8, 0xa3, 0x66, 0x7a, 0x6a, 0x8f, 0xd5, 0x64, 0xd0, 0xed, 0x81, 0x33, 0x9a, 0x95 ],
+ initDataType: 'cenc',
+ initData: 'AAAAcXBzc2gAAAAA7e+LqXnWSs6jyCfc1R0h7QAAAFEIARIQrRP56ivmmLh19QSo48zqZBoIY2FzdGxhYnMiKGV5SmhjM05sZEVsa0lqb2laVzFsTFhSbGMzUXRjMmx1WjJ4bEluMD0yB2RlZmF1bHQAAAMacHNzaAAAAACaBPB5mEBChquS5lvgiF+VAAAC+voCAAABAAEA8AI8AFcAUgBNAEgARQBBAEQARQBSACAAeABtAGwAbgBzAD0AIgBoAHQAdABwADoALwAvAHMAYwBoAGUAbQBhAHMALgBtAGkAYwByAG8AcwBvAGYAdAAuAGMAbwBtAC8ARABSAE0ALwAyADAAMAA3AC8AMAAzAC8AUABsAGEAeQBSAGUAYQBkAHkASABlAGEAZABlAHIAIgAgAHYAZQByAHMAaQBvAG4APQAiADQALgAwAC4AMAAuADAAIgA+ADwARABBAFQAQQA+ADwAUABSAE8AVABFAEMAVABJAE4ARgBPAD4APABLAEUAWQBMAEUATgA+ADEANgA8AC8ASwBFAFkATABFAE4APgA8AEEATABHAEkARAA+AEEARQBTAEMAVABSADwALwBBAEwARwBJAEQAPgA8AC8AUABSAE8AVABFAEMAVABJAE4ARgBPAD4APABLAEkARAA+ADYAdgBrAFQAcgBlAFkAcgB1AEoAaAAxADkAUQBTAG8ANAA4AHoAcQBaAEEAPQA9ADwALwBLAEkARAA+ADwAQwBIAEUAQwBLAFMAVQBNAD4AagBZAEYATgBmADAAeQBmADQAaQBzAD0APAAvAEMASABFAEMASwBTAFUATQA+ADwATABBAF8AVQBSAEwAPgBoAHQAdABwADoALwAvAHAAbABhAHkAcgBlAGEAZAB5AC4AZABpAHIAZQBjAHQAdABhAHAAcwAuAG4AZQB0AC8AcAByAC8AcwB2AGMALwByAGkAZwBoAHQAcwBtAGEAbgBhAGcAZQByAC4AYQBzAG0AeAA/AFAAbABhAHkAUgBpAGcAaAB0AD0AMQAmAGEAbQBwADsAVQBzAGUAUwBpAG0AcABsAGUATgBvAG4AUABlAHIAcwBpAHMAdABlAG4AdABMAGkAYwBlAG4AcwBlAD0AMQA8AC8ATABBAF8AVQBSAEwAPgA8AC8ARABBAFQAQQA+ADwALwBXAFIATQBIAEUAQQBEAEUAUgA+AA==' } ]
+ },
+
+ 'mp4-clear-encrypted' : {
+ assetId: 'mp4-basic',
+ initDataType: 'cenc',
+ audio : { type: 'audio/mp4;codecs="mp4a.40.2"',
+ path: '/encrypted-media/content/audio_aac-lc_128k_dashinit.mp4' },
+ video : { type: 'video/mp4;codecs="avc1.4d401e"',
+ path: '/encrypted-media/content/video_512x288_h264-360k_clear_enc_dashinit.mp4' },
+ keys : [ { kid: [ 0xad, 0x13, 0xf9, 0xea, 0x2b, 0xe6, 0x98, 0xb8, 0x75, 0xf5, 0x04, 0xa8, 0xe3, 0xcc, 0xea, 0x64 ],
+ key: [ 0xbe, 0x7d, 0xf8, 0xa3, 0x66, 0x7a, 0x6a, 0x8f, 0xd5, 0x64, 0xd0, 0xed, 0x81, 0x33, 0x9a, 0x95 ],
+ initDataType: 'cenc',
+ initData: 'AAAAcXBzc2gAAAAA7e+LqXnWSs6jyCfc1R0h7QAAAFEIARIQrRP56ivmmLh19QSo48zqZBoIY2FzdGxhYnMiKGV5SmhjM05sZEVsa0lqb2laVzFsTFhSbGMzUXRjMmx1WjJ4bEluMD0yB2RlZmF1bHQAAAMacHNzaAAAAACaBPB5mEBChquS5lvgiF+VAAAC+voCAAABAAEA8AI8AFcAUgBNAEgARQBBAEQARQBSACAAeABtAGwAbgBzAD0AIgBoAHQAdABwADoALwAvAHMAYwBoAGUAbQBhAHMALgBtAGkAYwByAG8AcwBvAGYAdAAuAGMAbwBtAC8ARABSAE0ALwAyADAAMAA3AC8AMAAzAC8AUABsAGEAeQBSAGUAYQBkAHkASABlAGEAZABlAHIAIgAgAHYAZQByAHMAaQBvAG4APQAiADQALgAwAC4AMAAuADAAIgA+ADwARABBAFQAQQA+ADwAUABSAE8AVABFAEMAVABJAE4ARgBPAD4APABLAEUAWQBMAEUATgA+ADEANgA8AC8ASwBFAFkATABFAE4APgA8AEEATABHAEkARAA+AEEARQBTAEMAVABSADwALwBBAEwARwBJAEQAPgA8AC8AUABSAE8AVABFAEMAVABJAE4ARgBPAD4APABLAEkARAA+ADYAdgBrAFQAcgBlAFkAcgB1AEoAaAAxADkAUQBTAG8ANAA4AHoAcQBaAEEAPQA9ADwALwBLAEkARAA+ADwAQwBIAEUAQwBLAFMAVQBNAD4AagBZAEYATgBmADAAeQBmADQAaQBzAD0APAAvAEMASABFAEMASwBTAFUATQA+ADwATABBAF8AVQBSAEwAPgBoAHQAdABwADoALwAvAHAAbABhAHkAcgBlAGEAZAB5AC4AZABpAHIAZQBjAHQAdABhAHAAcwAuAG4AZQB0AC8AcAByAC8AcwB2AGMALwByAGkAZwBoAHQAcwBtAGEAbgBhAGcAZQByAC4AYQBzAG0AeAA/AFAAbABhAHkAUgBpAGcAaAB0AD0AMQAmAGEAbQBwADsAVQBzAGUAUwBpAG0AcABsAGUATgBvAG4AUABlAHIAcwBpAHMAdABlAG4AdABMAGkAYwBlAG4AcwBlAD0AMQA8AC8ATABBAF8AVQBSAEwAPgA8AC8ARABBAFQAQQA+ADwALwBXAFIATQBIAEUAQQBEAEUAUgA+AA==' } ]
+ },
+
+ 'mp4-encrypted-clear' : {
+ assetId: 'mp4-basic',
+ initDataType: 'cenc',
+ audio : { type: 'audio/mp4;codecs="mp4a.40.2"',
+ path: '/encrypted-media/content/audio_aac-lc_128k_dashinit.mp4' },
+ video : { type: 'video/mp4;codecs="avc1.4d401e"',
+ path: '/encrypted-media/content/video_512x288_h264-360k_enc_clear_dashinit.mp4' },
+ keys : [ { kid: [ 0xad, 0x13, 0xf9, 0xea, 0x2b, 0xe6, 0x98, 0xb8, 0x75, 0xf5, 0x04, 0xa8, 0xe3, 0xcc, 0xea, 0x64 ],
+ key: [ 0xbe, 0x7d, 0xf8, 0xa3, 0x66, 0x7a, 0x6a, 0x8f, 0xd5, 0x64, 0xd0, 0xed, 0x81, 0x33, 0x9a, 0x95 ],
+ initDataType: 'cenc',
+ initData: 'AAAAcXBzc2gAAAAA7e+LqXnWSs6jyCfc1R0h7QAAAFEIARIQrRP56ivmmLh19QSo48zqZBoIY2FzdGxhYnMiKGV5SmhjM05sZEVsa0lqb2laVzFsTFhSbGMzUXRjMmx1WjJ4bEluMD0yB2RlZmF1bHQAAAMacHNzaAAAAACaBPB5mEBChquS5lvgiF+VAAAC+voCAAABAAEA8AI8AFcAUgBNAEgARQBBAEQARQBSACAAeABtAGwAbgBzAD0AIgBoAHQAdABwADoALwAvAHMAYwBoAGUAbQBhAHMALgBtAGkAYwByAG8AcwBvAGYAdAAuAGMAbwBtAC8ARABSAE0ALwAyADAAMAA3AC8AMAAzAC8AUABsAGEAeQBSAGUAYQBkAHkASABlAGEAZABlAHIAIgAgAHYAZQByAHMAaQBvAG4APQAiADQALgAwAC4AMAAuADAAIgA+ADwARABBAFQAQQA+ADwAUABSAE8AVABFAEMAVABJAE4ARgBPAD4APABLAEUAWQBMAEUATgA+ADEANgA8AC8ASwBFAFkATABFAE4APgA8AEEATABHAEkARAA+AEEARQBTAEMAVABSADwALwBBAEwARwBJAEQAPgA8AC8AUABSAE8AVABFAEMAVABJAE4ARgBPAD4APABLAEkARAA+ADYAdgBrAFQAcgBlAFkAcgB1AEoAaAAxADkAUQBTAG8ANAA4AHoAcQBaAEEAPQA9ADwALwBLAEkARAA+ADwAQwBIAEUAQwBLAFMAVQBNAD4AagBZAEYATgBmADAAeQBmADQAaQBzAD0APAAvAEMASABFAEMASwBTAFUATQA+ADwATABBAF8AVQBSAEwAPgBoAHQAdABwADoALwAvAHAAbABhAHkAcgBlAGEAZAB5AC4AZABpAHIAZQBjAHQAdABhAHAAcwAuAG4AZQB0AC8AcAByAC8AcwB2AGMALwByAGkAZwBoAHQAcwBtAGEAbgBhAGcAZQByAC4AYQBzAG0AeAA/AFAAbABhAHkAUgBpAGcAaAB0AD0AMQAmAGEAbQBwADsAVQBzAGUAUwBpAG0AcABsAGUATgBvAG4AUABlAHIAcwBpAHMAdABlAG4AdABMAGkAYwBlAG4AcwBlAD0AMQA8AC8ATABBAF8AVQBSAEwAPgA8AC8ARABBAFQAQQA+ADwALwBXAFIATQBIAEUAQQBEAEUAUgA+AA==' } ]
+ },
+
+
+ 'mp4-av-multikey' : {
+ assetId: 'mp4-basic',
+ initDataType: 'cenc',
+ associatedInitData: true, // indicates that initData for one key causes other keys to be returned as well
+ audio: { type: 'audio/mp4;codecs="mp4a.40.2"',
+ path: '/encrypted-media/content/audio_aac-lc_128k_enc_dashinit.mp4',
+ sinfStart: 0x02aa,
+ saizStarts: [0x081b, 0x9065, 0x1150a],
+ saioStarts: [0x0802, 0x906e, 0x11523],
+ sencStarts: [0x9c3, 0x9226] },
+ video : { type: 'video/mp4;codecs="avc1.4d401e"',
+ path: '/encrypted-media/content/video_512x288_h264-360k_enc_dashinit.mp4',
+ saizStarts: [0x840, 0x18031, 0x2ebad],
+ saioStarts: [0x889, 0x1804a, 0x2ebc6],
+ sencStarts: [0x2ec62] },
+ keys : [ { kid: [ 0xad, 0x13, 0xf9, 0xea, 0x2b, 0xe6, 0x98, 0xb8, 0x75, 0xf5, 0x04, 0xa8, 0xe3, 0xcc, 0xea, 0x64 ],
+ key: [ 0xbe, 0x7d, 0xf8, 0xa3, 0x66, 0x7a, 0x6a, 0x8f, 0xd5, 0x64, 0xd0, 0xed, 0x81, 0x33, 0x9a, 0x95 ],
+ initDataType: 'cenc',
+ initData: 'AAAAcXBzc2gAAAAA7e+LqXnWSs6jyCfc1R0h7QAAAFEIARIQrRP56ivmmLh19QSo48zqZBoIY2FzdGxhYnMiKGV5SmhjM05sZEVsa0lqb2laVzFsTFhSbGMzUXRjMmx1WjJ4bEluMD0yB2RlZmF1bHQAAAMacHNzaAAAAACaBPB5mEBChquS5lvgiF+VAAAC+voCAAABAAEA8AI8AFcAUgBNAEgARQBBAEQARQBSACAAeABtAGwAbgBzAD0AIgBoAHQAdABwADoALwAvAHMAYwBoAGUAbQBhAHMALgBtAGkAYwByAG8AcwBvAGYAdAAuAGMAbwBtAC8ARABSAE0ALwAyADAAMAA3AC8AMAAzAC8AUABsAGEAeQBSAGUAYQBkAHkASABlAGEAZABlAHIAIgAgAHYAZQByAHMAaQBvAG4APQAiADQALgAwAC4AMAAuADAAIgA+ADwARABBAFQAQQA+ADwAUABSAE8AVABFAEMAVABJAE4ARgBPAD4APABLAEUAWQBMAEUATgA+ADEANgA8AC8ASwBFAFkATABFA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I8AFcAUgBNAEgARQBBAEQARQBSACAAeABtAGwAbgBzAD0AIgBoAHQAdABwADoALwAvAHMAYwBoAGUAbQBhAHMALgBtAGkAYwByAG8AcwBvAGYAdAAuAGMAbwBtAC8ARABSAE0ALwAyADAAMAA3AC8AMAAzAC8AUABsAGEAeQBSAGUAYQBkAHkASABlAGEAZABlAHIAIgAgAHYAZQByAHMAaQBvAG4APQAiADQALgAwAC4AMAAuADAAIgA+ADwARABBAFQAQQA+ADwAUABSAE8AVABFAEMAVABJAE4ARgBPAD4APABLAEUAWQBMAEUATgA+ADEANgA8AC8ASwBFAFkATABFAE4APgA8AEEATABHAEkARAA+AEEARQBTAEMAVABSADwALwBBAEwARwBJAEQAPgA8AC8AUABSAE8AVABFAEMAVABJAE4ARgBPAD4APABLAEkARAA+AFEAZQBXAE8AVgBRAHEANQA4ADcASwBWAEQAUQBDAHQANAAzAFkATgBSAFEAPQA9ADwALwBLAEkARAA+ADwAQwBIAEUAQwBLAFMAVQBNAD4AWQBpAE8ALwAxADYATABzADkANgBFAD0APAAvAEMASABFAEMASwBTAFUATQA+ADwATABBAF8AVQBSAEwAPgBoAHQAdABwADoALwAvAHAAbABhAHkAcgBlAGEAZAB5AC4AZABpAHIAZQBjAHQAdABhAHAAcwAuAG4AZQB0AC8AcAByAC8AcwB2AGMALwByAGkAZwBoAHQAcwBtAGEAbgBhAGcAZQByAC4AYQBzAG0AeAA/AFAAbABhAHkAUgBpAGcAaAB0AD0AMQAmAGEAbQBwADsAVQBzAGUAUwBpAG0AcABsAGUATgBvAG4AUABlAHIAcwBpAHMAdABlAG4AdABMAGkAYwBlAG4AcwBlAD0AMQA8AC8ATABBAF8AVQBSAEwAPgA8AC8ARABBAFQAQQA+ADwALwBXAFIATQBIAEUAQQBEAEUAUgA+AA==' } ]
+ },
+
+ 'mp4-multikey' : { assetId: 'mp4-multikey',
+ initDataType: 'cenc',
+ audio: { type: 'audio/mp4;codecs="mp4a.40.2"',
+ path: '/encrypted-media/content/audio_aac-lc_128k_2keys_2sess.mp4' },
+ video: { type: 'video/mp4;codecs="avc1.4d401e"',
+ path: '/encrypted-media/content/video_512x288_h264-360k_enc_2keys_2sess.mp4' },
+ keys: [ { kid: [ 0x13, 0xa7, 0x53, 0x06, 0xd1, 0x18, 0x91, 0x7b, 0x47, 0xa6, 0xc1, 0x83, 0x64, 0x42, 0x51, 0x6f ],
+ key: [ 0x8a, 0xaa, 0xd8, 0xc4, 0xdb, 0xde, 0xac, 0xcd, 0xad, 0x26, 0x76, 0xa1, 0xed, 0x38, 0x95, 0x2e ],
+ variantId: 'key1',
+ initDataType: 'cenc',
+ initData: 'AAAAjXBzc2gAAAAA7e+LqXnWSs6jyCfc1R0h7QAAAG0IARIQE6dTBtEYkXtHpsGDZEJRbxoIY2FzdGxhYnMiRGV5SmhjM05sZEVsa0lqb2laVzFsTFhSbGMzUXRNbk5sYzNOcGIyNGlMQ0oyWVhKcFlXNTBTV1FpT2lKclpYa3hJbjA9MgdkZWZhdWx0AAADwnBzc2gAAAAAmgTweZhAQoarkuZb4IhflQAAA6KiAwAAAQABAJgDPABXAFIATQBIAEUAQQBEAEUAUgAgAHgAbQBsAG4AcwA9ACIAaAB0AHQAcAA6AC8ALwBzAGMAaABlAG0AYQBzAC4AbQBpAGMAcgBvAHMAbwBmAHQALgBjAG8AbQAvAEQAUgBNAC8AMgAwADAANwAvADAAMwAvAFAAbABhAHkAUgBlAGEAZAB5AEgAZQBhAGQAZQByACIAIAB2AGUAcgBzAGkAbwBuAD0AIgA0AC4AMAAuADAALgAwACIAPgA8AEQAQQBUAEEAPgA8AFAAUgBPAFQARQBDAFQASQBOAEYATwA+ADwASwBFAFkATABFAE4APgAxADYAPAAvAEsARQBZAEwARQBOAD4APABBAEwARwBJAEQAPgBBAEUAUwBDAFQAUgA8AC8AQQBMAEcASQBEAD4APAAvAFAAUgBPAFQARQBDAFQASQBOAEYATwA+ADwASwBJAEQAPgBCAGwATwBuAEUAeABqAFIAZQA1AEYASABwAHMARw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4AcwBlAC0AcAByAG8AeAB5AC0AaABlAGEAZABlAHIAYQB1AHQAaAAvAGQAcgBtAHQAbwBkAGEAeQAvAFIAaQBnAGgAdABzAE0AYQBuAGEAZwBlAHIALgBhAHMAbQB4ADwALwBMAFUASQBfAFUAUgBMAD4APABDAEgARQBDAEsAUwBVAE0APgB4AEQASwBBAFkAMAB2AFoAaABVAFUAPQA8AC8AQwBIAEUAQwBLAFMAVQBNAD4APAAvAEQAQQBUAEEAPgA8AC8AVwBSAE0ASABFAEEARABFAFIAPgA=' } ] },
+
+
+ 'mp4-multikey-sequential' : { assetId: 'mp4-multikey-sequential',
+ initDataType: 'cenc',
+ audio: { type: 'audio/mp4;codecs="mp4a.40.2"',
+ path: '/encrypted-media/content/audio_aac-lc_128k_dashinit.mp4' },
+ video: { type: 'video/mp4;codecs="avc1.4d401e"',
+ path: '/encrypted-media/content/video_512x288_h264-360k_multikey_dashinit.mp4' },
+ keys: [ { kid: [0x8a, 0x0d, 0x85, 0x45, 0x21, 0x05, 0xd4, 0x15, 0x35, 0x8f, 0xea, 0x8f, 0x68, 0xe6, 0xc1, 0x91],
+ key: [0x76, 0x6f, 0xab, 0xc1, 0x68, 0x3f, 0xf8, 0xef, 0x4e, 0x76, 0x00, 0x24, 0xc5, 0x23, 0x8f, 0x10],
+ variantId: 'key1',
+ initDataType: 'cenc',
+ initData: 'AAAAlXBzc2gAAAAA7e+LqXnWSs6jyCfc1R0h7QAAAHUIARIQig2FRSEF1BU1j+qPaObBkRoIY2FzdGxhYnMiTGV5SmhjM05sZEVsa0lqb2liWEEwTFcxMWJIUnBhMlY1TFhObGNYVmxiblJwWVd3aUxDSjJZWEpwWVc1MFNXUWlPaUpyWlhreEluMD0yB2RlZmF1bHQAAANYcHNzaAAAAACaBPB5mEBChquS5lvgiF+VAAADODgDAAABAAEALgM8AFcAUgBNAEgARQBBAEQARQBSACAAeABtAGwAbgBzAD0AIgBoAHQAdABwADoALwAvAHMAYwBoAGUAbQBhAHMALgBtA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[0x26, 0x52, 0xc3, 0x1d, 0xf7, 0x92, 0xd1, 0x7b, 0x08, 0xa6, 0xfa, 0xd3, 0x7c, 0xb6, 0x25, 0x60],
+ variantId: 'key2',
+ initDataType: 'cenc',
+ initData: 'AAAAlXBzc2gAAAAA7e+LqXnWSs6jyCfc1R0h7QAAAHUIARIQ+7S380q9MYc0S87EX5ZoiBoIY2FzdGxhYnMiTGV5SmhjM05sZEVsa0lqb2liWEEwTFcxMWJIUnBhMlY1TFhObGNYVmxiblJwWVd3aUxDSjJZWEpwWVc1MFNXUWlPaUpyWlhreUluMD0yB2RlZmF1bHQAAANYcHNzaAAAAACaBPB5mEBChquS5lvgiF+VAAADODgDAAABAAEALgM8AFcAUgBNAEgARQBBAEQARQBSACAAeABtAGwAbgBzAD0AIgBoAHQAdABwADoALwAvAHMAYwBoAGUAbQBhAHMALgBtAGkAYwByAG8AcwBvAGYAdAAuAGMAbwBtAC8ARABSAE0ALwAyADAAMAA3AC8AMAAzAC8AUABsAGEAeQBSAGUAYQBkAHkASABlAGEAZABlAHIAIgAgAHYAZQByAHMAaQBvAG4APQAiADQALgAwAC4AMAAuADAAIgA+ADwARABBAFQAQQA+ADwAUABSAE8AVABFAEMAVABJAE4ARgBPAD4APABLAEUAWQBMAEUATgA+ADEANgA8AC8ASwBFAFkATABFAE4APgA8AEEATABHAEkARAA+AEEARQBTAEMAVABSADwALwBBAEwARwBJAEQAPgA8AC8AUABSAE8AVABFAEMAVABJAE4ARgBPAD4APABLAEkARAA+ADgANwBlADAAKwA3ADEASwBoAHoARQAwAFMAOAA3AEUAWAA1AFoAbwBpAEEAPQA9ADwALwBLAEkARAA+ADwATABBAF8AVQBSAEwAPgBoAHQAdABwAHMAOgAvAC8AbABpAGMALgBzAHQAYQBnAGkAbgBnAC4AZAByAG0AdABvAGQAYQB5AC4AYwBvAG0ALwBsAGkAYwBlAG4AcwBlAC0AcAByAG8AeAB5AC0AaABlAGEAZABlAHIAYQB1AHQAaAAvAGQAcgBtAHQAbwBkAGEAeQAvAFIAaQBnAGgAdABzAE0AYQBuAGEAZwBlAHIALgBhAHMAbQB4ADwALwBMAEEAXwBVAFIATAA+ADwATABVAEkAXwBVAFIATAA+AGgAdAB0AHAAcwA6AC8ALwBwAGwAYQB5AHIAZQBhAGQAeQAtAHUAaQAuAGUAeABhAG0AcABsAGUALgBjAG8AbQA8AC8ATABVAEkAXwBVAFIATAA+ADwAQwBIAEUAQwBLAFMAVQBNAD4ARgB0AGkASQBoADYAUwBKAG0AcABZAD0APAAvAEMASABFAEMASwBTAFUATQA+ADwALwBEAEEAVABBAD4APAAvAFcAUgBNAEgARQBBAEQARQBSAD4A' } ] },
+
+ 'webm' : { audio : { type: 'audio/webm; codecs="opus"' },
+ video : { type: 'video/webm; codecs="vp8"',
+ path: '/encrypted-media/content/test-encrypted.webm' },
+ keys : [ { kid: [48,49,50,51,52,53,54,55,56,57,48,49,50,51,52,53],
+ key: [0xeb, 0xdd, 0x62, 0xf1, 0x68, 0x14, 0xd2, 0x7b,
+ 0x68, 0xef, 0x12, 0x2a, 0xfc, 0xe4, 0xae, 0x3c ] } ]
+ },
+ 'webm-multikey' :
+ { audio : { type: 'audio/webm; codecs="opus"' },
+ video : { type: 'video/webm; codecs="vp8"',
+ path: '/encrypted-media/content/test-encrypted-different-av-keys.webm' },
+ keys : [ { kid: [48,49,50,51,52,53,54,55,56,57,48,49,50,51,52,53],
+ key: [ 0x7A, 0x7A, 0x62, 0xF1, 0x68, 0x14, 0xD2, 0x7B,
+ 0x68, 0xEF, 0x12, 0x2A, 0xFC, 0xE4, 0xAE, 0x0A ] },
+ { kid: [49,50,51,52,53,54,55,56,57,48,49,50,51,52,53,54],
+ key: [ 0x30, 0x30, 0x62, 0xF1, 0x68, 0x14, 0xD2, 0x7B,
+ 0x68, 0xEF, 0x12, 0x2A, 0xFC, 0xE4, 0xAE, 0x0A ] } ]
+ },
+} );
+
+function addMemberListToObject( o )
+{
+ var items = [ ];
+ for( var item in o )
+ {
+ if ( !o.hasOwnProperty( item ) ) continue;
+
+ o[item].name = item;
+ items.push( o[item] );
+ }
+
+ o._items = items;
+
+ return o;
+}
+
+function getInitData( contentitem, initDataType )
+{
+ if (initDataType == 'webm') {
+ return new Uint8Array( contentitem.keys[ 0 ].kid ); // WebM initData supports only a single key
+ }
+
+ if (initDataType == 'cenc') {
+
+ var size = 36 + contentitem.keys.length * 16,
+ kids = contentitem.keys.map( function( k ) { return k.kid; } );
+
+ return new Uint8Array(Array.prototype.concat.call( [
+ 0x00, 0x00, size / 256, size % 256, // size
+ 0x70, 0x73, 0x73, 0x68, // 'pssh'
+ 0x01, // version = 1
+ 0x00, 0x00, 0x00, // flags
+ 0x10, 0x77, 0xEF, 0xEC, 0xC0, 0xB2, 0x4D, 0x02, // Common SystemID
+ 0xAC, 0xE3, 0x3C, 0x1E, 0x52, 0xE2, 0xFB, 0x4B,
+ 0x00, 0x00, 0x00, kids.length ], // key count ]
+ Array.prototype.concat.apply( [], kids ),
+ [ 0x00, 0x00, 0x00, 0x00 ]// datasize
+ ));
+ }
+ if (initDataType == 'keyids') {
+
+ return toUtf8( { kids: contentitem.keys.map( function( k ) { return base64urlEncode( new Uint8Array( k.kid ) ); } ) } );
+ }
+ throw 'initDataType ' + initDataType + ' not supported.';
+}
+
+function getSingleKeyInitData( kid, initDataType )
+{
+ if (initDataType == 'webm') {
+ return new Uint8Array( kid );
+ }
+
+ if (initDataType == 'cenc') {
+
+ var size = 52;
+
+ return new Uint8Array(Array.prototype.concat.call( [
+ 0x00, 0x00, size / 256, size % 256, // size
+ 0x70, 0x73, 0x73, 0x68, // 'pssh'
+ 0x01, // version = 1
+ 0x00, 0x00, 0x00, // flags
+ 0x10, 0x77, 0xEF, 0xEC, 0xC0, 0xB2, 0x4D, 0x02, // Common SystemID
+ 0xAC, 0xE3, 0x3C, 0x1E, 0x52, 0xE2, 0xFB, 0x4B,
+ 0x00, 0x00, 0x00, 0x01 ], // key count ]
+ kid,
+ [ 0x00, 0x00, 0x00, 0x00 ]// datasize
+ ));
+ }
+ if (initDataType == 'keyids') {
+
+ return toUtf8( { kids: [ base64urlEncode( new Uint8Array( kid ) ) ] } );
+ }
+ throw 'initDataType ' + initDataType + ' not supported.';
+}
+
+function getMultikeyInitDatas( contentitem, initDataType )
+{
+ return contentitem.keys.map( function( k ) { return getSingleKeyInitData( k.kid, initDataType ); } );
+}
+
+function getProprietaryInitDatas( contentitem )
+{
+ var keysWithInitData = contentitem.keys.filter( function( k ) { return k.initData; } );
+ return { initDataType: contentitem.initDataType,
+ initDatas : keysWithInitData.map( function( k ) { return k.initData; } ),
+ variantIds: keysWithInitData.map( function( k ) { return k.variantId; } )
+ };
+}
+
+// Returns a promise that resolves to the following object
+// { supported: boolean, // whether the content is supported at all
+// content: <the content item>, // the content item description
+// initDataTypes: <list of initDataTypes>
+// }
+//
+// Note: we test initData types one at a time since some versions of Edge don't support testing several at once
+//
+function isContentSupportedForInitDataTypes( keysystem, initDataTypes, contentitem )
+{
+ return Promise.all( initDataTypes.map( function( initDataType ) {
+ var configuration = { initDataTypes : [ initDataType ],
+ audioCapabilities: [ { contentType: contentitem.audio.type } ],
+ videoCapabilities: [ { contentType: contentitem.video.type } ]
+ };
+ return navigator.requestMediaKeySystemAccess( keysystem, [ configuration ] ).then( function( access ) {
+ return { supported: true, initDataType: access.getConfiguration().initDataTypes[ 0 ] };
+ }, function() {
+ return { supported: false };
+ } );
+ } ) ).then( function( results ) {
+
+ var initDataTypes = results.filter( function( result ) { return result.supported; } )
+ .map( function( result ) { return result.initDataType; } );
+
+ return initDataTypes.length > 0 ?
+ { content: contentitem, supported: true, initDataTypes: initDataTypes }
+ : { content: contentitem, supported: false };
+ } );
+}
+
+// Returns a promise that resolves to { content:, supported:, initDataTypes: } object
+function isContentSupported( keysystem, contentitem )
+{
+ return isContentSupportedForInitDataTypes( keysystem, [ 'cenc', 'webm', 'keyids' ], contentitem );
+}
+
+// Returns a Promise resolving to an array of supported content for the key system
+function getSupportedContent( keysystem )
+{
+ return Promise.all( content._items.map( isContentSupported.bind( null, keysystem ) ) ).
+ then( function( results )
+ {
+ return results.filter( function( r ) { return r.supported; } ).map( function( r ) { return r.content; } );
+ } );
+}
+
+// Returns a Promise resolving to an array of { content:, initDataType: } pairs for the key system
+function getSupportedContentAndInitDataTypes( keysystem )
+{
+ return Promise.all( content._items.map( isContentSupported.bind( null, keysystem ) ) ).
+ then( function( results )
+ {
+ return results.filter( function( r ) { return r.supported; } );
+ } );
+}
+
+// gets a configuration object for provided piece of content
+function getSimpleConfigurationForContent( contentitem )
+{
+ return { initDataTypes: [ 'keyids', 'webm', 'cenc' ],
+ audioCapabilities: [ { contentType: contentitem.audio.type } ],
+ videoCapabilities: [ { contentType: contentitem.video.type } ] };
+}
diff --git a/Tests/LibWeb/Text/input/wpt-import/encrypted-media/scripts/check-encryption-scheme.js b/Tests/LibWeb/Text/input/wpt-import/encrypted-media/scripts/check-encryption-scheme.js
new file mode 100644
index 00000000000..ffab4a34911
--- /dev/null
+++ b/Tests/LibWeb/Text/input/wpt-import/encrypted-media/scripts/check-encryption-scheme.js
@@ -0,0 +1,46 @@
+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.');
+
+ promise_test(
+ () => checkEncryptionScheme('cbcs-1-9'),
+ testnamePrefix(qualifier, config.keysystem) +
+ ' support for "cbcs-1-9" encryption scheme.');
+}
diff --git a/Tests/LibWeb/Text/input/wpt-import/encrypted-media/scripts/check-initdata-type.js b/Tests/LibWeb/Text/input/wpt-import/encrypted-media/scripts/check-initdata-type.js
new file mode 100644
index 00000000000..5c7cb6e4b9a
--- /dev/null
+++ b/Tests/LibWeb/Text/input/wpt-import/encrypted-media/scripts/check-initdata-type.js
@@ -0,0 +1,35 @@
+ function runTest( config, qualifier )
+ {
+ function checkInitDataType(initDataType)
+ {
+ return isInitDataTypeSupported(initDataType).then(function(result) {
+ // If |initDataType| is not supported, simply succeed.
+ if (!result)
+ return Promise.resolve('Not supported');
+
+ return navigator.requestMediaKeySystemAccess( config.keysystem, getSimpleConfigurationForInitDataType(initDataType))
+ .then(function(access) {
+ return access.createMediaKeys();
+ }).then(function(mediaKeys) {
+ var mediaKeySession = mediaKeys.createSession();
+ var initData = getInitData(initDataType);
+ return mediaKeySession.generateRequest(initDataType, initData);
+ });
+ });
+ }
+
+ promise_test(function()
+ {
+ return checkInitDataType('webm');
+ }, testnamePrefix( qualifier, config.keysystem ) + ' support for "webm".');
+
+ promise_test(function()
+ {
+ return checkInitDataType('cenc');
+ }, testnamePrefix( qualifier, config.keysystem ) + ' support for "cenc".');
+
+ promise_test(function()
+ {
+ return checkInitDataType('keyids');
+ }, testnamePrefix( qualifier, config.keysystem ) + ' support for "keyids".');
+}
diff --git a/Tests/LibWeb/Text/input/wpt-import/encrypted-media/scripts/requestmediakeysystemaccess.js b/Tests/LibWeb/Text/input/wpt-import/encrypted-media/scripts/requestmediakeysystemaccess.js
new file mode 100644
index 00000000000..a60d4a1e768
--- /dev/null
+++ b/Tests/LibWeb/Text/input/wpt-import/encrypted-media/scripts/requestmediakeysystemaccess.js
@@ -0,0 +1,341 @@
+function runTest(config, qualifier) {
+
+ var prefix = testnamePrefix(qualifier, config.keysystem) + ', requestMediaKeySystemAccess: ';
+
+ function expect_error(keySystem, configurations, expectedError, testname) {
+
+ var audioCapabilities = configurations.length ? configurations[0].audioCapabilities : undefined,
+ videoCapabilities = configurations.length ? configurations[0].videoCapabilities : undefined,
+ audiocontenttypes = audioCapabilities ? audioCapabilities.map( function(ac) { return "'" + ac.contentType + "'"; } ).join(',') : '',
+ videocontenttypes = videoCapabilities ? videoCapabilities.map( function(ac) { return "'" + ac.contentType + "'"; } ).join(',') : '',
+ modifiedtestname = testname.replace( '%audiocontenttype', audiocontenttypes ).replace( '%videocontenttype', videocontenttypes );
+
+ promise_test(function(test) {
+ var p = navigator.requestMediaKeySystemAccess(keySystem, configurations);
+ // expectedError is a string name for the error. We can differentiate
+ // JS Errors from DOMExceptions by checking whether
+ // window[expectedError] exists. If it does, expectedError is the name
+ // of a JS Error subclass and window[expectedError] is the constructor
+ // for that subclass. Otherwise it's a name for a DOMException.
+ if (window[expectedError]) {
+ return promise_rejects_js(test, window[expectedError], p);
+ } else {
+ return promise_rejects_dom(test, expectedError, p);
+ }
+ }, prefix + modifiedtestname + ' should result in ' + expectedError );
+ }
+
+ function assert_subset(actual, expected, path) {
+ if (typeof expected == 'string') {
+ assert_equals(actual, expected, path);
+ } else {
+ if (expected.hasOwnProperty('length')) {
+ assert_equals(actual.length, expected.length, path + '.length');
+ }
+ for (property in expected) {
+ assert_subset(actual[property], expected[property], path + '.' + property);
+ }
+ }
+ }
+
+ function expect_config(keySystem, configurations, expectedConfiguration, testname) {
+ promise_test(function(test) {
+ return navigator.requestMediaKeySystemAccess(keySystem, configurations).then(function(a) {
+ assert_subset(a.getConfiguration(), expectedConfiguration, testname + ': ');
+ });
+ }, testname);
+ }
+
+ // Tests for Key System.
+ expect_error('', [{}], 'TypeError', 'Empty Key System');
+ expect_error('com.example.unsupported', [{}], 'NotSupportedError', 'Unsupported Key System');
+ expect_error(config.keysystem + '.', [{}], 'NotSupportedError', 'Key System ending in "."');
+ expect_error(config.keysystem.toUpperCase(), [{}], 'NotSupportedError', 'Capitalized Key System');
+ expect_error(config.keysystem + '\u028F', [{}], 'NotSupportedError', 'Non-ASCII Key System');
+
+ // Parent of Clear Key not supported.
+ expect_error(config.keysystem.match(/^(.*?)\./)[1], [{}], 'NotSupportedError', 'Root domain of Key System alone');
+ expect_error(config.keysystem.match(/^(.*?)\./)[0], [{}], 'NotSupportedError', 'Root domain of Key System, with dot');
+ expect_error(config.keysystem.match(/^(.*?\..*?)\./)[1], [{}], 'NotSupportedError', 'Domain of Key System along');
+ expect_error(config.keysystem.match(/^(.*?\..*?)\./)[0], [{}], 'NotSupportedError', 'Domain of Key System, with dot');
+
+ // Child of Clear Key not supported.
+ expect_error(config.keysystem+'.foo', [{}], 'NotSupportedError', 'Child of Key System');
+
+ // Prefixed Clear Key not supported.
+ expect_error('webkit-'+config.keysystem, [{}], 'NotSupportedError', 'Prefixed Key System');
+
+ // Incomplete names.
+ expect_error(config.keysystem.substr(0,7)+config.keysystem.substr(8), [{}], 'NotSupportedError', 'Missing characters in middle of Key System name');
+ expect_error(config.keysystem.substr(0,config.keysystem.length-1), [{}], 'NotSupportedError', 'Missing characters at end of Key System name');
+
+ // Spaces in key system name not supported.
+ expect_error(' '+config.keysystem, [{}], 'NotSupportedError', 'Leading space in Key System name');
+ expect_error(config.keysystem.substr(0,6) + ' ' + config.keysystem.substr(6), [{}], 'NotSupportedError', 'Extra space in Key System name');
+ expect_error(config.keysystem + ' ', [{}], 'NotSupportedError', 'Trailing space in Key System name');
+
+ // Extra dots in key systems names not supported.
+ expect_error('.' + config.keysystem, [{}], 'NotSupportedError', 'Leading dot in Key System name');
+ expect_error(config.keysystem.substr(0,6) + '.' + config.keysystem.substr(6), [{}], 'NotSupportedError', 'Extra dot in middle of Key System name');
+ expect_error(config.keysystem + '.', [{}], 'NotSupportedError', 'Trailing dot in Key System name');
+
+ // Key system name is case sensitive.
+ if (config.keysystem !== config.keysystem.toUpperCase()) {
+ expect_error(config.keysystem.toUpperCase(), [{}], 'NotSupportedError', 'Key System name is case sensitive');
+ }
+
+ if (config.keysystem !== config.keysystem.toLowerCase()) {
+ expect_error(config.keysystem.toLowerCase(), [{}], 'NotSupportedError', 'Key System name is case sensitive');
+ }
+
+ // Tests for trivial configurations.
+ expect_error(config.keysystem, [], 'TypeError', 'Empty supportedConfigurations');
+ expect_error(config.keysystem, [{}], 'NotSupportedError', 'Empty configuration');
+
+ // Various combinations of supportedConfigurations.
+ expect_config(config.keysystem, [{
+ initDataTypes: [config.initDataType],
+ audioCapabilities: [{contentType: config.audioType}],
+ videoCapabilities: [{contentType: config.videoType}],
+ label: 'abcd',
+ }], {
+ initDataTypes: [config.initDataType],
+ audioCapabilities: [{contentType: config.audioType}],
+ videoCapabilities: [{contentType: config.videoType}],
+ label: 'abcd',
+ }, 'Basic supported configuration');
+
+ expect_config(config.keysystem, [{
+ initDataTypes: ['fakeidt', config.initDataType],
+ audioCapabilities: [{contentType: 'audio/fake'}, {contentType: config.audioType}],
+ videoCapabilities: [{contentType: 'video/fake'}, {contentType: config.videoType}],
+ }], {
+ initDataTypes: [config.initDataType],
+ audioCapabilities: [{contentType: config.audioType}],
+ videoCapabilities: [{contentType: config.videoType}],
+ }, 'Partially supported configuration');
+
+ expect_config(config.keysystem, [{
+ audioCapabilities: [{contentType: config.audioType}],
+ }], {
+ audioCapabilities: [{contentType: config.audioType}],
+ }, 'Supported audio codec');
+
+ expect_config(config.keysystem, [{
+ audioCapabilities: [{contentType: config.audioType.replace(/^(.*?);(.*)/, "$1; $2")}],
+ }], {
+ audioCapabilities: [{contentType: config.audioType.replace(/^(.*?);(.*)/, "$1; $2")}],
+ }, 'ContentType formatting must be preserved');
+
+ expect_error(config.keysystem, [{
+ audioCapabilities: [{contentType: 'audio/webm; codecs=fake'}],
+ }], 'NotSupportedError', 'Unsupported audio codec (%audiocontenttype)');
+
+ expect_error(config.keysystem, [{
+ audioCapabilities: [{contentType: 'video/webm; codecs=fake'}],
+ }], 'NotSupportedError', 'Unsupported video codec (%videocontenttype)');
+
+ expect_error(config.keysystem, [{
+ audioCapabilities: [
+ {contentType: 'audio/webm; codecs=mp4a'},
+ {contentType: 'audio/webm; codecs=mp4a.40.2'}
+ ],
+ }], 'NotSupportedError', 'Mismatched audio container/codec (%audiocontenttype)');
+
+ expect_error(config.keysystem, [{
+ audioCapabilities: [{contentType: config.videoType}],
+ }], 'NotSupportedError', 'Video codec specified in audio field (%audiocontenttype)');
+
+ expect_error(config.keysystem, [{
+ videoCapabilities: [{contentType: config.audioType}],
+ }], 'NotSupportedError', 'Audio codec specified in video field (%videocontenttype)');
+
+ expect_error(config.keysystem, [{
+ audioCapabilities: [
+ {contentType: 'audio/webm; codecs=avc1'},
+ {contentType: 'audio/webm; codecs=avc1.42e01e'}
+ ],
+ }], 'NotSupportedError', 'Mismatched audio container/codec (%audiocontenttype)');
+
+ expect_error(config.keysystem, [{
+ audioCapabilities: [
+ {contentType: 'audio/mp4; codecs=vorbis'}
+ ],
+ }], 'NotSupportedError', 'Mismatched audio container/codec (%audiocontenttype)');
+
+ expect_config(config.keysystem, [{
+ initDataTypes: ['fakeidt'],
+ videoCapabilities: [{contentType: config.videoType}]
+ }, {
+ initDataTypes: [config.initDataType],
+ videoCapabilities: [{contentType: config.videoType}]
+ }
+ ], {
+ initDataTypes: [config.initDataType],
+ videoCapabilities: [{contentType: config.videoType}]
+ }, 'Two configurations, one supported');
+
+ expect_config(config.keysystem, [{
+ initDataTypes: [config.initDataType],
+ videoCapabilities: [{contentType: config.videoType}]
+ }, {
+ videoCapabilities: [{contentType: config.videoType}]
+ }
+ ], {
+ initDataTypes: [config.initDataType],
+ videoCapabilities: [{contentType: config.videoType}]
+ }, 'Two configurations, both supported');
+
+ // Audio MIME type does not support video codecs.
+ expect_error(config.keysystem, [{
+ audioCapabilities: [
+ {contentType: 'audio/webm; codecs="vp8,vorbis"'},
+ {contentType: 'audio/webm; codecs="vorbis, vp8"'},
+ {contentType: 'audio/webm; codecs="vp8"'}
+ ],
+ }], 'NotSupportedError', 'Audio MIME type does not support video codecs (webm) (%audiocontenttype)');
+
+ expect_error(config.keysystem, [{
+ audioCapabilities: [
+ {contentType: 'audio/mp4; codecs="avc1"'},
+ {contentType: 'audio/mp4; codecs="avc1.4d401e"'},
+ ],
+ }], 'NotSupportedError', 'Audio MIME type does not support video codecs (mp4) (%audiocontenttype)');
+
+ // Video MIME type does not support audio codecs.
+ expect_error(config.keysystem, [{
+ videoCapabilities: [
+ {contentType: 'video/webm; codecs="vp8,vorbis"'},
+ {contentType: 'video/webm; codecs="vorbis, vp8"'},
+ {contentType: 'video/webm; codecs="vorbis"'}
+ ],
+ }], 'NotSupportedError', 'Video MIME type does not support audio codecs (webm) (%videocontenttype)');
+
+ expect_error(config.keysystem, [{
+ videoCapabilities: [
+ {contentType: 'video/mp4; codecs="mp4a"'},
+ {contentType: 'video/mp4; codecs="mp4a.40.2"'}
+ ],
+ }], 'NotSupportedError', 'Video MIME type does not support audio codecs (mp4) (%videocontenttype)');
+
+ // WebM does not support AVC1/AAC.
+ expect_error(config.keysystem, [{
+ audioCapabilities: [
+ {contentType: 'audio/webm; codecs="aac"'},
+ {contentType: 'audio/webm; codecs="avc1"'},
+ {contentType: 'audio/webm; codecs="vp8,aac"'}
+ ],
+ }], 'NotSupportedError', 'WebM audio does not support AVC1/AAC (%audiocontenttype)');
+
+ expect_error(config.keysystem, [{
+ videoCapabilities: [
+ {contentType: 'video/webm; codecs="aac"'},
+ {contentType: 'video/webm; codecs="avc1"'},
+ {contentType: 'video/webm; codecs="vp8,aac"'}
+ ],
+ }], 'NotSupportedError', 'WebM video does not support AVC1/AAC (%videocontenttype)');
+
+ // Extra space is allowed in contentType.
+ expect_config(config.keysystem, [{
+ videoCapabilities: [{contentType: ' ' + config.videoType}],
+ }], {
+ videoCapabilities: [{contentType: ' ' + config.videoType}],
+ }, 'Leading space in contentType');
+
+ expect_config(config.keysystem, [{
+ videoCapabilities: [{contentType: config.videoType.replace( /^(.*?);(.*)/, "$1 ;$2")}],
+ }], {
+ videoCapabilities: [{contentType: config.videoType.replace( /^(.*?);(.*)/, "$1 ;$2")}],
+ }, 'Space before ; in contentType');
+
+
+ expect_config(config.keysystem, [{
+ videoCapabilities: [{contentType: config.videoType + ' '}],
+ }], {
+ videoCapabilities: [{contentType: config.videoType + ' '}],
+ }, 'Trailing space in contentType');
+
+ expect_config(config.keysystem, [{
+ videoCapabilities: [{contentType: config.videoType.replace( /^(.*?codecs=\")(.*)/, "$1 $2")}],
+ }], {
+ videoCapabilities: [{contentType: config.videoType.replace( /^(.*?codecs=\")(.*)/, "$1 $2")}],
+ }, 'Space at start of codecs parameter');
+
+ expect_config(config.keysystem, [{
+ videoCapabilities: [{contentType: config.videoType.replace( /^(.*?codecs=\".*)\"/, "$1 \"")}],
+ }], {
+ videoCapabilities: [{contentType: config.videoType.replace( /^(.*?codecs=\".*)\"/, "$1 \"")}],
+ }, 'Space at end of codecs parameter');
+
+ // contentType is not case sensitive (except the codec names).
+ expect_config(config.keysystem, [{
+ videoCapabilities: [{contentType: 'V' + config.videoType.substr(1)}],
+ }], {
+ videoCapabilities: [{contentType: 'V' + config.videoType.substr(1)}],
+ }, 'Video/' );
+
+ expect_config(config.keysystem, [{
+ videoCapabilities: [{contentType: config.videoType.replace( /^(.*?)c(odecs.*)/, "$1C$2")}],
+ }], {
+ videoCapabilities: [{contentType: config.videoType.replace( /^(.*?)c(odecs.*)/, "$1C$2")}],
+ }, 'Codecs=');
+
+ var t = config.videoType.match(/(.*?)(;.*)/);
+ expect_config(config.keysystem, [{
+ videoCapabilities: [{contentType: t[1].toUpperCase() + t[2]}],
+ }], {
+ videoCapabilities: [{contentType: t[1].toUpperCase() + t[2]}],
+ }, 'Upper case MIME type');
+
+ t = config.videoType.match(/(.*?)codecs(.*)/);
+ expect_config(config.keysystem, [{
+ videoCapabilities: [{contentType: t[1] + 'CODECS' + t[2]}],
+ }], {
+ videoCapabilities: [{contentType: t[1] + 'CODECS' + t[2]}],
+ }, 'CODECS=');
+
+ // Unrecognized attributes are not allowed.
+ expect_error(config.keysystem, [{
+ videoCapabilities: [{contentType: 'video/webm; foo="bar"'}],
+ }], 'NotSupportedError', 'Unrecognized foo with webm (%videocontenttype)');
+
+ expect_error(config.keysystem, [{
+ videoCapabilities: [{contentType: 'video/mp4; foo="bar"'}],
+ }], 'NotSupportedError', 'Unrecognized foo with mp4 (%videocontenttype)');
+
+ expect_error(config.keysystem, [{
+ videoCapabilities: [{contentType: config.videoType + '; foo="bar"'}],
+ }], 'NotSupportedError', 'Unrecognized foo with codecs (%videocontenttype)');
+
+ // Invalid contentTypes.
+ expect_error(config.keysystem, [{
+ videoCapabilities: [{contentType: 'fake'}],
+ }], 'NotSupportedError', 'contentType: %videocontenttype');
+
+ expect_error(config.keysystem, [{
+ audioCapabilities: [{contentType: 'audio/fake'}],
+ }], 'NotSupportedError', 'contentType: %audiocontenttype');
+
+ expect_error(config.keysystem, [{
+ videoCapabilities: [{contentType: 'video/fake'}],
+ }], 'NotSupportedError', 'contentType: %videocontenttype');
+
+ // The actual codec names are case sensitive.
+ t = config.videoType.match( /(.*?codecs=\")(.*?\")(.*)/ );
+ if (t[2] !== t[2].toUpperCase()) {
+ expect_error(config.keysystem, [{
+ videoCapabilities: [{contentType: t[1] + t[2].toUpperCase() + t[3] }],
+ }], 'NotSupportedError', 'contentType: %videocontenttype');
+ }
+
+ if (t[2] !== t[2].toLowerCase()) {
+ expect_error(config.keysystem, [{
+ videoCapabilities: [{contentType: t[1] + t[2].toLowerCase() + t[3] }],
+ }], 'NotSupportedError', 'contentType: %videocontenttype');
+ }
+
+ // Extra comma is not allowed in codecs.
+ expect_error(config.keysystem, [{
+ videoCapabilities: [{contentType: t[1] + ',' + t[2] + t[3] }],
+ }], 'NotSupportedError', 'contentType: %videocontenttype');
+}
diff --git a/Tests/LibWeb/Text/input/wpt-import/encrypted-media/util/testmediasource.js b/Tests/LibWeb/Text/input/wpt-import/encrypted-media/util/testmediasource.js
new file mode 100644
index 00000000000..1c4a3615583
--- /dev/null
+++ b/Tests/LibWeb/Text/input/wpt-import/encrypted-media/util/testmediasource.js
@@ -0,0 +1,61 @@
+function testmediasource(config) {
+
+ return new Promise(function(resolve, reject) {
+ // Fetch the media resources
+ var fetches = [config.audioPath, config.videoPath].map(function(path) {
+ return fetch(path).then(function(response) {
+ if (!response.ok) throw new Error('Resource fetch failed');
+ return response.arrayBuffer();
+ });
+ });
+
+ Promise.all(fetches).then(function(resources) {
+ config.audioMedia = resources[0];
+ config.videoMedia = resources[1];
+ if (Object.hasOwn(config, 'audioBlankBytes')) {
+ audioMedia = new Uint8Array(config.audioMedia);
+ for (const pos of config.audioBlankBytes) {
+ audioMedia[pos] = ' '.charCodeAt();
+ }
+ }
+ if (Object.hasOwn(config, 'videoBlankBytes')) {
+ videoMedia = new Uint8Array(config.videoMedia);
+ for (const pos of config.videoBlankBytes) {
+ videoMedia[pos] = ' '.charCodeAt();
+ }
+ }
+
+ // Create media source
+ var source = new MediaSource();
+ source.done = new Promise(function(resolvesource,rejectsource){
+
+ // Create and fill source buffers when the media source is opened
+ source.addEventListener('sourceopen', onSourceOpen);
+ resolve(source);
+
+ function onSourceOpen(event) {
+ var audioSourceBuffer = source.addSourceBuffer(config.audioType),
+ videoSourceBuffer = source.addSourceBuffer(config.videoType);
+
+ audioSourceBuffer.addEventListener('updateend',onUpdateEnd);
+ videoSourceBuffer.addEventListener('updateend',onUpdateEnd);
+
+ audioSourceBuffer.appendBuffer(config.audioMedia);
+ videoSourceBuffer.appendBuffer(config.videoMedia);
+
+ function onUpdateEnd(event){
+ event.target.removeEventListener('updateend', onUpdateEnd);
+ if (!audioSourceBuffer.updating && !videoSourceBuffer.updating) {
+ if (source.readyState !== 'open') {
+ rejectsource(new Error("Media source error"));
+ } else {
+ source.endOfStream();
+ resolvesource();
+ }
+ }
+ }
+ }
+ });
+ });
+ });
+}
diff --git a/Tests/LibWeb/Text/input/wpt-import/encrypted-media/util/utf8.js b/Tests/LibWeb/Text/input/wpt-import/encrypted-media/util/utf8.js
new file mode 100644
index 00000000000..aea5ad7626d
--- /dev/null
+++ b/Tests/LibWeb/Text/input/wpt-import/encrypted-media/util/utf8.js
@@ -0,0 +1,2 @@
+toUtf8 = function( o ) { return new TextEncoder().encode( JSON.stringify( o ) ); }
+fromUtf8 = function( t ) { return JSON.parse( new TextDecoder().decode( t ) ); }
diff --git a/Tests/LibWeb/Text/input/wpt-import/encrypted-media/util/utils.js b/Tests/LibWeb/Text/input/wpt-import/encrypted-media/util/utils.js
new file mode 100644
index 00000000000..dd790067166
--- /dev/null
+++ b/Tests/LibWeb/Text/input/wpt-import/encrypted-media/util/utils.js
@@ -0,0 +1,307 @@
+function testnamePrefix( qualifier, keysystem ) {
+ return ( qualifier || '' ) + ( keysystem === 'org.w3.clearkey' ? keysystem : 'drm' );
+}
+
+function getInitData(initDataType) {
+
+ // FIXME: This is messed up, because here we are hard coding the key ids for the different content
+ // that we use for clearkey testing: webm and mp4. For keyids we return the mp4 one
+ //
+ // The content used with the DRM today servers has a different key id altogether
+
+ if (initDataType == 'webm') {
+ return new Uint8Array([
+ 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
+ 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F
+ ]);
+ }
+
+ if (initDataType == 'cenc') {
+ return new Uint8Array([
+ 0x00, 0x00, 0x00, 0x34, // size
+ 0x70, 0x73, 0x73, 0x68, // 'pssh'
+ 0x01, // version = 1
+ 0x00, 0x00, 0x00, // flags
+ 0x10, 0x77, 0xEF, 0xEC, 0xC0, 0xB2, 0x4D, 0x02, // Common SystemID
+ 0xAC, 0xE3, 0x3C, 0x1E, 0x52, 0xE2, 0xFB, 0x4B,
+ 0x00, 0x00, 0x00, 0x01, // key count
+ 0x00, 0x00, 0x00, 0x00, 0x03, 0xd2, 0xfc, 0x41, // key id
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00 // datasize
+ ]);
+ }
+ if (initDataType == 'keyids') {
+ var keyId = new Uint8Array([
+ 0x00, 0x00, 0x00, 0x00, 0x03, 0xd2, 0xfc, 0x41,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
+ ]);
+ return stringToUint8Array(createKeyIDs(keyId));
+ }
+ throw 'initDataType ' + initDataType + ' not supported.';
+}
+
+function stringToUint8Array(str)
+{
+ var result = new Uint8Array(str.length);
+ for(var i = 0; i < str.length; i++) {
+ result[i] = str.charCodeAt(i);
+ }
+ return result;
+}
+// Encodes |data| into base64url string. There is no '=' padding, and the
+// characters '-' and '_' must be used instead of '+' and '/', respectively.
+function base64urlEncode(data) {
+ var result = btoa(String.fromCharCode.apply(null, data));
+ return result.replace(/=+$/g, '').replace(/\+/g, "-").replace(/\//g, "_");
+}
+// Decode |encoded| using base64url decoding.
+function base64urlDecode(encoded) {
+ return atob(encoded.replace(/\-/g, "+").replace(/\_/g, "/"));
+}
+// Decode |encoded| using base64 to a Uint8Array
+function base64DecodeToUnit8Array(encoded) {
+ return new Uint8Array( atob( encoded ).split('').map( function(c){return c.charCodeAt(0);} ) );
+}
+// Clear Key can also support Key IDs Initialization Data.
+// ref: http://w3c.github.io/encrypted-media/keyids-format.html
+// Each parameter is expected to be a key id in an Uint8Array.
+function createKeyIDs() {
+ var keyIds = '{"kids":["';
+ for (var i = 0; i < arguments.length; i++) {
+ if (i != 0) keyIds += '","';
+ keyIds += base64urlEncode(arguments[i]);
+ }
+ keyIds += '"]}';
+ return keyIds;
+}
+
+async function getSupportedKeySystem() {
+ var userAgent = navigator.userAgent.toLowerCase();
+ var keysystem = undefined;
+ if (userAgent.indexOf('edge') > -1 ) {
+ keysystem = 'com.microsoft.playready';
+ } else if (userAgent.indexOf('chrome') > -1) {
+ keysystem = 'com.widevine.alpha';
+ } else if (userAgent.indexOf('firefox') > -1) {
+ keysystem = 'com.widevine.alpha';
+ if (userAgent.includes("win")) {
+ // Firefox on Windows may use PlayReady via Media Foundation or
+ // Widevine, depending on its configuration.
+ try {
+ await navigator.requestMediaKeySystemAccess(
+ 'com.microsoft.playready.recommendation',
+ [{ initDataTypes: ['cenc'],
+ videoCapabilities: [{ contentType: 'video/mp4;codecs="avc1.4d401e"' }] }]);
+ keysystem = 'com.microsoft.playready.recommendation';
+ } catch (e) {
+ }
+ }
+ }
+ return keysystem;
+}
+
+function waitForEventAndRunStep(eventName, element, func, stepTest)
+{
+ var eventCallback = function(event) {
+ if (func)
+ func(event);
+ }
+
+ element.addEventListener(eventName, stepTest.step_func(eventCallback), true);
+}
+
+function waitForEvent(eventName, element) {
+ return new Promise(function(resolve) {
+ element.addEventListener(eventName, resolve, true);
+ })
+}
+
+var consoleDiv = null;
+
+function consoleWrite(text)
+{
+ if (!consoleDiv && document.body) {
+ consoleDiv = document.createElement('div');
+ document.body.appendChild(consoleDiv);
+ }
+ var span = document.createElement('span');
+ span.appendChild(document.createTextNode(text));
+ span.appendChild(document.createElement('br'));
+ consoleDiv.appendChild(span);
+}
+
+function forceTestFailureFromPromise(test, error, message)
+{
+ test.step_func(assert_unreached)(message ? message + ': ' + error.message : error);
+}
+
+// Returns an array of audioCapabilities that includes entries for a set of
+// codecs that should cover all user agents.
+function getPossibleAudioCapabilities()
+{
+ return [
+ { contentType: 'audio/mp4; codecs="mp4a.40.2"' },
+ { contentType: 'audio/webm; codecs="opus"' },
+ ];
+}
+
+// Returns a trivial MediaKeySystemConfiguration that should be accepted,
+// possibly as a subset of the specified capabilities, by all user agents.
+function getSimpleConfiguration()
+{
+ return [ {
+ initDataTypes : [ 'webm', 'cenc', 'keyids' ],
+ audioCapabilities: getPossibleAudioCapabilities()
+ } ];
+}
+
+// Returns a MediaKeySystemConfiguration for |initDataType| that should be
+// accepted, possibly as a subset of the specified capabilities, by all
+// user agents.
+function getSimpleConfigurationForInitDataType(initDataType)
+{
+ return [ {
+ initDataTypes: [ initDataType ],
+ audioCapabilities: getPossibleAudioCapabilities()
+ } ];
+}
+
+// Returns a promise that is fulfilled with true if |initDataType| is supported,
+// by keysystem or false if not.
+function isInitDataTypeSupported(keysystem,initDataType)
+{
+ return navigator.requestMediaKeySystemAccess(
+ keysystem, getSimpleConfigurationForInitDataType(initDataType))
+ .then(function() { return true; }, function() { return false; });
+}
+
+function getSupportedInitDataTypes( keysystem )
+{
+ return [ 'cenc', 'keyids', 'webm' ].filter( isInitDataTypeSupported.bind( null, keysystem ) );
+}
+
+function arrayBufferAsString(buffer)
+{
+ var array = [];
+ Array.prototype.push.apply( array, new Uint8Array( buffer ) );
+ return '0x' + array.map( function( x ) { return x < 16 ? '0'+x.toString(16) : x.toString(16); } ).join('');
+}
+
+function dumpKeyStatuses(keyStatuses,short)
+{
+ var userAgent = navigator.userAgent.toLowerCase();
+ if (userAgent.indexOf('edge') === -1) {
+ if (!short) { consoleWrite("for (var entry of keyStatuses)"); }
+ for (var entry of keyStatuses) {
+ consoleWrite(arrayBufferAsString(entry[0]) + ": " + entry[1]);
+ }
+ if (!short) {
+ consoleWrite("for (var keyId of keyStatuses.keys())");
+ for (var keyId of keyStatuses.keys()) {
+ consoleWrite(arrayBufferAsString(keyId));
+ }
+ consoleWrite("for (var status of keyStatuses.values())");
+ for (var status of keyStatuses.values()) {
+ consoleWrite(status);
+ }
+ consoleWrite("for (var entry of keyStatuses.entries())");
+ for (var entry of keyStatuses.entries()) {
+ consoleWrite(arrayBufferAsString(entry[0]) + ": " + entry[1]);
+ }
+ consoleWrite("keyStatuses.forEach()");
+ keyStatuses.forEach(function(status, keyId) {
+ consoleWrite(arrayBufferAsString(keyId) + ": " + status);
+ });
+ }
+ } else {
+ if (!short) { consoleWrite("keyStatuses.forEach()"); }
+ keyStatuses.forEach(function(keyId, status) {
+ consoleWrite(arrayBufferAsString(keyId) + ": " + status);
+ });
+ }
+}
+
+// Verify that |keyStatuses| contains just the keys in |keys.expected|
+// and none of the keys in |keys.unexpected|. All keys should have status
+// 'usable'. Example call: verifyKeyStatuses(mediaKeySession.keyStatuses,
+// { expected: [key1], unexpected: [key2] });
+function verifyKeyStatuses(keyStatuses, keys)
+{
+ var expected = keys.expected || [];
+ var unexpected = keys.unexpected || [];
+
+ // |keyStatuses| should have same size as number of |keys.expected|.
+ assert_equals(keyStatuses.size, expected.length, "keystatuses should have expected size");
+
+ // All |keys.expected| should be found.
+ expected.map(function(key) {
+ assert_true(keyStatuses.has(key), "keystatuses should have the expected keys");
+ assert_equals(keyStatuses.get(key), 'usable', "keystatus value should be 'usable'");
+ });
+
+ // All |keys.unexpected| should not be found.
+ unexpected.map(function(key) {
+ assert_false(keyStatuses.has(key), "keystatuses should not have unexpected keys");
+ assert_equals(keyStatuses.get(key), undefined, "keystatus for unexpected key should be undefined");
+ });
+}
+
+// This function checks that calling |testCase.func| returns a
+// rejected Promise with the error.name equal to
+// |testCase.exception|.
+function test_exception(testCase /*...*/) {
+ var func = testCase.func;
+ var exception = testCase.exception;
+ var args = Array.prototype.slice.call(arguments, 1);
+
+ // This should really be rewritten in terms of the promise_rejects_*
+ // testharness utility functions, but that needs the async test involved
+ // passed in, and we don't have that here.
+ return func.apply(null, args).then(
+ function (result) {
+ assert_unreached(format_value(func));
+ },
+ function (error) {
+ assert_not_equals(error.message, "", format_value(func));
+ // `exception` is a string name for the error. We can differentiate
+ // JS Errors from DOMExceptions by checking whether
+ // window[exception] exists. If it does, expectedError is the name
+ // of a JS Error subclass and window[exception] is the constructor
+ // for that subclass. Otherwise it's a name for a DOMException.
+ if (window[exception]) {
+ assert_throws_js(window[exception],
+ () => { throw error; },
+ format_value(func));
+ } else {
+ assert_throws_dom(exception,
+ () => { throw error; },
+ format_value(func));
+ }
+ }
+ );
+}
+
+// Check that the events sequence (array of strings) matches the pattern (array of either strings, or
+// arrays of strings, with the latter representing a possibly repeating sub-sequence)
+function checkEventSequence(events,pattern) {
+ function th(i) { return i + (i < 4 ? ["th", "st", "nd", "rd"][i] : "th"); }
+ var i = 0, j=0, k=0;
+ while(i < events.length && j < pattern.length) {
+ if (!Array.isArray(pattern[j])) {
+ assert_equals(events[i], pattern[j], "Expected " + th(i+1) + " event to be '" + pattern[j] + "'");
+ ++i;
+ ++j;
+ } else {
+ assert_equals(events[i], pattern[j][k], "Expected " + th(i+1) + " event to be '" + pattern[j][k] + "'");
+ ++i;
+ k = (k+1)%pattern[j].length;
+ if (k === 0 && events[i] !== pattern[j][0]) {
+ ++j;
+ }
+ }
+ }
+ assert_equals(i,events.length,"Received more events than expected");
+ assert_equals(j,pattern.length,"Expected more events than received");
+}
+
+