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

Unified Diff: third_party/WebKit/LayoutTests/imported/wpt/encrypted-media/scripts/events-session-closed-event.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/events-session-closed-event.js
diff --git a/third_party/WebKit/LayoutTests/imported/wpt/encrypted-media/scripts/events-session-closed-event.js b/third_party/WebKit/LayoutTests/imported/wpt/encrypted-media/scripts/events-session-closed-event.js
new file mode 100644
index 0000000000000000000000000000000000000000..44f683eac854b1f0fea6a845c0ea841e84eb5c26
--- /dev/null
+++ b/third_party/WebKit/LayoutTests/imported/wpt/encrypted-media/scripts/events-session-closed-event.js
@@ -0,0 +1,52 @@
+function runTest(config, qualifier)
+{
+ var testname = testnamePrefix(qualifier, config.keysystem) + ' test MediaKeySession closed event.';
+
+ var configuration = {
+ initDataTypes: [config.initDataType],
+ audioCapabilities: [{
+ contentType: config.audioType
+ }],
+ videoCapabilities: [{
+ contentType: config.videoType
+ }],
+ sessionTypes: ['temporary']
+ };
+
+ promise_test(function (test) {
+ var initDataType;
+ var initData;
+ var mediaKeySession;
+
+ return navigator.requestMediaKeySystemAccess(config.keysystem, [configuration]).then(function (access) {
+ initDataType = access.getConfiguration().initDataTypes[0];
+ return access.createMediaKeys();
+ }).then(function (mediaKeys) {
+ mediaKeySession = mediaKeys.createSession();
+ if(config.initData) {
+ initData = config.initData;
+ } else {
+ initData = stringToUint8Array(atob(config.content.keys[0].initData));
+ }
+ return mediaKeySession.generateRequest(initDataType, initData);
+ }).then(function() {
+ // close() should result in the closed promise being
+ // fulfilled.
+ return mediaKeySession.close();
+ }).then(function (result) {
+ assert_equals(result, undefined);
+ // Wait for the session to be closed.
+ return mediaKeySession.closed;
+ }).then(function (result) {
+ assert_equals(result, undefined);
+ // Now that the session is closed, verify that the
+ // closed attribute immediately returns a fulfilled
+ // promise.
+ return mediaKeySession.closed;
+ }).then(function (result) {
+ assert_equals(result, undefined);
+ }).catch(function(error) {
+ assert_unreached('Error: ' + error.name);
+ });
+ }, testname);
+}

Powered by Google App Engine
This is Rietveld 408576698