Bug 1121332. Part 5 - update EME mochitests for webidl changes. r=cpearce.

This commit is contained in:
JW Wang 2015-01-31 13:23:19 +13:00
Родитель 437228dab0
Коммит 3195a43be9
2 изменённых файлов: 24 добавлений и 21 удалений

Просмотреть файл

@ -31,14 +31,17 @@ function UsableKeyIdsMatch(usableKeyIds, expectedKeyIds) {
function AwaitAllKeysUsable(session, keys, token) {
return new Promise(function(resolve, reject) {
function listener(event) {
session.getUsableKeyIds().then(function(usableKeyIds) {
var u = UsableKeyIdsMatch(usableKeyIds, keys);
if (UsableKeyIdsMatch(usableKeyIds, keys)) {
Log(token, "resolving AwaitAllKeysUsable promise");
session.removeEventListener("keyschange", listener);
resolve();
}
}, bail(token + " failed to get usableKeyIds"));
var map = session.keyStatuses;
var usableKeyIds = [];
for (var [key, val] of map.entries()) {
is(val, "usable", token + ": key status should be usable");
usableKeyIds.push(key);
}
if (UsableKeyIdsMatch(usableKeyIds, keys)) {
Log(token, "resolving AwaitAllKeysUsable promise");
session.removeEventListener("keyschange", listener);
resolve();
}
}
session.addEventListener("keyschange", listener);
});
@ -47,12 +50,11 @@ function AwaitAllKeysUsable(session, keys, token) {
function AwaitAllKeysNotUsable(session, token) {
return new Promise(function(resolve, reject) {
function listener(event) {
session.getUsableKeyIds().then(function(usableKeyIds) {
if (usableKeyIds.length == 0) {
session.removeEventListener("keyschange", listener);
resolve();
}
}, bail(token + " failed to get usableKeyIds"));
var map = session.keyStatuses;
if (map.size == 0) {
session.removeEventListener("keyschange", listener);
resolve();
}
}
session.addEventListener("keyschange", listener);
});

Просмотреть файл

@ -22,13 +22,14 @@ function KeysChangeFunc(session, keys, token) {
return function(ev) {
var session = ev.target;
session.gotKeysChanged = true;
session.getUsableKeyIds().then(function(keyIds) {
for (var k = 0; k < keyIds.length; k++) {
var kid = Base64ToHex(window.btoa(ArrayBufferToString(keyIds[k])));
ok(kid in session.keyIdsReceived, TimeStamp(token) + " session.keyIdsReceived contained " + kid + " as expected.");
session.keyIdsReceived[kid] = true;
}
}, bail("Failed to get keyIds"));
var map = session.keyStatuses;
for (var [key, val] of map.entries()) {
is(val, "usable", token + ": key status should be usable");
var kid = Base64ToHex(window.btoa(ArrayBufferToString(key)));
ok(kid in session.keyIdsReceived, TimeStamp(token) + " session.keyIdsReceived contained " + kid + " as expected.");
session.keyIdsReceived[kid] = true;
}
}
}