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

Unified Diff: chrome/renderer/extensions/module_system_unittest.cc

Issue 11312157: Add ExceptionHandler to ModuleSystem, remove heap allocated v8::TryCatch. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 1 month 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
Index: chrome/renderer/extensions/module_system_unittest.cc
diff --git a/chrome/renderer/extensions/module_system_unittest.cc b/chrome/renderer/extensions/module_system_unittest.cc
index 9bf7471b97f50e9ae4e1178d30f1d657c6bb2c13..da233b8ffcb11cb7730fb3477364d3010dbe4e02 100644
--- a/chrome/renderer/extensions/module_system_unittest.cc
+++ b/chrome/renderer/extensions/module_system_unittest.cc
@@ -31,6 +31,36 @@ class CounterNatives : public NativeHandler {
int counter_;
};
+class TestExceptionHandler : public ModuleSystem::ExceptionHandler {
+ public:
+ TestExceptionHandler()
+ : handled_exception_(false) {
+ }
+
+ virtual void HandleUncaughtException() {
+ handled_exception_ = true;
+ }
+
+ bool handled_exception() const { return handled_exception_; }
+
+ private:
+ bool handled_exception_;
+};
+
+TEST_F(ModuleSystemTest, TestExceptionHandling) {
+ ModuleSystem::NativesEnabledScope natives_enabled_scope(module_system_.get());
+ TestExceptionHandler* handler = new TestExceptionHandler;
+ scoped_ptr<ModuleSystem::ExceptionHandler> scoped_handler(handler);
+ ASSERT_FALSE(handler->handled_exception());
+ module_system_->set_exception_handler(scoped_handler.Pass());
+
+ RegisterModule("test", "throw 'hi';");
+ module_system_->Require("test");
+ ASSERT_TRUE(handler->handled_exception());
+
+ ExpectNoAssertionsMade();
+}
+
TEST_F(ModuleSystemTest, TestRequire) {
ModuleSystem::NativesEnabledScope natives_enabled_scope(module_system_.get());
RegisterModule("add", "exports.Add = function(x, y) { return x + y; };");

Powered by Google App Engine
This is Rietveld 408576698