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/media/test/test_mediarecorder_record_audiocontext.html | |
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/media/test/test_mediarecorder_record_audiocontext.html')
-rw-r--r-- | dom/media/test/test_mediarecorder_record_audiocontext.html | 66 |
1 files changed, 66 insertions, 0 deletions
diff --git a/dom/media/test/test_mediarecorder_record_audiocontext.html b/dom/media/test/test_mediarecorder_record_audiocontext.html new file mode 100644 index 000000000..2697ad8d0 --- /dev/null +++ b/dom/media/test/test_mediarecorder_record_audiocontext.html @@ -0,0 +1,66 @@ +<!DOCTYPE HTML> +<html> +<head> + <title>Test MediaRecorder Record AudioContext</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> +</head> +<body> + +<script class="testbody" type="text/javascript"> + +function startTest() { + var context = new AudioContext(); + var hasonstop = false; + var buffer = context.createBuffer(1, 80920, context.sampleRate); + for (var i = 0; i < 80920; ++i) { + buffer.getChannelData(0)[i] = Math.sin(1000 * 2 * Math.PI * i / context.sampleRate); + } + + var source = context.createBufferSource(); + source.buffer = buffer; + source.loop = true; + + var dest = context.createMediaStreamDestination(); + source.connect(dest); + var elem = document.createElement('audio'); + elem.srcObject = dest.stream; + mMediaStream = dest.stream; + source.start(0); + elem.play(); + mMediaRecorder = new MediaRecorder(dest.stream); + mMediaRecorder.onwarning = function() { + ok(false, 'onwarning unexpectedly fired'); + }; + + mMediaRecorder.onerror = function() { + ok(false, 'onerror unexpectedly fired'); + }; + + mMediaRecorder.onstop = function() { + ok(true, 'onstop fired successfully'); + is(mMediaRecorder.state, 'inactive', 'check recording status is inactive'); + SimpleTest.finish(); + }; + mMediaRecorder.ondataavailable = function (e) { + if (mMediaRecorder.state == 'recording') { + is('audio/ogg', mMediaRecorder.mimeType, "check the record mimetype return " + mMediaRecorder.mimeType); + ok(e.data.size > 0, 'check blob has data'); + mMediaRecorder.stop(); + } + }; + try { + mMediaRecorder.start(1000); + is('recording', mMediaRecorder.state, "check record state recording"); + } catch (e) { + ok(false, 'Can t record audio context'); + } +} + +startTest(); +SimpleTest.waitForExplicitFinish(); +</script> +</pre> +</body> +</html> |