зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1179521 - [EME] Replace test_eme_obs_notification.html with test for mediakeys-request notification. r=gerald
This commit is contained in:
Родитель
cfc2efb3e7
Коммит
8580f40510
|
@ -349,6 +349,7 @@ MediaKeySystemAccess::NotifyObservers(nsIDOMWindow* aWindow,
|
|||
data.mStatus = aStatus;
|
||||
nsAutoString json;
|
||||
data.ToJSON(json);
|
||||
EME_LOG("MediaKeySystemAccess::NotifyObservers() %s", NS_ConvertUTF16toUTF8(json).get());
|
||||
nsCOMPtr<nsIObserverService> obs = services::GetObserverService();
|
||||
if (obs) {
|
||||
obs->NotifyObservers(aWindow, "mediakeys-request", json.get());
|
||||
|
|
|
@ -618,11 +618,8 @@ skip-if = (os == 'win' && os_version == '5.1') || (os != 'win' && toolkit != 'go
|
|||
skip-if = toolkit == 'android' || (os == 'win' && !debug) # bug 1043403, bug 1140675
|
||||
[test_eme_non_mse_fails.html]
|
||||
skip-if = toolkit == 'android' # bug 1043403
|
||||
#[test_eme_obs_notification.html]
|
||||
#skip-if = buildapp == 'b2g' || toolkit == 'android' # bug 1043403
|
||||
# Disabled (bug 1140778) since this test fails and we don't want to remove the
|
||||
# functionality being tested by this test. We should still test other observers
|
||||
# in future however, so I'm not removing the test, just disabling it.
|
||||
[test_eme_request_notifications.html]
|
||||
skip-if = toolkit == 'android' # bug 1043403
|
||||
[test_eme_persistent_sessions.html]
|
||||
skip-if = toolkit == 'android' # bug 1043403
|
||||
[test_eme_playback.html]
|
||||
|
|
|
@ -1,68 +0,0 @@
|
|||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<head>
|
||||
<title>Test Encrypted Media Extensions</title>
|
||||
<script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
|
||||
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
|
||||
<script type="text/javascript" src="manifest.js"></script>
|
||||
<script type="text/javascript" src="eme.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
<pre id="test">
|
||||
<script class="testbody" type="text/javascript">
|
||||
var manager = new MediaTestManager;
|
||||
|
||||
var videos = new Set();
|
||||
var observedVideos = new Set();
|
||||
|
||||
var observer = function(subject) {
|
||||
ok(videos.has(subject), "Video should be known to us");
|
||||
videos.delete(subject);
|
||||
observedVideos.add(subject);
|
||||
};
|
||||
SpecialPowers.Services.obs.addObserver(observer, "media-eme-metadataloaded", false);
|
||||
|
||||
// When the test manager finishes, these sets should all be empty again:
|
||||
manager.onFinished = function() {
|
||||
is(videos.size, 0, "video set should be empty");
|
||||
is(observedVideos.size, 0, "observed video set should be empty");
|
||||
};
|
||||
|
||||
// ... but even if they're not, we should clear them out when we finish:
|
||||
SimpleTest.registerCleanupFunction(function() {
|
||||
SpecialPowers.Services.obs.removeObserver(observer, "media-eme-metadataloaded");
|
||||
videos.clear();
|
||||
observedVideos.clear();
|
||||
});
|
||||
|
||||
function startTest(test, token)
|
||||
{
|
||||
manager.started(token);
|
||||
|
||||
var sessions = [];
|
||||
|
||||
var v = SetupEME(test, token);
|
||||
videos.add(v);
|
||||
v.preload = "auto"; // Required due to "canplay" not firing for MSE unless we do this.
|
||||
|
||||
v.addEventListener("loadeddata", function(ev) {
|
||||
ok(observedVideos.has(ev.target), "Should have been told about eme video through observer as well.");
|
||||
observedVideos.delete(ev.target);
|
||||
manager.finished(token);
|
||||
});
|
||||
|
||||
LoadTestWithManagedLoadToken(test, v, manager, token,
|
||||
{ onlyLoadFirstFragments:2, noEndOfStream:true });
|
||||
}
|
||||
|
||||
function beginTest() {
|
||||
manager.runTests(gEMETests, startTest);
|
||||
}
|
||||
|
||||
SimpleTest.waitForExplicitFinish();
|
||||
SetupEMEPref(beginTest);
|
||||
</script>
|
||||
</pre>
|
||||
</body>
|
||||
</html>
|
||||
|
|
@ -0,0 +1,109 @@
|
|||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<head>
|
||||
<title>Test Encrypted Media Extensions</title>
|
||||
<script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
|
||||
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
|
||||
<script type="text/javascript" src="manifest.js"></script>
|
||||
<script type="text/javascript" src="eme.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
<pre id="test">
|
||||
<script class="testbody" type="text/javascript">
|
||||
var manager = new MediaTestManager;
|
||||
|
||||
var observedStatus = "nothing";
|
||||
|
||||
var observer = function(subject, topic, data) {
|
||||
observedStatus = JSON.parse(data).status;
|
||||
info("Observed: " + observedStatus);
|
||||
};
|
||||
SpecialPowers.Services.obs.addObserver(observer, "mediakeys-request", false);
|
||||
|
||||
SimpleTest.registerCleanupFunction(function() {
|
||||
SpecialPowers.Services.obs.removeObserver(observer, "mediakeys-request");
|
||||
});
|
||||
|
||||
function SetPrefs(prefs) {
|
||||
return new Promise(function(resolve, reject) {
|
||||
SpecialPowers.pushPrefEnv({"set": prefs}, function() { resolve(); });
|
||||
});
|
||||
}
|
||||
|
||||
function Test(test) {
|
||||
var p = test.prefs ? SetPrefs(test.prefs) : Promise.resolve();
|
||||
observedStatus = "nothing";
|
||||
var name = "'" + test.keySystem + "'";
|
||||
return p.then(function() {
|
||||
return new Promise(function(resolve, reject) {
|
||||
navigator.requestMediaKeySystemAccess(test.keySystem)
|
||||
.then(
|
||||
function(keySystemAccess) {
|
||||
return keySystemAccess.createMediaKeys();
|
||||
})
|
||||
.then(
|
||||
function(mediaKeys) {
|
||||
ok(test.shouldPass, name + " passed and was expected to " + (test.shouldPass ? "pass" : "fail"));
|
||||
is(observedStatus, test.expectedStatus, name + " observer service result");
|
||||
resolve();
|
||||
}
|
||||
)
|
||||
.catch(
|
||||
function() {
|
||||
ok(!test.shouldPass, name + " failed and was expected to " + (test.shouldPass ? "pass" : "fail"));
|
||||
is(observedStatus, test.expectedStatus, name + " observer service result");
|
||||
resolve();
|
||||
}
|
||||
);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
const CLEARKEY_ID = 'org.w3.clearkey';
|
||||
|
||||
var tests = [
|
||||
{
|
||||
keySystem: CLEARKEY_ID,
|
||||
shouldPass: false,
|
||||
expectedStatus: 'api-disabled',
|
||||
prefs: [["media.eme.enabled", false], ["media.eme.clearkey.enabled", true]]
|
||||
},
|
||||
{
|
||||
keySystem: CLEARKEY_ID,
|
||||
shouldPass: false,
|
||||
expectedStatus: 'cdm-disabled',
|
||||
prefs: [["media.eme.enabled", true], ["media.eme.clearkey.enabled", false]]
|
||||
},
|
||||
{
|
||||
keySystem: 'unsupported-keysystem',
|
||||
shouldPass: false,
|
||||
expectedStatus: 'cdm-not-supported'
|
||||
},
|
||||
{
|
||||
keySystem: CLEARKEY_ID + '.10000' , // A stupendously high min CDM version, presumably not installed.
|
||||
shouldPass: false,
|
||||
expectedStatus: 'cdm-insufficient-version',
|
||||
prefs: [["media.eme.enabled", true], ["media.eme.clearkey.enabled", true]]
|
||||
},
|
||||
{
|
||||
keySystem: CLEARKEY_ID,
|
||||
shouldPass: true,
|
||||
expectedStatus: 'cdm-created',
|
||||
prefs: [["media.eme.enabled", true], ["media.eme.clearkey.enabled", true]]
|
||||
},
|
||||
];
|
||||
|
||||
SetupEMEPref(function() {
|
||||
tests.reduce(function(p,c,i,array) {
|
||||
return p.then(function() { return Test(c); });
|
||||
}, Promise.resolve()).then(SimpleTest.finish);
|
||||
});
|
||||
|
||||
|
||||
SimpleTest.waitForExplicitFinish();
|
||||
|
||||
</script>
|
||||
</pre>
|
||||
</body>
|
||||
</html>
|
||||
|
Загрузка…
Ссылка в новой задаче