Bug 1238472 - start playing webm after the iframe loaded.
--- a/dom/browser-element/mochitest/browserElement_NoAudioTrack.js
+++ b/dom/browser-element/mochitest/browserElement_NoAudioTrack.js
@@ -3,54 +3,60 @@
SimpleTest.waitForExplicitFinish();
browserElementTestHelpers.setEnabledPref(true);
browserElementTestHelpers.addPermission();
var fileURL = 'http://example.org/tests/dom/browser-element/mochitest/file_browserElement_NoAudioTrack.html';
var generator = runTests();
var testFrame;
+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 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);
+ ok(true, "Remove event-listener.");
document.body.removeChild(testFrame);
+ ok(true, "Remove test-frame from document.");
SimpleTest.finish();
}
function setCommand(aArg) {
info("# Command = " + aArg);
testFrame.src = fileURL + '#' + aArg;
-
- // Yield to the event loop a few times to make sure that onactivestatechanged
- // is not dispatched.
- SimpleTest.executeSoon(function() {
- SimpleTest.executeSoon(function() {
- SimpleTest.executeSoon(function() {
- continueTest();
- });
- });
- });
}
function runTests() {
setCommand('play');
yield undefined;
- setCommand('pause');
+ // wait a second to make sure that onactivestatechanged isn't dispatched.
+ setCommand('idle');
yield undefined;
finish();
yield undefined;
}
function setupTestFrame() {
testFrame = document.createElement('iframe');
@@ -72,17 +78,21 @@ function setupTestFrame() {
ac.onactivestatechanged = null;
error("Should not receive onactivestatechanged!");
};
continueTest();
}
testFrame.addEventListener('mozbrowserloadend', loadend);
+ testFrame.addEventListener('mozbrowsershowmodalprompt', alertListener);
+ ok(true, "Add event-listeners.");
+
document.body.appendChild(testFrame);
+ ok(true, "Append test-frame to document.");
}
addEventListener('testready', function() {
SpecialPowers.pushPrefEnv({'set': [["b2g.system_manifest_url", "http://mochi.test:8888/manifest.webapp"]]},
function() {
SimpleTest.executeSoon(setupTestFrame);
});
});
--- a/dom/browser-element/mochitest/file_browserElement_NoAudioTrack.html
+++ b/dom/browser-element/mochitest/file_browserElement_NoAudioTrack.html
@@ -1,11 +1,32 @@
<!DOCTYPE HTML>
<html>
<body>
<script type="application/javascript;version=1.7">
var audio = new Audio();
audio.src = "noaudio.webm";
+audio.preload = "none";
audio.loop = true;
-audio.play();
+
+function ok(aVal, aMsg) {
+ alert((!!aVal ? "OK" : "KO") + ", " + aMsg);
+}
+
+function runCommands()
+{
+ switch(location.hash) {
+ case '#play':
+ audio.play();
+ ok(true, "Start playing a video without audio track!");
+ break;
+ case '#idle':
+ ok(!audio.paused, "Video is still playing!");
+ break;
+ default :
+ ok(false, "Undefined command!");
+ }
+}
+
+window.addEventListener('hashchange', runCommands);
</script>
</body>
</html>
\ No newline at end of file
--- a/dom/browser-element/mochitest/mochitest.ini
+++ b/dom/browser-element/mochitest/mochitest.ini
@@ -205,16 +205,17 @@ skip-if = (toolkit == 'gonk' && !debug)
skip-if = (toolkit == 'android' && processor == 'x86') #x86 only
[test_browserElement_inproc_GetScreenshotDppx.html]
[test_browserElement_inproc_Iconchange.html]
[test_browserElement_inproc_LoadEvents.html]
[test_browserElement_inproc_Manifestchange.html]
[test_browserElement_inproc_Metachange.html]
[test_browserElement_inproc_NextPaint.html]
[test_browserElement_inproc_NoAudioTrack.html]
+tags = audiochannel
[test_browserElement_inproc_OpenNamed.html]
skip-if = (toolkit == 'gonk' && !debug)
[test_browserElement_inproc_OpenTab.html]
disabled = won't work as Firefox desktop will intercept ctrl-click
[test_browserElement_inproc_OpenWindow.html]
skip-if = (toolkit == 'gonk' && !debug)
[test_browserElement_inproc_OpenWindowDifferentOrigin.html]
skip-if = (toolkit == 'gonk' && !debug)