Commit d548859d authored by maxmorin's avatar maxmorin Committed by Commit bot

Revert making trying to authorize a nonsense device id a bad_message.

As it happens, renderers actually do this, and we don't want to
unnecessarily crash them. Instead, use the previous behaviour of
returning OUTPUT_DEVICE_STATUS_ERROR_NOT_FOUND instead.

One way to trigger a nonsense id being sent to the browser is by using
the setSinkId method of an HTMLMediaElement.

BUG=671167

Review-Url: https://codereview.chromium.org/2561343002
Cr-Commit-Position: refs/heads/master@{#437933}
parent c435080b
...@@ -82,8 +82,8 @@ void AudioOutputAuthorizationHandler::RequestDeviceAuthorization( ...@@ -82,8 +82,8 @@ void AudioOutputAuthorizationHandler::RequestDeviceAuthorization(
DCHECK_CURRENTLY_ON(BrowserThread::IO); DCHECK_CURRENTLY_ON(BrowserThread::IO);
if (!IsValidDeviceId(device_id)) { if (!IsValidDeviceId(device_id)) {
bad_message::ReceivedBadMessage(render_process_id_, cb.Run(media::OUTPUT_DEVICE_STATUS_ERROR_NOT_FOUND, false,
bad_message::AOAH_NONSENSE_DEVICE_ID); media::AudioParameters::UnavailableDeviceParams(), std::string());
return; return;
} }
......
...@@ -260,8 +260,7 @@ TEST_F(AudioOutputAuthorizationHandlerTest, ...@@ -260,8 +260,7 @@ TEST_F(AudioOutputAuthorizationHandlerTest,
SyncWithAllThreads(); SyncWithAllThreads();
} }
TEST_F(AudioOutputAuthorizationHandlerTest, TEST_F(AudioOutputAuthorizationHandlerTest, AuthorizeInvalidDeviceId_NotFound) {
AuthorizeInvalidDeviceId_BadMessage) {
std::unique_ptr<TestBrowserContext> context = std::unique_ptr<TestBrowserContext> context =
base::MakeUnique<TestBrowserContext>(); base::MakeUnique<TestBrowserContext>();
std::unique_ptr<MockRenderProcessHost> RPH = std::unique_ptr<MockRenderProcessHost> RPH =
...@@ -272,7 +271,10 @@ TEST_F(AudioOutputAuthorizationHandlerTest, ...@@ -272,7 +271,10 @@ TEST_F(AudioOutputAuthorizationHandlerTest,
GetAudioManager(), GetMediaStreamManager(), RPH->GetID(), kSalt); GetAudioManager(), GetMediaStreamManager(), RPH->GetID(), kSalt);
EXPECT_EQ(RPH->bad_msg_count(), 0); EXPECT_EQ(RPH->bad_msg_count(), 0);
EXPECT_CALL(listener, MockAuthorizationCallback(_, _, _, _)).Times(0); EXPECT_CALL(listener,
MockAuthorizationCallback(
media::OUTPUT_DEVICE_STATUS_ERROR_NOT_FOUND, _, _, _))
.Times(1);
BrowserThread::PostTask( BrowserThread::PostTask(
BrowserThread::IO, FROM_HERE, BrowserThread::IO, FROM_HERE,
...@@ -281,7 +283,9 @@ TEST_F(AudioOutputAuthorizationHandlerTest, ...@@ -281,7 +283,9 @@ TEST_F(AudioOutputAuthorizationHandlerTest,
kInvalidDeviceId, SecurityOrigin(), listener.GetCallback()))); kInvalidDeviceId, SecurityOrigin(), listener.GetCallback())));
SyncWithAllThreads(); SyncWithAllThreads();
EXPECT_EQ(RPH->bad_msg_count(), 1); // It is possible to request an invalid device id from JS APIs,
// so we don't want to crash the renderer for this.
EXPECT_EQ(RPH->bad_msg_count(), 0);
BrowserThread::DeleteSoon(BrowserThread::IO, FROM_HERE, handler.release()); BrowserThread::DeleteSoon(BrowserThread::IO, FROM_HERE, handler.release());
SyncWithAllThreads(); SyncWithAllThreads();
RPH.reset(); RPH.reset();
......
...@@ -609,9 +609,8 @@ TEST_F(AudioRendererHostTest, CreateDeviceWithBadSecurityOrigin) { ...@@ -609,9 +609,8 @@ TEST_F(AudioRendererHostTest, CreateDeviceWithBadSecurityOrigin) {
} }
TEST_F(AudioRendererHostTest, CreateInvalidDevice) { TEST_F(AudioRendererHostTest, CreateInvalidDevice) {
Create(kInvalidDeviceId, url::Origin(GURL(kSecurityOrigin)), true, false); Create(kInvalidDeviceId, url::Origin(GURL(kSecurityOrigin)), true, true);
Close(); Close();
AssertBadMsgReported();
} }
TEST_F(AudioRendererHostTest, CreateFailsForInvalidRenderFrame) { TEST_F(AudioRendererHostTest, CreateFailsForInvalidRenderFrame) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment