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

Unified Diff: third_party/WebKit/LayoutTests/imported/wpt/encrypted-media/scripts/reset-src-after-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/reset-src-after-setmediakeys.js
diff --git a/third_party/WebKit/LayoutTests/imported/wpt/encrypted-media/scripts/reset-src-after-setmediakeys.js b/third_party/WebKit/LayoutTests/imported/wpt/encrypted-media/scripts/reset-src-after-setmediakeys.js
new file mode 100644
index 0000000000000000000000000000000000000000..acddd8dd5f451e567728c3a379da60f13ee32348
--- /dev/null
+++ b/third_party/WebKit/LayoutTests/imported/wpt/encrypted-media/scripts/reset-src-after-setmediakeys.js
@@ -0,0 +1,61 @@
+function runTest(config)
+{
+ async_test(function(test) {
+ var mediaKeys;
+ var mediaSource;
+ var encryptedEventIndex = 0;
+ var video = config.video;
+ var keysystem = config.keysystem;
+ var configuration = {
+ initDataTypes: [config.initDataType],
+ audioCapabilities: [{
+ contentType: config.audioType
+ }],
+ videoCapabilities: [{
+ contentType: config.videoType
+ }],
+ sessionTypes: ['temporary']
+ };
+
+ assert_not_equals(video, null);
+
+ var onEncrypted = function(event) {
+ ++encryptedEventIndex;
+ assert_equals(video.mediaKeys, mediaKeys);
+
+ // This event is fired once for the audio stream and once
+ // for the video stream each time .src is set.
+ if (encryptedEventIndex === 2) {
+ // Finished first video; Create new media source and wait for two more encrypted events
+ return testmediasource(config).then(function (source) {
+ video.src = URL.createObjectURL(source);
+ }).catch(function (error) {
+ forceTestFailureFromPromise(test, error)
+ });
+ } else if (encryptedEventIndex === 4) {
+ // Finished second video.
+ test.done();
+ }
+ };
+
+ // Create a MediaKeys object and assign it to video.
+ return navigator.requestMediaKeySystemAccess(keysystem, [configuration]).then(test.step_func(function (access) {
+ assert_equals(access.keySystem, keysystem);
+ return access.createMediaKeys();
+ })).then(test.step_func(function (result) {
+ mediaKeys = result;
+ assert_not_equals(mediaKeys, null);
+ return video.setMediaKeys(mediaKeys);
+ })).then(test.step_func(function () {
+ assert_equals(video.mediaKeys, mediaKeys);
+ return testmediasource(config);
+ })).then(function (source) {
+ waitForEventAndRunStep('encrypted', video, onEncrypted, test);
+ mediaSource = source;
+ video.src = URL.createObjectURL(mediaSource);
+ }).catch(function (error) {
+ forceTestFailureFromPromise(test, error);
+ });
+
+ }, 'Reset src after setMediaKeys().');
+}

Powered by Google App Engine
This is Rietveld 408576698