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

Side by Side Diff: content/renderer/browser_plugin/browser_plugin_browsertest.cc

Issue 10917225: Browser Plugin: Reload and Stop operations (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Updated Created 8 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 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 "content/renderer/browser_plugin/browser_plugin_browsertest.h" 5 #include "content/renderer/browser_plugin/browser_plugin_browsertest.h"
6 6
7 #include "base/file_path.h" 7 #include "base/file_path.h"
8 #include "base/file_util.h" 8 #include "base/file_util.h"
9 #include "base/path_service.h" 9 #include "base/path_service.h"
10 #include "content/common/browser_plugin_messages.h" 10 #include "content/common/browser_plugin_messages.h"
(...skipping 305 matching lines...) Expand 10 before | Expand all | Expand 10 after
316 browser_plugin->DidNavigate(GURL(kGoogleURL)); 316 browser_plugin->DidNavigate(GURL(kGoogleURL));
317 EXPECT_EQ(kGoogleURL, ExecuteScriptAndReturnString("url")); 317 EXPECT_EQ(kGoogleURL, ExecuteScriptAndReturnString("url"));
318 318
319 ExecuteJavaScript(kRemoveEventListener); 319 ExecuteJavaScript(kRemoveEventListener);
320 browser_plugin->DidNavigate(GURL(kGoogleNewsURL)); 320 browser_plugin->DidNavigate(GURL(kGoogleNewsURL));
321 // The URL variable should not change because we've removed the event 321 // The URL variable should not change because we've removed the event
322 // listener. 322 // listener.
323 EXPECT_EQ(kGoogleURL, ExecuteScriptAndReturnString("url")); 323 EXPECT_EQ(kGoogleURL, ExecuteScriptAndReturnString("url"));
324 } 324 }
325 325
326 TEST_F(BrowserPluginTest, StopMethod) {
327 const char* kCallStop =
328 "document.getElementById('browserplugin').stop();";
329 LoadHTML(GetHTMLForBrowserPluginObject().c_str());
330 ExecuteJavaScript(kCallStop);
331 EXPECT_TRUE(browser_plugin_manager()->sink().GetUniqueMessageMatching(
332 BrowserPluginHostMsg_Stop::ID));
333 }
334
335 TEST_F(BrowserPluginTest, ReloadMethod) {
336 const char* kCallReload =
337 "document.getElementById('browserplugin').reload();";
338 LoadHTML(GetHTMLForBrowserPluginObject().c_str());
339 ExecuteJavaScript(kCallReload);
340 EXPECT_TRUE(browser_plugin_manager()->sink().GetUniqueMessageMatching(
341 BrowserPluginHostMsg_Reload::ID));
342 }
343
344 TEST_F(BrowserPluginTest, ReloadAfterCrash) {
345 LoadHTML(GetHTMLForBrowserPluginObject().c_str());
346 int instance_id = 0;
347 // Verify that we're reporting the correct URL to navigate to based on the
348 // src attribute.
349 {
lazyboy 2012/09/13 19:14:15 Out of curiosity, what does this inner scopes do?
Fady Samuel 2012/09/19 14:38:09 It limits the scope of the msg, frame_id, src, siz
lazyboy 2012/09/19 15:06:06 OK thanks. (Making sure they are just local scopes
350 const IPC::Message* msg =
351 browser_plugin_manager()->sink().GetUniqueMessageMatching(
352 BrowserPluginHostMsg_NavigateGuest::ID);
353 ASSERT_TRUE(msg);
354
355 long long frame_id;
356 std::string src;
357 gfx::Size size;
358 BrowserPluginHostMsg_NavigateGuest::Read(
359 msg,
360 &instance_id,
361 &frame_id,
362 &src,
363 &size);
364 EXPECT_EQ("foo", src);
365 }
366 browser_plugin_manager()->sink().ClearMessages();
367
368 MockBrowserPlugin* browser_plugin =
369 static_cast<MockBrowserPlugin*>(
370 browser_plugin_manager()->GetBrowserPlugin(instance_id));
371 ASSERT_TRUE(browser_plugin);
372 // Crash the guest
373 browser_plugin->GuestCrashed();
374 // Reload the crashed guest
375 ExecuteJavaScript("document.getElementById('browserplugin').reload();");
376 // Verify that we do NOT issue a reload.
377 EXPECT_FALSE(browser_plugin_manager()->sink().GetUniqueMessageMatching(
378 BrowserPluginHostMsg_Reload::ID));
379 // Verify that we've navigated back to the same page.
lazyboy 2012/09/13 19:14:15 Also ASSERT_FALSE(browser_plugin_.guest_crashed_)
Fady Samuel 2012/09/19 14:38:09 Done.
380 {
381 const IPC::Message* msg =
382 browser_plugin_manager()->sink().GetUniqueMessageMatching(
383 BrowserPluginHostMsg_NavigateGuest::ID);
384 ASSERT_TRUE(msg);
385
386 long long frame_id;
387 std::string src;
388 gfx::Size size;
389 BrowserPluginHostMsg_NavigateGuest::Read(
390 msg,
391 &instance_id,
392 &frame_id,
393 &src,
394 &size);
395 EXPECT_EQ("foo", src);
396 }
397 }
398
326 } // namespace content 399 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698