2009-03-09 00:02:14 +03:00
|
|
|
<!DOCTYPE HTML>
|
|
|
|
<html>
|
|
|
|
<!--
|
|
|
|
https://bugzilla.mozilla.org/show_bug.cgi?id=478957
|
|
|
|
-->
|
|
|
|
<head>
|
|
|
|
<title>Test for Bug 478957</title>
|
2019-04-16 06:53:28 +03:00
|
|
|
<script src="/tests/SimpleTest/SimpleTest.js"></script>
|
2009-03-09 00:02:14 +03:00
|
|
|
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
|
2010-05-31 02:02:06 +04:00
|
|
|
<script type="text/javascript" src="manifest.js"></script>
|
2009-03-09 00:02:14 +03:00
|
|
|
</head>
|
|
|
|
<body>
|
|
|
|
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=478957">Mozilla Bug 478957</a>
|
|
|
|
<p id="display"></p>
|
|
|
|
<div id="content" style="display: none">
|
2019-10-24 13:51:10 +03:00
|
|
|
|
2009-03-09 00:02:14 +03:00
|
|
|
</div>
|
|
|
|
|
|
|
|
<div id="log" style="font-size: small;"></div>
|
|
|
|
|
|
|
|
<pre id="test">
|
|
|
|
<script type="application/javascript">
|
|
|
|
|
|
|
|
/** Test for Bug 478957 **/
|
|
|
|
|
|
|
|
// Tests whether we leak events and state change info when loading stuff from local files from a webserver.
|
|
|
|
|
2011-04-01 02:10:48 +04:00
|
|
|
var manager = new MediaTestManager;
|
2009-03-09 00:02:14 +03:00
|
|
|
|
2009-10-09 15:48:33 +04:00
|
|
|
var gEventTypes = [ 'loadstart', 'progress', 'suspend', 'abort', 'error', 'emptied', 'stalled', 'play', 'pause', 'loadedmetadata', 'loadeddata', 'waiting', 'playing', 'canplay', 'canplaythrough', 'seeking', 'seeked', 'timeupdate', 'ended', 'ratechange', 'durationchange', 'volumechange' ];
|
2009-03-09 00:02:14 +03:00
|
|
|
|
2017-08-24 12:41:15 +03:00
|
|
|
var gExpectedEvents = ['loadstart', 'error'];
|
2011-04-01 02:10:48 +04:00
|
|
|
|
|
|
|
function createTestArray() {
|
|
|
|
var tests = [];
|
|
|
|
var tmpVid = document.createElement("video");
|
|
|
|
|
2017-11-20 20:44:59 +03:00
|
|
|
return makeInfoLeakTests().then(infoLeakTests => {
|
|
|
|
for (var testNum=0; testNum < infoLeakTests.length; testNum++) {
|
|
|
|
var test = infoLeakTests[testNum];
|
|
|
|
if (!tmpVid.canPlayType(test.type)) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2019-10-24 13:51:10 +03:00
|
|
|
var t = {};
|
2017-11-20 20:44:59 +03:00
|
|
|
t.name = test.src;
|
|
|
|
t.type = test.type;
|
|
|
|
|
|
|
|
tests.push(t);
|
2011-04-01 02:10:48 +04:00
|
|
|
}
|
2017-11-20 20:44:59 +03:00
|
|
|
return tests;
|
|
|
|
})
|
2011-04-01 02:10:48 +04:00
|
|
|
}
|
2009-03-09 00:02:14 +03:00
|
|
|
|
|
|
|
function log(msg) {
|
2015-01-14 00:40:00 +03:00
|
|
|
info(msg);
|
2009-03-09 00:02:14 +03:00
|
|
|
var l = document.getElementById('log');
|
2019-10-24 13:51:10 +03:00
|
|
|
// eslint-disable-next-line no-unsanitized/property
|
2009-03-09 00:02:14 +03:00
|
|
|
l.innerHTML += msg + "<br>";
|
|
|
|
}
|
|
|
|
|
2011-04-01 02:10:48 +04:00
|
|
|
function finish(v) {
|
|
|
|
log("finish: " + v.name);
|
|
|
|
clearInterval(v.checkStateInterval);
|
2014-06-16 22:17:00 +04:00
|
|
|
|
|
|
|
for (var i=0; i<gEventTypes.length; i++) {
|
2017-01-17 13:50:25 +03:00
|
|
|
v.removeEventListener(gEventTypes[i], listener);
|
2014-06-16 22:17:00 +04:00
|
|
|
}
|
|
|
|
removeNodeAndSource(v);
|
|
|
|
|
2011-04-01 02:10:48 +04:00
|
|
|
manager.finished(v.token);
|
|
|
|
v = null;
|
2009-03-09 00:02:14 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
function listener(evt) {
|
2011-04-01 02:10:48 +04:00
|
|
|
var v = evt.target;
|
2015-01-14 00:40:00 +03:00
|
|
|
log(filename(v.name) + ': got ' + evt.type);
|
|
|
|
|
|
|
|
// On slow machines like B2G emulator, progress timer could time out before
|
|
|
|
// receiving any HTTP notification. We will ignore the 'stalled' event to
|
|
|
|
// pass the tests.
|
|
|
|
if (evt.type == 'stalled') {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2011-04-01 02:10:48 +04:00
|
|
|
ok(v.eventNum < gExpectedEvents.length, filename(v.name) + " Too many events received");
|
|
|
|
var expected = (v.eventNum < gExpectedEvents.length) ? gExpectedEvents[v.eventNum] : "NoEvent";
|
|
|
|
is(evt.type, expected, filename(v.name) + " Events received in wrong order");
|
|
|
|
v.eventNum++;
|
|
|
|
if (v.eventNum == gExpectedEvents.length) {
|
2009-03-09 00:02:14 +03:00
|
|
|
// In one second, move onto the next test. This give a chance for any
|
|
|
|
// other events to come in. Note: we don't expect any events to come
|
|
|
|
// in, unless we've leaked some info, and 1 second should be enough time
|
|
|
|
// for the leak to show up.
|
2019-10-24 13:51:10 +03:00
|
|
|
setTimeout(function() {finish(v);}, 1000);
|
2009-03-09 00:02:14 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-04-01 02:10:48 +04:00
|
|
|
function createMedia(type, src, token) {
|
2015-01-13 12:53:22 +03:00
|
|
|
var tag = getMajorMimeType(type);
|
2011-04-01 02:10:48 +04:00
|
|
|
var v = document.createElement(tag);
|
2009-03-09 00:02:14 +03:00
|
|
|
for (var i=0; i<gEventTypes.length; i++) {
|
2017-01-17 13:50:25 +03:00
|
|
|
v.addEventListener(gEventTypes[i], listener);
|
2009-03-09 00:02:14 +03:00
|
|
|
}
|
2014-06-16 22:17:00 +04:00
|
|
|
v.preload = "metadata";
|
2011-04-01 02:10:48 +04:00
|
|
|
v.src = src;
|
|
|
|
v.name = src;
|
|
|
|
document.body.appendChild(v);
|
|
|
|
v.eventNum = 0;
|
|
|
|
v.token = token;
|
|
|
|
setTimeout(
|
|
|
|
function() {
|
|
|
|
v.checkStateInterval = setInterval(function(){checkState(v);},1);
|
|
|
|
}, 0);
|
2009-03-09 00:02:14 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
// Define our own ok() and is() functions. The mochitest ones take ages constructing the log
|
|
|
|
// of all the passes, so only report failures.
|
|
|
|
function test_ok(b, msg) {
|
|
|
|
if (!b) {
|
|
|
|
log("FAILED test_ok: " + msg);
|
|
|
|
ok(b, msg);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
function test_is(a, b, msg) {
|
|
|
|
if (a != b) {
|
|
|
|
log("FAILED test_is: " + msg);
|
|
|
|
is(a,b,msg);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-09-03 04:03:03 +04:00
|
|
|
function filename(uri) {
|
|
|
|
return uri.substr(uri.lastIndexOf("/")+1);
|
|
|
|
}
|
|
|
|
|
2011-04-01 02:10:48 +04:00
|
|
|
function checkState(v) {
|
2019-10-24 13:51:10 +03:00
|
|
|
test_ok(v.networkState <= HTMLMediaElement.NETWORK_LOADING ||
|
2011-04-01 02:10:48 +04:00
|
|
|
v.networkState == HTMLMediaElement.NETWORK_NO_SOURCE,
|
|
|
|
"NetworkState of " + v.networkState + " was leaked.");
|
|
|
|
test_ok(v.readyState == HTMLMediaElement.HAVE_NOTHING,
|
|
|
|
"Ready state of " + v.readyState + " was leaked");
|
|
|
|
test_is(v.seeking, false, "Seeking leaked");
|
|
|
|
test_is(v.currentTime, 0, "Leaked currentTime");
|
|
|
|
test_ok(isNaN(v.duration), "Leaked duration");
|
|
|
|
test_is(v.paused, true, "Paused leaked");
|
|
|
|
test_is(v.ended, false, "Ended leaked");
|
|
|
|
test_is(v.autoplay, false, "Autoplay leaked");
|
|
|
|
test_is(v.controls, false, "Controls leaked");
|
|
|
|
test_is(v.muted, false, "muted leaked");
|
|
|
|
test_ok(v.error==null || v.error.code==MediaError.MEDIA_ERR_SRC_NOT_SUPPORTED,
|
|
|
|
"Error code should not exist or be SRC_NOT_SUPPORTED. v.error=" +
|
|
|
|
(v.error ? v.error.code : "null"));
|
|
|
|
test_ok(filename(v.currentSrc) == filename(v.name) ||
|
|
|
|
v.networkState == HTMLMediaElement.NETWORK_NO_SOURCE,
|
|
|
|
"currentSrc should match candidate uri, if we've got a valid source");
|
2009-03-09 00:02:14 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-04-01 02:10:48 +04:00
|
|
|
function startTest(test, token) {
|
|
|
|
manager.started(token);
|
|
|
|
log("Testing: " + test.type + " @ " + test.name);
|
2019-10-24 13:51:10 +03:00
|
|
|
createMedia(test.type, test.name, token);
|
2009-03-09 00:02:14 +03:00
|
|
|
}
|
|
|
|
|
Bug 1541557: Part 5 - Update callers of ChromeScript.sendSyncMessage to use sendQuery instead. r=nika
Since JSWindowActors don't have direct access to synchronous messaging,
ChromeScript callers are going to need to migrate to asynchronous messaging
and queries instead.
Since there's no comparable API to sendQuery for frame message managers, this
patch adds a stub that uses synchronous messaging, but makes the API appear
asynchronous, and migrates callers to use it instead of direct synchronous
messaging. This will be replaced with a true synchronous API in the actor
migration.
Fortunately, most of the time, this actually leads to simpler code. The
`sendQuery` API doesn't have the odd return value semantics of
`sendSyncMessage`, and can usually just be used as a drop-in replacement. Many
of the `sendSyncMessage` callers don't actually use the result, and can just
be changed to `sendAsyncMessage`. And many of the existing async messaging
users can be changed to just use `sendQuery` rather than sending messages and
adding response listeners.
However, the APZ code is an exception. It relies on intricate properties of
the event loop, and doesn't have an easy way to slot in promise handlers, so I
migrated it to using sync messaging via process message managers instead.
Differential Revision: https://phabricator.services.mozilla.com/D35055
--HG--
extra : rebase_source : d5707e87f293a831a5cf2e0b0a7e977090267f78
extra : source : 75ebd6fce136ab3bd0e591c2b8b2d06d3b5bf923
2019-06-12 22:40:51 +03:00
|
|
|
SimpleTest.waitForExplicitFinish();
|
2017-11-20 20:44:59 +03:00
|
|
|
createTestArray().then(testArray => {
|
|
|
|
manager.runTests(testArray, startTest);
|
|
|
|
});
|
2009-03-09 00:02:14 +03:00
|
|
|
|
|
|
|
</script>
|
|
|
|
</pre>
|
|
|
|
|
|
|
|
</body>
|
|
|
|
</html>
|