diff options
author | Matt A. Tobin <mattatobin@localhost.localdomain> | 2018-02-02 04:16:08 -0500 |
---|---|---|
committer | Matt A. Tobin <mattatobin@localhost.localdomain> | 2018-02-02 04:16:08 -0500 |
commit | 5f8de423f190bbb79a62f804151bc24824fa32d8 (patch) | |
tree | 10027f336435511475e392454359edea8e25895d /dom/browser-element/mochitest/browserElement_NoAudioTrack.js | |
parent | 49ee0794b5d912db1f95dce6eb52d781dc210db5 (diff) | |
download | UXP-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/browser-element/mochitest/browserElement_NoAudioTrack.js')
-rw-r--r-- | dom/browser-element/mochitest/browserElement_NoAudioTrack.js | 96 |
1 files changed, 96 insertions, 0 deletions
diff --git a/dom/browser-element/mochitest/browserElement_NoAudioTrack.js b/dom/browser-element/mochitest/browserElement_NoAudioTrack.js new file mode 100644 index 000000000..47f0fd524 --- /dev/null +++ b/dom/browser-element/mochitest/browserElement_NoAudioTrack.js @@ -0,0 +1,96 @@ +"use strict"; + +SimpleTest.waitForExplicitFinish(); +browserElementTestHelpers.setEnabledPref(true); + +var fileURL = 'chrome://mochitests/content/chrome/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; +} + +function runTests() { + setCommand('play'); + yield undefined; + + // wait a second to make sure that onactivestatechanged isn't dispatched. + setCommand('idle'); + yield undefined; + + finish(); + yield undefined; +} + +function setupTestFrame() { + testFrame = document.createElement('iframe'); + testFrame.setAttribute('mozbrowser', 'true'); + testFrame.src = fileURL; + + function loadend() { + testFrame.removeEventListener('mozbrowserloadend', loadend); + ok("allowedAudioChannels" in testFrame, "allowedAudioChannels exist"); + var channels = testFrame.allowedAudioChannels; + is(channels.length, 9, "9 audio channel by default"); + + var ac = channels[0]; + ok(ac instanceof BrowserElementAudioChannel, "Correct class"); + ok("onactivestatechanged" in ac, "onactivestatechanged exists"); + + ac.onactivestatechanged = () => { + ac.onactivestatechanged = null; + ok(true, "Should 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_startup_url", window.location.href]]}, + function() { + SimpleTest.executeSoon(setupTestFrame); + }); +}); |