mirror of
https://github.com/servo/servo.git
synced 2025-08-04 05:00:08 +01:00
Update web-platform-tests to revision 9817f7f027fe1e92cc2fce31d6002c4d669918e8
This commit is contained in:
parent
8e52f8a523
commit
f3533538ea
2144 changed files with 21364 additions and 11001 deletions
|
@ -1,119 +0,0 @@
|
|||
// Encrypted Media Extensions WebIDL
|
||||
//
|
||||
// NOTE: Please update the link below to the specification version from
|
||||
// which this IDL was extracted.
|
||||
//
|
||||
// https://www.w3.org/TR/2016/WD-encrypted-media-20160610/
|
||||
// + commit 5499821932391ae2c2e53756ae7ab9fae89d5863
|
||||
//
|
||||
|
||||
partial interface Navigator {
|
||||
Promise<MediaKeySystemAccess> requestMediaKeySystemAccess (DOMString keySystem, sequence<MediaKeySystemConfiguration> supportedConfigurations);
|
||||
};
|
||||
|
||||
enum MediaKeysRequirement {
|
||||
"required",
|
||||
"optional",
|
||||
"not-allowed"
|
||||
};
|
||||
|
||||
dictionary MediaKeySystemConfiguration {
|
||||
DOMString label = "";
|
||||
sequence<DOMString> initDataTypes = [];
|
||||
sequence<MediaKeySystemMediaCapability> audioCapabilities = [];
|
||||
sequence<MediaKeySystemMediaCapability> videoCapabilities = [];
|
||||
MediaKeysRequirement distinctiveIdentifier = "optional";
|
||||
MediaKeysRequirement persistentState = "optional";
|
||||
sequence<DOMString> sessionTypes;
|
||||
};
|
||||
|
||||
dictionary MediaKeySystemMediaCapability {
|
||||
DOMString contentType = "";
|
||||
DOMString robustness = "";
|
||||
};
|
||||
|
||||
interface MediaKeySystemAccess {
|
||||
readonly attribute DOMString keySystem;
|
||||
MediaKeySystemConfiguration getConfiguration ();
|
||||
Promise<MediaKeys> createMediaKeys ();
|
||||
};
|
||||
|
||||
enum MediaKeySessionType {
|
||||
"temporary",
|
||||
"persistent-usage-record",
|
||||
"persistent-license"
|
||||
};
|
||||
|
||||
interface MediaKeys {
|
||||
MediaKeySession createSession (optional MediaKeySessionType sessionType = "temporary");
|
||||
Promise<boolean> setServerCertificate (BufferSource serverCertificate);
|
||||
};
|
||||
|
||||
interface MediaKeySession : EventTarget {
|
||||
readonly attribute DOMString sessionId;
|
||||
readonly attribute unrestricted double expiration;
|
||||
readonly attribute Promise<void> closed;
|
||||
readonly attribute MediaKeyStatusMap keyStatuses;
|
||||
attribute EventHandler onkeystatuseschange;
|
||||
attribute EventHandler onmessage;
|
||||
Promise<void> generateRequest (DOMString initDataType, BufferSource initData);
|
||||
Promise<boolean> load (DOMString sessionId);
|
||||
Promise<void> update (BufferSource response);
|
||||
Promise<void> close ();
|
||||
Promise<void> remove ();
|
||||
};
|
||||
|
||||
interface MediaKeyStatusMap {
|
||||
iterable<BufferSource,MediaKeyStatus>;
|
||||
readonly attribute unsigned long size;
|
||||
boolean has (BufferSource keyId);
|
||||
any get (BufferSource keyId);
|
||||
};
|
||||
|
||||
enum MediaKeyStatus {
|
||||
"usable",
|
||||
"expired",
|
||||
"released",
|
||||
"output-restricted",
|
||||
"output-downscaled",
|
||||
"status-pending",
|
||||
"internal-error"
|
||||
};
|
||||
|
||||
enum MediaKeyMessageType {
|
||||
"license-request",
|
||||
"license-renewal",
|
||||
"license-release",
|
||||
"individualization-request"
|
||||
};
|
||||
|
||||
[Constructor(DOMString type, MediaKeyMessageEventInit eventInitDict)]
|
||||
interface MediaKeyMessageEvent : Event {
|
||||
readonly attribute MediaKeyMessageType messageType;
|
||||
readonly attribute ArrayBuffer message;
|
||||
};
|
||||
|
||||
dictionary MediaKeyMessageEventInit : EventInit {
|
||||
required MediaKeyMessageType messageType;
|
||||
required ArrayBuffer message;
|
||||
};
|
||||
|
||||
// partial interface HTMLMediaElement : EventTarget {
|
||||
partial interface HTMLMediaElement {
|
||||
readonly attribute MediaKeys? mediaKeys;
|
||||
attribute EventHandler onencrypted;
|
||||
attribute EventHandler onwaitingforkey;
|
||||
Promise<void> setMediaKeys (MediaKeys? mediaKeys);
|
||||
};
|
||||
|
||||
[Constructor(DOMString type, optional MediaEncryptedEventInit eventInitDict)]
|
||||
interface MediaEncryptedEvent : Event {
|
||||
readonly attribute DOMString initDataType;
|
||||
readonly attribute ArrayBuffer? initData;
|
||||
};
|
||||
|
||||
dictionary MediaEncryptedEventInit : EventInit {
|
||||
DOMString initDataType = "";
|
||||
ArrayBuffer? initData = null;
|
||||
};
|
||||
|
|
@ -0,0 +1,53 @@
|
|||
<!doctype html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset=utf-8>
|
||||
<title>Encrypted Media Extensions: Successful Playback, Temporary session limited playduration, check keystatus, DRM, 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>
|
||||
<script src=/encrypted-media/util/fetch.js></script>
|
||||
<script src=/encrypted-media/util/testmediasource.js></script>
|
||||
|
||||
<!-- Content metadata -->
|
||||
<script src=/encrypted-media/content/content-metadata.js></script>
|
||||
|
||||
<!-- Message handler for DRM servers -->
|
||||
<script src=/encrypted-media/util/drm-messagehandler.js></script>
|
||||
|
||||
<!-- The script for this specific test -->
|
||||
<script src=/encrypted-media/scripts/playback-temporary-playduration-keystatus.js></script>
|
||||
|
||||
</head>
|
||||
<body>
|
||||
<div id='log'></div>
|
||||
|
||||
<div id='video'>
|
||||
<video id="videoelement" width="200px"></video>
|
||||
</div>
|
||||
|
||||
<script>
|
||||
var keysystem = getSupportedKeySystem(),
|
||||
contentitem = content['mp4-basic'],
|
||||
handler = new MessageHandler( keysystem, contentitem ),
|
||||
config = { video: document.getElementById('videoelement'),
|
||||
keysystem: keysystem,
|
||||
messagehandler: handler.messagehandler,
|
||||
audioPath: contentitem.audio.path,
|
||||
videoPath: contentitem.video.path,
|
||||
audioType: contentitem.audio.type,
|
||||
videoType: contentitem.video.type,
|
||||
initDataType: contentitem.initDataType,
|
||||
playduration: 2000,
|
||||
testcase: 'single key' };
|
||||
|
||||
runTest(config);
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
|
@ -0,0 +1,53 @@
|
|||
<!doctype html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset=utf-8>
|
||||
<title>Encrypted Media Extensions: Successful Playback, Temporary session limited playduration, DRM, 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>
|
||||
<script src=/encrypted-media/util/fetch.js></script>
|
||||
<script src=/encrypted-media/util/testmediasource.js></script>
|
||||
|
||||
<!-- Content metadata -->
|
||||
<script src=/encrypted-media/content/content-metadata.js></script>
|
||||
|
||||
<!-- Message handler for DRM servers -->
|
||||
<script src=/encrypted-media/util/drm-messagehandler.js></script>
|
||||
|
||||
<!-- The script for this specific test -->
|
||||
<script src=/encrypted-media/scripts/playback-temporary-playduration.js></script>
|
||||
|
||||
</head>
|
||||
<body>
|
||||
<div id='log'></div>
|
||||
|
||||
<div id='video'>
|
||||
<video id="videoelement" width="200px"></video>
|
||||
</div>
|
||||
|
||||
<script>
|
||||
var keysystem = getSupportedKeySystem(),
|
||||
contentitem = content['mp4-basic'],
|
||||
handler = new MessageHandler( keysystem, contentitem ),
|
||||
config = { video: document.getElementById('videoelement'),
|
||||
keysystem: keysystem,
|
||||
messagehandler: handler.messagehandler,
|
||||
audioPath: contentitem.audio.path,
|
||||
videoPath: contentitem.video.path,
|
||||
audioType: contentitem.audio.type,
|
||||
videoType: contentitem.video.type,
|
||||
initDataType: contentitem.initDataType,
|
||||
playduration: 2000,
|
||||
testcase: 'single key' };
|
||||
|
||||
runTest(config);
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
|
@ -22,7 +22,7 @@
|
|||
<script>
|
||||
setup(function() {
|
||||
|
||||
fetch( 'EncryptedMediaExtensions.idl')
|
||||
fetch( '/interfaces/encrypted-media.idl' )
|
||||
.then( function( response ) {
|
||||
if ( !response.ok ) throw new Error( 'IDL fetch failed' );
|
||||
return response.text();
|
||||
|
|
|
@ -1,4 +1,7 @@
|
|||
#!/usr/bin/python
|
||||
|
||||
from __future__ import print_function
|
||||
|
||||
import os, re, os.path, glob
|
||||
|
||||
head = re.compile( r"^(\s*</head>)", re.MULTILINE )
|
||||
|
@ -19,11 +22,11 @@ def process_file( infile, outfile ) :
|
|||
|
||||
if __name__ == '__main__' :
|
||||
if (not os.getcwd().endswith('polyfill')) :
|
||||
print "Please run from polyfill directory"
|
||||
print("Please run from polyfill directory")
|
||||
exit( 1 )
|
||||
|
||||
for infile in glob.glob( "../*.html" ) :
|
||||
process_file( infile, os.path.basename( infile ) )
|
||||
|
||||
for infile in glob.glob( "../resources/*.html" ) :
|
||||
process_file( infile, os.path.join( "resources", os.path.basename( infile ) ) )
|
||||
process_file( infile, os.path.join( "resources", os.path.basename( infile ) ) )
|
||||
|
|
|
@ -0,0 +1,78 @@
|
|||
function runTest(config,qualifier) {
|
||||
|
||||
var testname = testnamePrefix(qualifier, config.keysystem)
|
||||
+ ', temporary, '
|
||||
+ /video\/([^;]*)/.exec(config.videoType)[1]
|
||||
+ ', playback with limited playduration, check keystatus, ' + config.testcase;
|
||||
|
||||
var configuration = { initDataTypes: [ config.initDataType ],
|
||||
audioCapabilities: [ { contentType: config.audioType } ],
|
||||
videoCapabilities: [ { contentType: config.videoType } ],
|
||||
sessionTypes: [ 'temporary' ] };
|
||||
|
||||
async_test(function(test) {
|
||||
|
||||
var _video = config.video,
|
||||
_mediaKeys,
|
||||
_mediaKeySession,
|
||||
_mediaSource;
|
||||
|
||||
function onFailure(error) {
|
||||
forceTestFailureFromPromise(test, error);
|
||||
}
|
||||
|
||||
function onEncrypted(event) {
|
||||
assert_equals(event.target, _video);
|
||||
assert_true(event instanceof window.MediaEncryptedEvent);
|
||||
assert_equals(event.type, 'encrypted');
|
||||
|
||||
// Only create the session for the first encrypted event
|
||||
if (_mediaKeySession !== undefined) return;
|
||||
|
||||
var initDataType = config.initData ? config.initDataType : event.initDataType;
|
||||
var initData = config.initData || event.initData;
|
||||
|
||||
_mediaKeySession = _mediaKeys.createSession('temporary');
|
||||
waitForEventAndRunStep('message', _mediaKeySession, onMessage, test);
|
||||
_mediaKeySession.generateRequest( initDataType, initData ).catch(onFailure);
|
||||
}
|
||||
|
||||
function onMessage(event) {
|
||||
assert_equals(event.target, _mediaKeySession);
|
||||
assert_true(event instanceof window.MediaKeyMessageEvent);
|
||||
assert_equals(event.type, 'message');
|
||||
|
||||
assert_in_array(event.messageType, ['license-request', 'individualization-request']);
|
||||
|
||||
config.messagehandler(event.messageType, event.message, {playDuration: config.playduration}).then(function(response) {
|
||||
return event.target.update(response);
|
||||
}).catch(onFailure);
|
||||
}
|
||||
|
||||
function onPlaying(event) {
|
||||
waitForEventAndRunStep('keystatuseschange', _mediaKeySession, onKeystatuseschange, test);
|
||||
}
|
||||
|
||||
function onKeystatuseschange(event) {
|
||||
for (var status of event.target.keyStatuses.values()) {
|
||||
assert_equals(status, "expired", "All keys should have keyStatus expired");
|
||||
}
|
||||
test.done();
|
||||
}
|
||||
|
||||
navigator.requestMediaKeySystemAccess(config.keysystem, [configuration]).then(function(access) {
|
||||
return access.createMediaKeys();
|
||||
}).then(function(mediaKeys) {
|
||||
_mediaKeys = mediaKeys;
|
||||
return _video.setMediaKeys(_mediaKeys);
|
||||
}).then(function(){
|
||||
waitForEventAndRunStep('encrypted', _video, onEncrypted, test);
|
||||
waitForEventAndRunStep('playing', _video, onPlaying, test);
|
||||
return testmediasource(config);
|
||||
}).then(function(source) {
|
||||
_mediaSource = source;
|
||||
_video.src = URL.createObjectURL(_mediaSource);
|
||||
_video.play();
|
||||
}).catch(onFailure);
|
||||
}, testname);
|
||||
}
|
|
@ -0,0 +1,80 @@
|
|||
function runTest(config,qualifier) {
|
||||
|
||||
var testname = testnamePrefix(qualifier, config.keysystem)
|
||||
+ ', temporary, '
|
||||
+ /video\/([^;]*)/.exec(config.videoType)[1]
|
||||
+ ', playback with limited playduration, ' + config.testcase;
|
||||
|
||||
var configuration = { initDataTypes: [ config.initDataType ],
|
||||
audioCapabilities: [ { contentType: config.audioType } ],
|
||||
videoCapabilities: [ { contentType: config.videoType } ],
|
||||
sessionTypes: [ 'temporary' ] };
|
||||
|
||||
async_test(function(test) {
|
||||
|
||||
var _video = config.video,
|
||||
_mediaKeys,
|
||||
_mediaKeySession,
|
||||
_mediaSource;
|
||||
|
||||
function onFailure(error) {
|
||||
forceTestFailureFromPromise(test, error);
|
||||
}
|
||||
|
||||
function onEncrypted(event) {
|
||||
assert_equals(event.target, _video);
|
||||
assert_true(event instanceof window.MediaEncryptedEvent);
|
||||
assert_equals(event.type, 'encrypted');
|
||||
|
||||
// Only create the session for the first encrypted event
|
||||
if (_mediaKeySession !== undefined) return;
|
||||
|
||||
var initDataType = config.initData ? config.initDataType : event.initDataType;
|
||||
var initData = config.initData || event.initData;
|
||||
|
||||
_mediaKeySession = _mediaKeys.createSession('temporary');
|
||||
waitForEventAndRunStep('message', _mediaKeySession, onMessage, test);
|
||||
_mediaKeySession.generateRequest( initDataType, initData ).catch(onFailure);
|
||||
}
|
||||
|
||||
function onMessage(event) {
|
||||
assert_equals(event.target, _mediaKeySession);
|
||||
assert_true(event instanceof window.MediaKeyMessageEvent);
|
||||
assert_equals(event.type, 'message');
|
||||
|
||||
assert_in_array(event.messageType, ['license-request', 'individualization-request']);
|
||||
|
||||
config.messagehandler(event.messageType, event.message, {playDuration: config.playduration}).then(function(response) {
|
||||
return event.target.update(response);
|
||||
}).catch(onFailure);
|
||||
}
|
||||
|
||||
function onPlaying(event) {
|
||||
// Not using waitForEventAndRunStep() to avoid too many
|
||||
// EVENT(onTimeUpdate) logs.
|
||||
_video.addEventListener('timeupdate', test.step_func(onTimeupdate), true);
|
||||
test.step_timeout(function(){
|
||||
test.done();
|
||||
},config.playduration * 2);
|
||||
}
|
||||
|
||||
function onTimeupdate(event) {
|
||||
assert_less_than(_video.currentTime * 1000, config.playduration, "Video should not play for more than playDuration from licence");
|
||||
}
|
||||
|
||||
navigator.requestMediaKeySystemAccess(config.keysystem, [configuration]).then(function(access) {
|
||||
return access.createMediaKeys();
|
||||
}).then(function(mediaKeys) {
|
||||
_mediaKeys = mediaKeys;
|
||||
return _video.setMediaKeys(_mediaKeys);
|
||||
}).then(function(){
|
||||
waitForEventAndRunStep('encrypted', _video, onEncrypted, test);
|
||||
waitForEventAndRunStep('playing', _video, onPlaying, test);
|
||||
return testmediasource(config);
|
||||
}).then(function(source) {
|
||||
_mediaSource = source;
|
||||
_video.src = URL.createObjectURL(_mediaSource);
|
||||
_video.play();
|
||||
}).catch(onFailure);
|
||||
}, testname);
|
||||
}
|
|
@ -107,11 +107,14 @@ const requestConstructors = {
|
|||
outputProtection: {digital : false, analogue: false, enforce: false},
|
||||
storeLicense: (sessionType === 'persistent-license')};
|
||||
|
||||
if (!params || params.expiration === undefined) {
|
||||
if (!params || (params.expiration === undefined && params.playDuration === undefined)) {
|
||||
crt.profile = {purchase: {}};
|
||||
} else {
|
||||
crt.profile = {rental: {absoluteExpiration: (new Date(params.expiration)).toISOString(),
|
||||
playDuration: 3600000 } };
|
||||
var expiration = params.expiration || (Date.now().valueOf() + 3600000),
|
||||
playDuration = params.playDuration || 3600000;
|
||||
|
||||
crt.profile = {rental: {absoluteExpiration: (new Date(expiration)).toISOString(),
|
||||
playDuration: playDuration } };
|
||||
}
|
||||
|
||||
if (content.variantId !== undefined) {
|
||||
|
|
|
@ -173,32 +173,34 @@ function arrayBufferAsString(buffer)
|
|||
return '0x' + array.map( function( x ) { return x < 16 ? '0'+x.toString(16) : x.toString(16); } ).join('');
|
||||
}
|
||||
|
||||
function dumpKeyStatuses(keyStatuses)
|
||||
function dumpKeyStatuses(keyStatuses,short)
|
||||
{
|
||||
var userAgent = navigator.userAgent.toLowerCase();
|
||||
if (userAgent.indexOf('edge') === -1) {
|
||||
consoleWrite("for (var entry of keyStatuses)");
|
||||
if (!short) { consoleWrite("for (var entry of keyStatuses)"); }
|
||||
for (var entry of keyStatuses) {
|
||||
consoleWrite(arrayBufferAsString(entry[0]) + ": " + entry[1]);
|
||||
}
|
||||
consoleWrite("for (var keyId of keyStatuses.keys())");
|
||||
for (var keyId of keyStatuses.keys()) {
|
||||
consoleWrite(arrayBufferAsString(keyId));
|
||||
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);
|
||||
});
|
||||
}
|
||||
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 {
|
||||
consoleWrite("keyStatuses.forEach()");
|
||||
if (!short) { consoleWrite("keyStatuses.forEach()"); }
|
||||
keyStatuses.forEach(function(keyId, status) {
|
||||
consoleWrite(arrayBufferAsString(keyId) + ": " + status);
|
||||
});
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue