зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1225425 - [Testcase] Do not unregister the AudioChannelAgent during seeking. r=baku
--HG-- extra : rebase_source : 120d28d3cba5be5b73f9267b8985e83b4ef75070
This commit is contained in:
Родитель
b29099ae6d
Коммит
5abb5f1bf7
|
@ -0,0 +1,118 @@
|
|||
"use strict";
|
||||
|
||||
SimpleTest.waitForExplicitFinish();
|
||||
browserElementTestHelpers.setEnabledPref(true);
|
||||
browserElementTestHelpers.addPermission();
|
||||
|
||||
var fileURL = 'http://example.org/tests/dom/browser-element/mochitest/file_browserElement_AudioChannelSeeking.html';
|
||||
var generator = runTests();
|
||||
var testFrame;
|
||||
var ac;
|
||||
|
||||
function alertListener(e) {
|
||||
var message = e.detail.message
|
||||
if (/^OK/.exec(message)) {
|
||||
ok(true, "Message from file : " + message);
|
||||
continueTest();
|
||||
} else if (/^KO/.exec(message)) {
|
||||
error(message);
|
||||
} else {
|
||||
error("Undefined event.");
|
||||
}
|
||||
}
|
||||
|
||||
function assert(aVal, aMessage) {
|
||||
return (!aVal) ? error(aMessage) : 0;
|
||||
}
|
||||
|
||||
function error(aMessage) {
|
||||
ok(false, "Error : " + aMessage);
|
||||
finish();
|
||||
}
|
||||
|
||||
function continueTest() {
|
||||
try {
|
||||
generator.next();
|
||||
} catch (e if e instanceof StopIteration) {
|
||||
error("Stop test because of exception!");
|
||||
}
|
||||
}
|
||||
|
||||
function finish() {
|
||||
testFrame.removeEventListener('mozbrowsershowmodalprompt', alertListener);
|
||||
document.body.removeChild(testFrame);
|
||||
SimpleTest.finish();
|
||||
}
|
||||
|
||||
function setCommand(aArg) {
|
||||
assert(!!ac, "Audio channel doesn't exist!");
|
||||
info("# Command = " + aArg);
|
||||
testFrame.src = fileURL + '#' + aArg;
|
||||
|
||||
switch (aArg) {
|
||||
case 'play':
|
||||
break;
|
||||
case 'seeking':
|
||||
ac.onactivestatechanged = () => {
|
||||
ac.onactivestatechanged = null;
|
||||
error("Should not receive onactivestatechanged!");
|
||||
};
|
||||
break;
|
||||
case 'pause':
|
||||
ac.onactivestatechanged = null;
|
||||
break;
|
||||
default :
|
||||
error("Undefined command!");
|
||||
}
|
||||
}
|
||||
|
||||
function runTests() {
|
||||
setCommand('play');
|
||||
yield undefined;
|
||||
|
||||
setCommand('seeking');
|
||||
yield undefined;
|
||||
|
||||
setCommand('seeking');
|
||||
yield undefined;
|
||||
|
||||
setCommand('seeking');
|
||||
yield undefined;
|
||||
|
||||
setCommand('pause');
|
||||
yield undefined;
|
||||
|
||||
finish();
|
||||
yield undefined;
|
||||
}
|
||||
|
||||
function setupTestFrame() {
|
||||
testFrame = document.createElement('iframe');
|
||||
testFrame.setAttribute('mozbrowser', 'true');
|
||||
testFrame.setAttribute('mozapp', 'http://example.org/manifest.webapp');
|
||||
testFrame.src = fileURL;
|
||||
|
||||
function loadend() {
|
||||
testFrame.removeEventListener('mozbrowserloadend', loadend);
|
||||
ok("allowedAudioChannels" in testFrame, "allowedAudioChannels exist");
|
||||
var channels = testFrame.allowedAudioChannels;
|
||||
is(channels.length, 1, "1 audio channel by default");
|
||||
|
||||
ac = channels[0];
|
||||
ok(ac instanceof BrowserElementAudioChannel, "Correct class");
|
||||
ok("onactivestatechanged" in ac, "onactivestatechanged exists");
|
||||
|
||||
continueTest();
|
||||
}
|
||||
|
||||
testFrame.addEventListener('mozbrowsershowmodalprompt', alertListener);
|
||||
testFrame.addEventListener('mozbrowserloadend', loadend);
|
||||
document.body.appendChild(testFrame);
|
||||
}
|
||||
|
||||
addEventListener('testready', function() {
|
||||
SpecialPowers.pushPrefEnv({'set': [["b2g.system_manifest_url", "http://mochi.test:8888/manifest.webapp"]]},
|
||||
function() {
|
||||
SimpleTest.executeSoon(setupTestFrame);
|
||||
});
|
||||
});
|
|
@ -0,0 +1,58 @@
|
|||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<body>
|
||||
<script type="application/javascript;version=1.7">
|
||||
var audio = new Audio();
|
||||
audio.src = "audio.ogg";
|
||||
audio.loop = true;
|
||||
|
||||
function assert(aVal, aMessage) {
|
||||
return (!aVal) ? ok(false, aMessage) : 0;
|
||||
}
|
||||
|
||||
function ok(aVal, aMsg) {
|
||||
alert((!!aVal ? "OK" : "KO") + ", " + aMsg);
|
||||
}
|
||||
|
||||
function randomSeeking() {
|
||||
var seekingPosition = Math.random() * audio.duration;
|
||||
assert(seekingPosition < audio.duration, "Seeking position out of range!")
|
||||
audio.currentTime = seekingPosition;
|
||||
audio.onseeked = () => {
|
||||
audio.onseeked = null;
|
||||
location.hash = '#idle';
|
||||
ok(true, "Seeking complete, position = " + seekingPosition);
|
||||
};
|
||||
}
|
||||
|
||||
function runCommands()
|
||||
{
|
||||
switch(location.hash) {
|
||||
case '#play':
|
||||
audio.play();
|
||||
audio.onplay = () => {
|
||||
audio.onplay = null;
|
||||
ok(true, "Start playing, duration = " + audio.duration);
|
||||
};
|
||||
break;
|
||||
case '#seeking':
|
||||
randomSeeking();
|
||||
break;
|
||||
case '#pause':
|
||||
audio.pause();
|
||||
audio.onpause = () => {
|
||||
audio.onpause = null;
|
||||
ok(true, "Stop playing.");
|
||||
};
|
||||
break;
|
||||
case '#idle':
|
||||
break;
|
||||
default :
|
||||
ok(false, "Undefined command!");
|
||||
}
|
||||
}
|
||||
|
||||
window.addEventListener('hashchange', runCommands);
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
|
@ -12,6 +12,7 @@ support-files =
|
|||
browserElement_Find.js
|
||||
browserElement_OpenTab.js
|
||||
|
||||
[test_browserElement_oop_AudioChannelSeeking.html]
|
||||
[test_browserElement_oop_getStructuredData.html]
|
||||
[test_browserElement_oop_Viewmode.html]
|
||||
[test_browserElement_oop_ThemeColor.html]
|
||||
|
|
|
@ -11,6 +11,7 @@ support-files =
|
|||
browserElement_AllowEmbedAppsInNestedOOIframe.js
|
||||
browserElement_AppFramePermission.js
|
||||
browserElement_AppWindowNamespace.js
|
||||
browserElement_AudioChannelSeeking.js
|
||||
browserElement_AudioChannelMutedByDefault.js
|
||||
browserElement_AudioPlayback.js
|
||||
browserElement_Auth.js
|
||||
|
@ -92,6 +93,7 @@ support-files =
|
|||
file_browserElement_AllowEmbedAppsInNestedOOIframe.html
|
||||
file_browserElement_AppFramePermission.html
|
||||
file_browserElement_AppWindowNamespace.html
|
||||
file_browserElement_AudioChannelSeeking.html
|
||||
file_browserElement_AudioChannel_nested.html
|
||||
file_browserElement_AudioChannelMutedByDefault.html
|
||||
file_browserElement_Viewmode.html
|
||||
|
@ -157,6 +159,7 @@ support-files =
|
|||
[test_browserElement_NoPref.html]
|
||||
[test_browserElement_NoPermission.html]
|
||||
[test_browserElement_inproc_Alert.html]
|
||||
[test_browserElement_inproc_AudioChannelSeeking.html]
|
||||
[test_browserElement_inproc_Viewmode.html]
|
||||
[test_browserElement_inproc_ThemeColor.html]
|
||||
skip-if = buildapp == 'b2g'
|
||||
|
|
|
@ -0,0 +1,13 @@
|
|||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<head>
|
||||
<title>Bug 1227051 - Do not unregister the AudioChannelAgent during seeking</title>
|
||||
<script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
|
||||
<script type="application/javascript" src="browserElementTestHelpers.js"></script>
|
||||
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
|
||||
</head>
|
||||
<body>
|
||||
<script type="application/javascript;version=1.7" src="browserElement_AudioChannelSeeking.js">
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
|
@ -0,0 +1,13 @@
|
|||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<head>
|
||||
<title>Bug 1227051 - Do not unregister the AudioChannelAgent during seeking</title>
|
||||
<script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
|
||||
<script type="application/javascript" src="browserElementTestHelpers.js"></script>
|
||||
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
|
||||
</head>
|
||||
<body>
|
||||
<script type="application/javascript;version=1.7" src="browserElement_AudioChannelSeeking.js">
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
Загрузка…
Ссылка в новой задаче