Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(29)

Unified Diff: third_party/WebKit/LayoutTests/imported/wpt/encrypted-media/scripts/setmediakeys.js

Issue 2546853003: Add W3C encrypted-media tests (Closed)
Patch Set: rebase now that content files landed Created 4 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/LayoutTests/imported/wpt/encrypted-media/scripts/setmediakeys.js
diff --git a/third_party/WebKit/LayoutTests/imported/wpt/encrypted-media/scripts/setmediakeys.js b/third_party/WebKit/LayoutTests/imported/wpt/encrypted-media/scripts/setmediakeys.js
new file mode 100644
index 0000000000000000000000000000000000000000..f161e6712fd09c43b6659021c33554ba6680a775
--- /dev/null
+++ b/third_party/WebKit/LayoutTests/imported/wpt/encrypted-media/scripts/setmediakeys.js
@@ -0,0 +1,49 @@
+function runTest(config, qualifier) {
+ var testname = testnamePrefix( qualifier, config.keysystem )
+ + ', setMediaKeys';
+
+ var configuration = getSimpleConfigurationForContent( config.content );
+
+ if ( config.initDataType && config.initData ) {
+ configuration.initDataTypes = [ config.initDataType ];
+ }
+
+ async_test (function (test) {
+ var _video = config.video,
+ _mediaKeys;
+
+ // Test MediaKeys assignment.
+ assert_equals(_video.mediaKeys, null);
+ assert_equals(typeof _video.setMediaKeys, 'function');
+
+ function onFailure(error) {
+ forceTestFailureFromPromise(test, error);
+ }
+
+ // Try setting mediaKeys to null.
+ _video.setMediaKeys(null).then(function(result) {
+ assert_equals(_video.mediaKeys, null);
+
+ // setMediaKeys should fail when setting to the wrong type of object - Date.
+ return _video.setMediaKeys(new Date());
+ }).then(function (result) {
+ assert_unreached('setMediaKeys should fail when setting to wrong kind of object (Date)');
+ }, function(error) {
+ // The error should be TypeError.
+ assert_equals(error.name, 'TypeError', 'setMediaKeys should return a TypeError when setting to wrong kind of object (Date)');
+ return navigator.requestMediaKeySystemAccess(config.keysystem, [configuration]);
+ }).then(function(access) {
+ assert_equals(access.keySystem, config.keysystem)
+ return access.createMediaKeys();
+ }).then(function(result) {
+ _mediaKeys = result;
+ assert_not_equals(_mediaKeys, null);
+ assert_equals(typeof _mediaKeys.createSession, 'function');
+ return _video.setMediaKeys(_mediaKeys);
+ }).then(function(result) {
+ assert_not_equals(_video.mediaKeys, null);
+ assert_equals(_video.mediaKeys, _mediaKeys);
+ test.done();
+ }).catch(onFailure);
+ }, testname);
+}

Powered by Google App Engine
This is Rietveld 408576698