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

Side by Side Diff: ceee/ie/plugin/scripting/content_script_manager_unittest.cc

Issue 4997002: IE CEEE: Explicitly assign window properties/methods into the script host glo... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 10 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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 // Content script manager implementation unit tests. 5 // Content script manager implementation unit tests.
6 #include "ceee/ie/plugin/scripting/content_script_manager.h" 6 #include "ceee/ie/plugin/scripting/content_script_manager.h"
7 7
8 #include "base/logging.h" 8 #include "base/logging.h"
9 #include "base/utf_string_conversions.h" 9 #include "base/utf_string_conversions.h"
10 #include "ceee/common/initializing_coclass.h" 10 #include "ceee/common/initializing_coclass.h"
(...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after
216 216
217 function_ = NULL; 217 function_ = NULL;
218 function_keeper_.Release(); 218 function_keeper_.Release();
219 219
220 // Test for leakage. 220 // Test for leakage.
221 EXPECT_EQ(0, testing::InstanceCountMixinBase::all_instance_count()); 221 EXPECT_EQ(0, testing::InstanceCountMixinBase::all_instance_count());
222 } 222 }
223 223
224 // Set up to expect scripting initialization. 224 // Set up to expect scripting initialization.
225 void ExpectScriptInitialization() { 225 void ExpectScriptInitialization() {
226 EXPECT_CALL(*script_host_,
227 RegisterScriptObject(StrEq(L"window"), _, true))
228 .WillOnce(Return(S_OK));
229
230 EXPECT_CALL(*script_host_,
231 RunScript(testing::StartsWith(L"ceee-content://"), _))
232 .Times(5)
233 .WillRepeatedly(Return(S_OK));
234
235 // Return the mock function for start/end init.
236 EXPECT_CALL(*script_host_, RunExpression(StrEq(L"ceee.startInit_"), _))
237 .WillOnce(
238 DoAll(
239 CopyVariantToArgument<1>(CComVariant(function_keeper_)),
240 Return(S_OK)));
241 EXPECT_CALL(*script_host_, RunExpression(StrEq(L"ceee.endInit_"), _))
242 .WillOnce(
243 DoAll(
244 CopyVariantToArgument<1>(CComVariant(function_keeper_)),
245 Return(S_OK)));
246
247 EXPECT_CALL(*frame_host_, GetExtensionId(_)).WillOnce(DoAll( 226 EXPECT_CALL(*frame_host_, GetExtensionId(_)).WillOnce(DoAll(
248 SetArgumentPointee<0>(std::wstring(kExtensionId)), 227 SetArgumentPointee<0>(std::wstring(kExtensionId)),
249 Return(S_OK))); 228 Return(S_OK)));
250 229
251 // And expect two invocations. 230 EXPECT_CALL(*script_host_,
231 RunScript(testing::StartsWith(L"ceee-content://"), _))
232 .Times(5).WillRepeatedly(Return(S_OK));
233
234 // Return the mock function for start/end init.
235 EXPECT_CALL(*script_host_, RunExpression(StrEq(L"ceee.startInit_"), _))
236 .WillOnce(DoAll(
237 CopyVariantToArgument<1>(CComVariant(function_keeper_)),
238 Return(S_OK)));
239 EXPECT_CALL(*script_host_, RunExpression(StrEq(L"ceee.endInit_"), _))
240 .WillOnce(DoAll(
241 CopyVariantToArgument<1>(CComVariant(function_keeper_)),
242 Return(S_OK)));
243
244 // Register the window object and initialize its globals.
245 EXPECT_CALL(*script_host_,
246 RegisterScriptObject(StrEq(L"window"), _, false))
247 .WillOnce(Return(S_OK));
248 EXPECT_CALL(*script_host_, RunExpression(StrEq(L"ceee.initGlobals_"), _))
249 .WillOnce(DoAll(
250 CopyVariantToArgument<1>(CComVariant(function_keeper_)),
251 Return(S_OK)));
252
253 // And expect three invocations.
252 // TODO(siggi@chromium.org): be more specific? 254 // TODO(siggi@chromium.org): be more specific?
253 EXPECT_CALL(*function_, Invoke(_, _, _, _, _, _, _, _)) 255 EXPECT_CALL(*function_, Invoke(_, _, _, _, _, _, _, _))
254 .Times(2) 256 .Times(3).WillRepeatedly(Return(S_OK));
255 .WillRepeatedly(Return(S_OK));
256 } 257 }
257 258
258 void ExpectCreateScriptHost(TestingContentScriptManager* manager) { 259 void ExpectCreateScriptHost(TestingContentScriptManager* manager) {
259 EXPECT_CALL(*manager, CreateScriptHost(_)) 260 EXPECT_CALL(*manager, CreateScriptHost(_))
260 .WillOnce( 261 .WillOnce(
261 DoAll( 262 DoAll(
262 CopyInterfaceToArgument<0>(script_host_keeper_), 263 CopyInterfaceToArgument<0>(script_host_keeper_),
263 Return(S_OK))); 264 Return(S_OK)));
264 } 265 }
265 266
(...skipping 214 matching lines...) Expand 10 before | Expand all | Expand 10 after
480 481
481 EXPECT_CALL(manager, 482 EXPECT_CALL(manager,
482 InjectStyleTag(document_, head_node.p, StrEq(kCssContent))) 483 InjectStyleTag(document_, head_node.p, StrEq(kCssContent)))
483 .WillOnce(Return(S_OK)); 484 .WillOnce(Return(S_OK));
484 485
485 ASSERT_HRESULT_SUCCEEDED( 486 ASSERT_HRESULT_SUCCEEDED(
486 manager.ContentScriptManager::InsertCss(kCssContent, document_)); 487 manager.ContentScriptManager::InsertCss(kCssContent, document_));
487 } 488 }
488 489
489 } // namespace 490 } // namespace
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698