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

Side by Side Diff: chrome/renderer/extensions/module_system_unittest.cc

Issue 11571014: Lazy load chrome.* APIs (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix interactive_ui_tests Created 7 years, 10 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 using extensions::ModuleSystem; 10 using extensions::ModuleSystem;
10 using extensions::NativeHandler; 11 using extensions::NativeHandler;
12 using extensions::ObjectBackedNativeHandler;
11 13
12 class CounterNatives : public NativeHandler { 14 class CounterNatives : public ObjectBackedNativeHandler {
13 public: 15 public:
14 explicit CounterNatives(v8::Isolate* isolate) 16 explicit CounterNatives(v8::Isolate* isolate)
15 : NativeHandler(isolate), counter_(0) { 17 : ObjectBackedNativeHandler(isolate), counter_(0) {
16 RouteFunction("Get", base::Bind(&CounterNatives::Get, 18 RouteFunction("Get", base::Bind(&CounterNatives::Get,
17 base::Unretained(this))); 19 base::Unretained(this)));
18 RouteFunction("Increment", base::Bind(&CounterNatives::Increment, 20 RouteFunction("Increment", base::Bind(&CounterNatives::Increment,
19 base::Unretained(this))); 21 base::Unretained(this)));
20 } 22 }
21 23
22 v8::Handle<v8::Value> Get(const v8::Arguments& args) { 24 v8::Handle<v8::Value> Get(const v8::Arguments& args) {
23 return v8::Integer::New(counter_); 25 return v8::Integer::New(counter_);
24 } 26 }
25 27
(...skipping 226 matching lines...) Expand 10 before | Expand all | Expand 10 after
252 } 254 }
253 255
254 TEST_F(ModuleSystemTest, TestOverrideNonExistentNativeHandler) { 256 TEST_F(ModuleSystemTest, TestOverrideNonExistentNativeHandler) {
255 ModuleSystem::NativesEnabledScope natives_enabled_scope(module_system_.get()); 257 ModuleSystem::NativesEnabledScope natives_enabled_scope(module_system_.get());
256 OverrideNativeHandler("thing", "exports.x = 5;"); 258 OverrideNativeHandler("thing", "exports.x = 5;");
257 RegisterModule("test", 259 RegisterModule("test",
258 "var assert = requireNative('assert');" 260 "var assert = requireNative('assert');"
259 "assert.AssertTrue(requireNative('thing').x == 5);"); 261 "assert.AssertTrue(requireNative('thing').x == 5);");
260 module_system_->Require("test"); 262 module_system_->Require("test");
261 } 263 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698