Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1450)

Unified Diff: chrome/browser/extensions/hotword_browsertest.cc

Issue 587153002: Suppress the exception thrown when responding to message with no response callback. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix typo. Created 6 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | chrome/browser/resources/hotword_helper/manager.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/extensions/hotword_browsertest.cc
diff --git a/chrome/browser/extensions/hotword_browsertest.cc b/chrome/browser/extensions/hotword_browsertest.cc
new file mode 100644
index 0000000000000000000000000000000000000000..e26a7366f3ee919d36e7cad59c3144b83e00f3f0
--- /dev/null
+++ b/chrome/browser/extensions/hotword_browsertest.cc
@@ -0,0 +1,87 @@
+// Copyright 2014 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 "base/files/file_path.h"
+#include "base/path_service.h"
+#include "base/prefs/pref_service.h"
+#include "chrome/browser/extensions/component_loader.h"
+#include "chrome/browser/extensions/error_console/error_console.h"
+#include "chrome/browser/extensions/extension_browsertest.h"
+#include "chrome/browser/extensions/extension_service.h"
+#include "chrome/browser/profiles/profile.h"
+#include "chrome/common/pref_names.h"
+#include "chrome/test/base/ui_test_utils.h"
+#include "content/public/common/content_switches.h"
+#include "extensions/common/extension.h"
+#include "extensions/test/extension_test_message_listener.h"
+#include "testing/gtest/include/gtest/gtest.h"
+
+
+namespace extensions {
+
+static const char* kHotwordHelperExtensionId =
+ "dnhpdliibojhegemfjheidglijccjfmc";
+
+class HotwordBrowserTest : public ExtensionBrowserTest {
+ public:
+ HotwordBrowserTest() : error_console_(NULL) { }
+ virtual ~HotwordBrowserTest() { }
+
+ protected:
+ virtual void SetUpInProcessBrowserTestFixture() OVERRIDE {
+ ExtensionBrowserTest::SetUpInProcessBrowserTestFixture();
+
+ // Force the VoiceTrigger field trial on to enable the hotword_helper
+ // extension.
+ base::CommandLine::ForCurrentProcess()->AppendSwitchASCII(
+ switches::kForceFieldTrials, "VoiceTrigger/Install/");
+ // Load the hotword_helper extension.
+ ComponentLoader::EnableBackgroundExtensionsForTesting();
+
+ // We need to enable the ErrorConsole FeatureSwitch in order to collect
+ // errors. This should be enabled on any channel <= Dev, but let's make
+ // sure (in case a test is running on, e.g., a beta channel).
+ FeatureSwitch::error_console()->SetOverrideValue(
+ FeatureSwitch::OVERRIDE_ENABLED);
+ }
+
+ virtual void SetUpOnMainThread() OVERRIDE {
+ ExtensionBrowserTest::SetUpOnMainThread();
+
+ // Errors are only kept if we have Developer Mode enabled.
+ profile()->GetPrefs()->SetBoolean(prefs::kExtensionsUIDeveloperMode, true);
+
+ error_console_ = ErrorConsole::Get(profile());
+ ASSERT_TRUE(error_console_);
+ }
+
+ ErrorConsole* error_console() { return error_console_; }
+
+ private:
+ // Weak reference to the ErrorConsole.
+ ErrorConsole* error_console_;
+
+ DISALLOW_COPY_AND_ASSIGN(HotwordBrowserTest);
+};
+
+// Test we silently capture an exception from a message handler's response
+// callback. This happens when the caller to chrome.runtime.sendMessage()
+// doesn't specify a response callback.
+IN_PROC_BROWSER_TEST_F(HotwordBrowserTest, MessageSendResponseError) {
+ // Enable error reporting for the hotword helper extension.
+ error_console()->SetReportingAllForExtension(kHotwordHelperExtensionId, true);
+
+ ExtensionTestMessageListener doneListener("done", false);
+ const Extension* extension = extension_service()->GetExtensionById(
+ kHotwordHelperExtensionId, false);
+ ASSERT_TRUE(extension);
+ const Extension* test_extension = LoadExtension(
+ test_data_dir_.AppendASCII("hotword"));
+ ASSERT_TRUE(test_extension);
+
+ ASSERT_TRUE(doneListener.WaitUntilSatisfied());
+ ASSERT_TRUE(error_console()->GetErrorsForExtension(extension->id()).empty());
+}
+
+} // namespace extensions
« no previous file with comments | « no previous file | chrome/browser/resources/hotword_helper/manager.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698