OLD | NEW |
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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 "base/message_loop.h" | 5 #include "base/message_loop.h" |
6 #include "chrome/browser/browser.h" | 6 #include "chrome/browser/browser.h" |
7 #include "chrome/browser/renderer_host/render_view_host.h" | 7 #include "chrome/browser/renderer_host/render_view_host.h" |
8 #include "chrome/browser/profile.h" | 8 #include "chrome/browser/profile.h" |
9 #include "chrome/browser/extensions/extension_error_reporter.h" | 9 #include "chrome/browser/extensions/extension_error_reporter.h" |
10 #include "chrome/browser/extensions/extension_view.h" | 10 #include "chrome/browser/extensions/extension_view.h" |
(...skipping 30 matching lines...) Expand all Loading... |
41 bool got_message() { return got_message_; } | 41 bool got_message() { return got_message_; } |
42 private: | 42 private: |
43 virtual void RunJavaScriptMessage( | 43 virtual void RunJavaScriptMessage( |
44 const std::wstring& message, | 44 const std::wstring& message, |
45 const std::wstring& default_prompt, | 45 const std::wstring& default_prompt, |
46 const int flags, | 46 const int flags, |
47 IPC::Message* reply_msg, | 47 IPC::Message* reply_msg, |
48 bool* did_suppress_message) { | 48 bool* did_suppress_message) { |
49 got_message_ = true; | 49 got_message_ = true; |
50 MessageLoopForUI::current()->Quit(); | 50 MessageLoopForUI::current()->Quit(); |
| 51 |
| 52 // Call super, otherwise we'll leak reply_msg. |
| 53 ExtensionView::RunJavaScriptMessage( |
| 54 message, default_prompt, flags, reply_msg, did_suppress_message); |
51 } | 55 } |
52 | 56 |
53 bool got_message_; | 57 bool got_message_; |
54 }; | 58 }; |
55 | 59 |
56 // This class waits for a specific extension to be loaded. | 60 // This class waits for a specific extension to be loaded. |
57 class ExtensionLoadedObserver : public NotificationObserver { | 61 class ExtensionLoadedObserver : public NotificationObserver { |
58 public: | 62 public: |
59 explicit ExtensionLoadedObserver() : extension_(NULL) { | 63 explicit ExtensionLoadedObserver() : extension_(NULL) { |
60 registrar_.Add(this, NotificationType::EXTENSIONS_LOADED, | 64 registrar_.Add(this, NotificationType::EXTENSIONS_LOADED, |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
123 | 127 |
124 // Now wait for it to load, and grab a pointer to it. | 128 // Now wait for it to load, and grab a pointer to it. |
125 Extension* extension = observer.WaitForExtension(); | 129 Extension* extension = observer.WaitForExtension(); |
126 ASSERT_TRUE(extension); | 130 ASSERT_TRUE(extension); |
127 GURL url = Extension::GetResourceURL(extension->url(), "index.html"); | 131 GURL url = Extension::GetResourceURL(extension->url(), "index.html"); |
128 | 132 |
129 // Start the extension process and wait for it to show a javascript alert. | 133 // Start the extension process and wait for it to show a javascript alert. |
130 MockExtensionView view(url, profile); | 134 MockExtensionView view(url, profile); |
131 EXPECT_TRUE(view.got_message()); | 135 EXPECT_TRUE(view.got_message()); |
132 } | 136 } |
OLD | NEW |