| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "chrome/test/base/module_system_test.h" | 5 #include "chrome/test/base/module_system_test.h" |
| 6 #include "base/memory/scoped_ptr.h" | 6 #include "base/memory/scoped_ptr.h" |
| 7 #include "chrome/renderer/extensions/module_system.h" | 7 #include "chrome/renderer/extensions/module_system.h" |
| 8 | 8 |
| 9 // TODO(cduvall/kalman): Put this file in extensions namespace. | 9 // TODO(cduvall/kalman): Put this file in extensions namespace. |
| 10 using extensions::ModuleSystem; | 10 using extensions::ModuleSystem; |
| (...skipping 22 matching lines...) Expand all Loading... |
| 33 private: | 33 private: |
| 34 int counter_; | 34 int counter_; |
| 35 }; | 35 }; |
| 36 | 36 |
| 37 class TestExceptionHandler : public ModuleSystem::ExceptionHandler { | 37 class TestExceptionHandler : public ModuleSystem::ExceptionHandler { |
| 38 public: | 38 public: |
| 39 TestExceptionHandler() | 39 TestExceptionHandler() |
| 40 : handled_exception_(false) { | 40 : handled_exception_(false) { |
| 41 } | 41 } |
| 42 | 42 |
| 43 virtual void HandleUncaughtException() OVERRIDE { | 43 virtual void HandleUncaughtException(const v8::TryCatch& try_catch) OVERRIDE { |
| 44 handled_exception_ = true; | 44 handled_exception_ = true; |
| 45 } | 45 } |
| 46 | 46 |
| 47 bool handled_exception() const { return handled_exception_; } | 47 bool handled_exception() const { return handled_exception_; } |
| 48 | 48 |
| 49 private: | 49 private: |
| 50 bool handled_exception_; | 50 bool handled_exception_; |
| 51 }; | 51 }; |
| 52 | 52 |
| 53 TEST_F(ModuleSystemTest, TestExceptionHandling) { | 53 TEST_F(ModuleSystemTest, TestExceptionHandling) { |
| (...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 254 } | 254 } |
| 255 | 255 |
| 256 TEST_F(ModuleSystemTest, TestOverrideNonExistentNativeHandler) { | 256 TEST_F(ModuleSystemTest, TestOverrideNonExistentNativeHandler) { |
| 257 ModuleSystem::NativesEnabledScope natives_enabled_scope(module_system_.get()); | 257 ModuleSystem::NativesEnabledScope natives_enabled_scope(module_system_.get()); |
| 258 OverrideNativeHandler("thing", "exports.x = 5;"); | 258 OverrideNativeHandler("thing", "exports.x = 5;"); |
| 259 RegisterModule("test", | 259 RegisterModule("test", |
| 260 "var assert = requireNative('assert');" | 260 "var assert = requireNative('assert');" |
| 261 "assert.AssertTrue(requireNative('thing').x == 5);"); | 261 "assert.AssertTrue(requireNative('thing').x == 5);"); |
| 262 module_system_->Require("test"); | 262 module_system_->Require("test"); |
| 263 } | 263 } |
| OLD | NEW |