OLD | NEW |
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 "base/basictypes.h" | 5 #include "base/basictypes.h" |
6 | 6 |
7 #include "base/memory/shared_memory.h" | 7 #include "base/memory/shared_memory.h" |
8 #include "base/strings/string_util.h" | 8 #include "base/strings/string_util.h" |
9 #include "base/strings/utf_string_conversions.h" | 9 #include "base/strings/utf_string_conversions.h" |
10 #include "base/win/windows_version.h" | 10 #include "base/win/windows_version.h" |
(...skipping 18 matching lines...) Expand all Loading... |
29 #include "testing/gtest/include/gtest/gtest.h" | 29 #include "testing/gtest/include/gtest/gtest.h" |
30 #include "third_party/WebKit/public/platform/WebData.h" | 30 #include "third_party/WebKit/public/platform/WebData.h" |
31 #include "third_party/WebKit/public/platform/WebHTTPBody.h" | 31 #include "third_party/WebKit/public/platform/WebHTTPBody.h" |
32 #include "third_party/WebKit/public/platform/WebString.h" | 32 #include "third_party/WebKit/public/platform/WebString.h" |
33 #include "third_party/WebKit/public/platform/WebURLError.h" | 33 #include "third_party/WebKit/public/platform/WebURLError.h" |
34 #include "third_party/WebKit/public/platform/WebURLResponse.h" | 34 #include "third_party/WebKit/public/platform/WebURLResponse.h" |
35 #include "third_party/WebKit/public/web/WebDataSource.h" | 35 #include "third_party/WebKit/public/web/WebDataSource.h" |
36 #include "third_party/WebKit/public/web/WebFrame.h" | 36 #include "third_party/WebKit/public/web/WebFrame.h" |
37 #include "third_party/WebKit/public/web/WebHistoryItem.h" | 37 #include "third_party/WebKit/public/web/WebHistoryItem.h" |
38 #include "third_party/WebKit/public/web/WebRuntimeFeatures.h" | 38 #include "third_party/WebKit/public/web/WebRuntimeFeatures.h" |
| 39 #include "third_party/WebKit/public/web/WebScriptSource.h" |
39 #include "third_party/WebKit/public/web/WebView.h" | 40 #include "third_party/WebKit/public/web/WebView.h" |
40 #include "third_party/WebKit/public/web/WebWindowFeatures.h" | 41 #include "third_party/WebKit/public/web/WebWindowFeatures.h" |
41 #include "ui/events/keycodes/keyboard_codes.h" | 42 #include "ui/events/keycodes/keyboard_codes.h" |
42 #include "ui/gfx/codec/jpeg_codec.h" | 43 #include "ui/gfx/codec/jpeg_codec.h" |
43 #include "ui/gfx/range/range.h" | 44 #include "ui/gfx/range/range.h" |
44 | 45 |
45 #if defined(OS_LINUX) && !defined(USE_AURA) | 46 #if defined(OS_LINUX) && !defined(USE_AURA) |
46 #include "ui/base/gtk/event_synthesis_gtk.h" | 47 #include "ui/base/gtk/event_synthesis_gtk.h" |
47 #endif | 48 #endif |
48 | 49 |
(...skipping 2184 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2233 | 2234 |
2234 view()->webview()->clearFocusedNode(); | 2235 view()->webview()->clearFocusedNode(); |
2235 const IPC::Message* msg3 = render_thread_->sink().GetFirstMessageMatching( | 2236 const IPC::Message* msg3 = render_thread_->sink().GetFirstMessageMatching( |
2236 ViewHostMsg_FocusedNodeChanged::ID); | 2237 ViewHostMsg_FocusedNodeChanged::ID); |
2237 EXPECT_TRUE(msg3); | 2238 EXPECT_TRUE(msg3); |
2238 ViewHostMsg_FocusedNodeChanged::Read(msg3, ¶ms); | 2239 ViewHostMsg_FocusedNodeChanged::Read(msg3, ¶ms); |
2239 EXPECT_FALSE(params.a); | 2240 EXPECT_FALSE(params.a); |
2240 render_thread_->sink().ClearMessages(); | 2241 render_thread_->sink().ClearMessages(); |
2241 } | 2242 } |
2242 | 2243 |
| 2244 class SynchronousFrameRemovalOnLoadTest : public RenderViewImplTest { |
| 2245 protected: |
| 2246 // Helper render view observer class that tries to remove |
| 2247 // element with id 'frame' from top frame/document DOM |
| 2248 // when non-top frame finishes loading. |
| 2249 class OnLoadFrameRemover : public RenderViewObserver { |
| 2250 public: |
| 2251 explicit OnLoadFrameRemover(RenderView* render_view) : |
| 2252 RenderViewObserver(render_view) {} |
| 2253 virtual ~OnLoadFrameRemover() {} |
| 2254 |
| 2255 virtual void DidFinishDocumentLoad(blink::WebFrame* frame) OVERRIDE { |
| 2256 if (frame->top() != frame) { |
| 2257 frame->top()->executeScript(blink::WebScriptSource( |
| 2258 WebString::fromUTF8( |
| 2259 "document.getElementById('frame').remove();"))); |
| 2260 } |
| 2261 } |
| 2262 }; |
| 2263 }; |
| 2264 |
| 2265 // Tests if synchronously removing a frame on its load does not cause crashes. |
| 2266 TEST_F(SynchronousFrameRemovalOnLoadTest, DynamicallyInsertedFrame) { |
| 2267 OnLoadFrameRemover remover(view()); |
| 2268 LoadHTML("<!DOCTYPE html>" |
| 2269 "<html>" |
| 2270 "<head>" |
| 2271 "<title></title>" |
| 2272 "<script type='text/javascript' language='javascript'>" |
| 2273 "window.onload = function () {" |
| 2274 " frame = document.createElement('iframe');" |
| 2275 " frame.id = 'frame';" |
| 2276 " document.body.appendChild(frame);" |
| 2277 "}" |
| 2278 "</script>" |
| 2279 "</head>" |
| 2280 "<body></body>" |
| 2281 "</html>"); |
| 2282 } |
| 2283 |
| 2284 TEST_F(SynchronousFrameRemovalOnLoadTest, StaticFrame) { |
| 2285 OnLoadFrameRemover remover(view()); |
| 2286 LoadHTML("<!DOCTYPE html>" |
| 2287 "<html>" |
| 2288 "<head>" |
| 2289 "<title></title>" |
| 2290 "</head>" |
| 2291 "<body>" |
| 2292 "<iframe id='frame' src='about:blank'></iframe>" |
| 2293 "</body>" |
| 2294 "</html>"); |
| 2295 } |
| 2296 |
2243 } // namespace content | 2297 } // namespace content |
OLD | NEW |