From 0b0d2ff170d52f8d0e84d659cf257c071d0a4c76 Mon Sep 17 00:00:00 2001 From: Paul Adenot Date: Thu, 18 Jul 2013 11:57:38 +0200 Subject: [PATCH] Bug 883591 - Don't allow creating a MediaStreamDestinationNode on an OfflineAudioContext. r=ehsan --- content/media/webaudio/AudioContext.cpp | 7 ++++++- content/media/webaudio/AudioContext.h | 2 +- content/media/webaudio/test/test_OfflineAudioContext.html | 4 ++++ dom/webidl/AudioContext.webidl | 2 +- 4 files changed, 12 insertions(+), 3 deletions(-) diff --git a/content/media/webaudio/AudioContext.cpp b/content/media/webaudio/AudioContext.cpp index de380dedb12a..067df0129ab3 100644 --- a/content/media/webaudio/AudioContext.cpp +++ b/content/media/webaudio/AudioContext.cpp @@ -213,8 +213,13 @@ bool IsValidBufferSize(uint32_t aBufferSize) { } already_AddRefed -AudioContext::CreateMediaStreamDestination() +AudioContext::CreateMediaStreamDestination(ErrorResult& aRv) { + if (mIsOffline) { + aRv.Throw(NS_ERROR_DOM_NOT_SUPPORTED_ERR); + return nullptr; + } + nsRefPtr node = new MediaStreamAudioDestinationNode(this); return node.forget(); diff --git a/content/media/webaudio/AudioContext.h b/content/media/webaudio/AudioContext.h index 794004c1e9ec..f6095f8f8c0f 100644 --- a/content/media/webaudio/AudioContext.h +++ b/content/media/webaudio/AudioContext.h @@ -127,7 +127,7 @@ public: bool aMixToMono, ErrorResult& aRv); already_AddRefed - CreateMediaStreamDestination(); + CreateMediaStreamDestination(ErrorResult& aRv); already_AddRefed CreateScriptProcessor(uint32_t aBufferSize, diff --git a/content/media/webaudio/test/test_OfflineAudioContext.html b/content/media/webaudio/test/test_OfflineAudioContext.html index 6a5cf3a173c7..29c58edd80bc 100644 --- a/content/media/webaudio/test/test_OfflineAudioContext.html +++ b/content/media/webaudio/test/test_OfflineAudioContext.html @@ -23,6 +23,10 @@ addLoadEvent(function() { } expectException(function() { + ctx.createMediaStreamDestination(); + }, DOMException.NOT_SUPPORTED_ERR); + + expectException(function() { new OfflineAudioContext(2, 100, 0); }, DOMException.NOT_SUPPORTED_ERR); expectException(function() { diff --git a/dom/webidl/AudioContext.webidl b/dom/webidl/AudioContext.webidl index f8a28302e9bb..9d33cbc887da 100644 --- a/dom/webidl/AudioContext.webidl +++ b/dom/webidl/AudioContext.webidl @@ -32,7 +32,7 @@ interface AudioContext : EventTarget { [Creator] AudioBufferSourceNode createBufferSource(); - [Creator] + [Creator, Throws] MediaStreamAudioDestinationNode createMediaStreamDestination(); [Creator, Throws] -- 2.11.4.GIT