Commit be37ca15 authored by Peter Kasting's avatar Peter Kasting Committed by Commit Bot

Regression test for null pointer deref.

Bug: 1050801
Change-Id: I101dc922e1e589b5741a24ffb41e10452275bcc1
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2068309Reviewed-by: default avatarMartin Šrámek <msramek@chromium.org>
Commit-Queue: Peter Kasting <pkasting@chromium.org>
Cr-Commit-Position: refs/heads/master@{#743808}
parent bd2fe416
......@@ -1340,10 +1340,10 @@ void ContentSettingMediaStreamBubbleModel::SetMediaMenus() {
PrefService* prefs = GetProfile()->GetPrefs();
MediaCaptureDevicesDispatcher* dispatcher =
MediaCaptureDevicesDispatcher::GetInstance();
const blink::MediaStreamDevices& microphones =
dispatcher->GetAudioCaptureDevices();
if (MicrophoneAccessed()) {
const blink::MediaStreamDevices& microphones =
dispatcher->GetAudioCaptureDevices();
MediaMenu mic_menu;
mic_menu.label = l10n_util::GetStringUTF16(IDS_MEDIA_SELECTED_MIC_LABEL);
if (!microphones.empty()) {
......
// Copyright 2020 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "chrome/browser/ui/views/content_setting_bubble_contents.h"
#include "chrome/browser/ui/content_settings/content_setting_bubble_model.h"
#include "chrome/test/base/testing_profile.h"
#include "chrome/test/views/chrome_views_test_base.h"
#include "content/public/test/web_contents_tester.h"
#include "ui/views/bubble/bubble_dialog_delegate_view.h"
using ContentSettingBubbleContentsTest = ChromeViewsTestBase;
class TestContentSettingBubbleModel : public ContentSettingBubbleModel {
public:
TestContentSettingBubbleModel(Delegate* delegate,
content::WebContents* web_contents)
: ContentSettingBubbleModel(delegate, web_contents) {
AddListItem(
ListItem(nullptr, base::string16(), base::string16(), false, false, 0));
}
};
// Regression test for http://crbug.com/1050801 .
TEST_F(ContentSettingBubbleContentsTest, NullDeref) {
TestingProfile profile;
std::unique_ptr<content::WebContents> web_contents =
content::WebContentsTester::CreateTestWebContents(&profile, nullptr);
auto model = std::make_unique<TestContentSettingBubbleModel>(
nullptr, web_contents.get());
auto contents = std::make_unique<ContentSettingBubbleContents>(
std::move(model), web_contents.get(), nullptr,
views::BubbleBorder::TOP_LEFT);
views::Widget::InitParams params =
CreateParams(views::Widget::InitParams::TYPE_WINDOW);
params.ownership = views::Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET;
views::Widget widget;
widget.Init(std::move(params));
contents->set_parent_window(widget.GetNativeView());
// Should not crash.
views::BubbleDialogDelegateView::CreateBubble(contents.release())->CloseNow();
}
......@@ -5332,6 +5332,7 @@ test("unit_tests") {
"../browser/ui/views/bookmarks/bookmark_editor_view_unittest.cc",
"../browser/ui/views/bookmarks/bookmark_menu_delegate_unittest.cc",
"../browser/ui/views/confirm_bubble_views_unittest.cc",
"../browser/ui/views/content_setting_bubble_contents_unittest.cc",
"../browser/ui/views/desktop_capture/desktop_media_picker_views_unittest.cc",
"../browser/ui/views/device_chooser_content_view_unittest.cc",
"../browser/ui/views/download/download_item_view_unittest.cc",
......
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