summaryrefslogtreecommitdiffstats
path: root/dom/media/test/test_eme_waitingforkey.html
diff options
context:
space:
mode:
authorMatt A. Tobin <mattatobin@localhost.localdomain>2018-02-02 04:16:08 -0500
committerMatt A. Tobin <mattatobin@localhost.localdomain>2018-02-02 04:16:08 -0500
commit5f8de423f190bbb79a62f804151bc24824fa32d8 (patch)
tree10027f336435511475e392454359edea8e25895d /dom/media/test/test_eme_waitingforkey.html
parent49ee0794b5d912db1f95dce6eb52d781dc210db5 (diff)
downloadUXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.gz
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.lz
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.xz
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.zip
Add m-esr52 at 52.6.0
Diffstat (limited to 'dom/media/test/test_eme_waitingforkey.html')
-rw-r--r--dom/media/test/test_eme_waitingforkey.html117
1 files changed, 117 insertions, 0 deletions
diff --git a/dom/media/test/test_eme_waitingforkey.html b/dom/media/test/test_eme_waitingforkey.html
new file mode 100644
index 000000000..ce808342b
--- /dev/null
+++ b/dom/media/test/test_eme_waitingforkey.html
@@ -0,0 +1,117 @@
+<!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="http://test1.mochi.test:8888/tests/dom/media/test/eme.js"></script>
+</head>
+<body>
+<pre id="test">
+<script class="testbody" type="text/javascript">
+var manager = new MediaTestManager;
+
+function startTest(test, token)
+{
+ // Test if the appropriate preconditions are met such that we can start
+ // prcoessing delayed sessions.
+ function TestIfDoneDelaying()
+ {
+ var got = "Got:";
+ if (loaded) { got += " loaded,"; }
+ got += " " + gotEncrypted + "/" + test.sessionCount + " sessions,";
+ got += " " + gotWaitingForKey + " waiting for key events"
+ if (loaded && gotEncrypted == test.sessionCount && gotWaitingForKey > 0) {
+ Log(token, got + " -> Update sessions with keys");
+ params.ProcessSessions();
+ } else {
+ Log(token, got + " -> Wait for more...");
+ }
+ }
+
+ manager.started(token);
+
+ var updatedSessionsCount = 0;
+ var loaded = false;
+
+ var params = {
+ // params will be populated with a ProcessSessions() callback, that can be
+ // called to process delayed sessions.
+ delaySessions: true,
+ // Function to be called once we start processing and updating sessions.
+ // This should only be called once the preconditions in TestIfDoneDealying
+ // are met.
+ onsessionupdated: function(session) {
+ updatedSessionsCount += 1;
+ if (updatedSessionsCount == test.sessionCount) {
+ info(TimeStamp(token) + " Updated all sessions, loading complete -> Play");
+ v.play();
+ } else {
+ info(TimeStamp(token) + " Updated " + updatedSessionsCount + "/" + test.sessionCount + " sessions so far");
+ }
+ },
+ };
+ var v = SetupEME(test, token, params);
+
+ document.body.appendChild(v);
+
+ var gotEncrypted = 0;
+ var gotWaitingForKey = 0;
+ var gotOnwaitingforkey = 0;
+
+ v.addEventListener("encrypted", function() {
+ gotEncrypted += 1;
+ TestIfDoneDelaying();
+ });
+
+ v.addEventListener("waitingforkey", function() {
+ gotWaitingForKey += 1;
+ TestIfDoneDelaying()
+ });
+
+ v.onwaitingforkey = function() {
+ gotOnwaitingforkey += 1;
+ };
+
+ v.addEventListener("loadedmetadata", function() {
+ ok(SpecialPowers.do_lookupGetter(v, "isEncrypted").apply(v),
+ TimeStamp(token) + " isEncrypted should be true");
+ is(v.isEncrypted, undefined, "isEncrypted should not be accessible from content");
+ });
+
+ v.addEventListener("ended", function() {
+ ok(true, TimeStamp(token) + " got ended event");
+ // We expect only one waitingForKey as we delay until all sessions are ready.
+ // I.e. one waitingForKey should be fired, after which, we process all sessions,
+ // so it should not be possible to be blocked by a key after that point.
+ ok(gotWaitingForKey == 1, "Expected number 1 wait, got: " + gotWaitingForKey);
+ ok(gotOnwaitingforkey == gotWaitingForKey, "Should have as many event listener calls as event handler calls, got: " + gotOnwaitingforkey);
+
+ v.closeSessions().then(() => manager.finished(token));
+ });
+
+ LoadTest(test, v, token)
+ .then(function() {
+ loaded = true;
+ TestIfDoneDelaying();
+ }).catch(function() {
+ ok(false, token + " failed to load");
+ manager.finished(token);
+ });
+}
+
+function beginTest() {
+ manager.runTests(gEMETests, startTest);
+}
+
+if (!IsMacOSSnowLeopardOrEarlier()) {
+ SimpleTest.waitForExplicitFinish();
+ SetupEMEPref(beginTest);
+} else {
+ todo(false, "Test disabled on this platform.");
+}
+</script>
+</pre>
+</body>
+</html>