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

Side by Side Diff: chrome/renderer/render_view_unittest.cc

Issue 18183: First pass as implementing the greasemonkey API. This patch (Closed)
Patch Set: Created 11 years, 11 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
« no previous file with comments | « chrome/renderer/render_view.cc ('k') | chrome/renderer/renderer_resources.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2008 The Chromium Authors. All rights reserved. 1 // Copyright (c) 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/scoped_ptr.h" 5 #include "base/scoped_ptr.h"
6 #include "chrome/renderer/mock_render_process.h" 6 #include "chrome/renderer/mock_render_process.h"
7 #include "chrome/renderer/mock_render_thread.h" 7 #include "chrome/renderer/mock_render_thread.h"
8 #include "chrome/renderer/render_view.h" 8 #include "chrome/renderer/render_view.h"
9 #include "testing/gtest/include/gtest/gtest.h" 9 #include "testing/gtest/include/gtest/gtest.h"
10 #include "webkit/glue/webframe.h" 10 #include "webkit/glue/webframe.h"
(...skipping 18 matching lines...) Expand all
29 } 29 }
30 30
31 // Returns a pointer to the main frame. 31 // Returns a pointer to the main frame.
32 WebFrame* GetMainFrame() { 32 WebFrame* GetMainFrame() {
33 return view_->webview()->GetMainFrame(); 33 return view_->webview()->GetMainFrame();
34 } 34 }
35 35
36 // Executes the given JavaScript in the context of the main frame. The input 36 // Executes the given JavaScript in the context of the main frame. The input
37 // is a NULL-terminated UTF-8 string. 37 // is a NULL-terminated UTF-8 string.
38 void ExecuteJavaScript(const char* js) { 38 void ExecuteJavaScript(const char* js) {
39 GetMainFrame()->ExecuteJavaScript(js, GURL()); 39 GetMainFrame()->ExecuteJavaScript(js,
40 GURL(), // script url
41 1); // base line number
40 } 42 }
41 43
42 // Loads the given HTML into the main frame as a data: URL. 44 // Loads the given HTML into the main frame as a data: URL.
43 void LoadHTML(const char* html) { 45 void LoadHTML(const char* html) {
44 std::string url_str = "data:text/html;charset=utf-8,"; 46 std::string url_str = "data:text/html;charset=utf-8,";
45 url_str.append(html); 47 url_str.append(html);
46 GURL url(url_str); 48 GURL url(url_str);
47 49
48 scoped_ptr<WebRequest> request(WebRequest::Create(url)); 50 scoped_ptr<WebRequest> request(WebRequest::Create(url));
49 GetMainFrame()->LoadRequest(request.get()); 51 GetMainFrame()->LoadRequest(request.get());
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
119 ViewHostMsg_UpdateState::ID)); 121 ViewHostMsg_UpdateState::ID));
120 render_thread_.ClearMessages(); 122 render_thread_.ClearMessages();
121 123
122 // Change the value of the input. We should have gotten an update state 124 // Change the value of the input. We should have gotten an update state
123 // notification. We need to spin the message loop to catch this update. 125 // notification. We need to spin the message loop to catch this update.
124 ExecuteJavaScript("document.getElementById('elt_text').value = 'foo';"); 126 ExecuteJavaScript("document.getElementById('elt_text').value = 'foo';");
125 ProcessPendingMessages(); 127 ProcessPendingMessages();
126 EXPECT_TRUE(render_thread_.GetUniqueMessageMatching( 128 EXPECT_TRUE(render_thread_.GetUniqueMessageMatching(
127 ViewHostMsg_UpdateState::ID)); 129 ViewHostMsg_UpdateState::ID));
128 } 130 }
OLDNEW
« no previous file with comments | « chrome/renderer/render_view.cc ('k') | chrome/renderer/renderer_resources.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698