Chromium Code Reviews| 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 2094 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2143 view()->OnCandidateWindowUpdated(); | 2144 view()->OnCandidateWindowUpdated(); |
| 2144 view()->OnCandidateWindowHidden(); | 2145 view()->OnCandidateWindowHidden(); |
| 2145 | 2146 |
| 2146 // Retrieve the content and check if it is expected. | 2147 // Retrieve the content and check if it is expected. |
| 2147 const int kMaxOutputCharacters = 50; | 2148 const int kMaxOutputCharacters = 50; |
| 2148 std::string output = UTF16ToUTF8( | 2149 std::string output = UTF16ToUTF8( |
| 2149 GetMainFrame()->contentAsText(kMaxOutputCharacters)); | 2150 GetMainFrame()->contentAsText(kMaxOutputCharacters)); |
| 2150 EXPECT_EQ(output, "\nResult:showupdatehide"); | 2151 EXPECT_EQ(output, "\nResult:showupdatehide"); |
| 2151 } | 2152 } |
| 2152 | 2153 |
| 2154 class SynchronousFrameRemovalOnLoadTest : public RenderViewImplTest { | |
| 2155 protected: | |
| 2156 // Helper render view observer class that tries to remove | |
| 2157 // element with id 'frame' from top frame/document DOM | |
| 2158 // when non-top frame finishes loading. | |
| 2159 class OnLoadFrameRemover : public RenderViewObserver { | |
| 2160 public: | |
| 2161 OnLoadFrameRemover(RenderView* render_view) : | |
|
jamesr
2014/01/15 18:56:14
one argument constructors must be marked explicit
| |
| 2162 RenderViewObserver(render_view) {} | |
| 2163 virtual ~OnLoadFrameRemover() {} | |
| 2164 | |
| 2165 virtual void DidFinishDocumentLoad(blink::WebFrame* frame) { | |
|
jamesr
2014/01/15 18:56:14
if this is overriding a function from RenderViewOb
| |
| 2166 if (frame->top() != frame) { | |
| 2167 frame->top()->executeScript(blink::WebScriptSource( | |
| 2168 WebString::fromUTF8( | |
| 2169 "document.getElementById('frame').remove();"))); | |
| 2170 } | |
| 2171 } | |
| 2172 }; | |
| 2173 }; | |
| 2174 | |
| 2175 // Tests if synchronously removing a frame on its load does not cause crashes. | |
| 2176 TEST_F(SynchronousFrameRemovalOnLoadTest, DynamicallyInsertedFrame) { | |
| 2177 OnLoadFrameRemover remover(view()); | |
| 2178 LoadHTML("<html>" | |
| 2179 "<head>" | |
| 2180 "<title></title>" | |
| 2181 "<script type='text/javascript' language='javascript'>" | |
| 2182 "window.onload = function () {" | |
| 2183 " frame = document.createElement('iframe');" | |
| 2184 " frame.id = 'frame';" | |
| 2185 " document.body.appendChild(frame);" | |
| 2186 "}" | |
| 2187 "</script>" | |
| 2188 "</head>" | |
| 2189 "<body></body>" | |
| 2190 "</html>"); | |
| 2191 } | |
| 2192 | |
| 2193 TEST_F(SynchronousFrameRemovalOnLoadTest, StaticFrame) { | |
| 2194 OnLoadFrameRemover remover(view()); | |
| 2195 LoadHTML("<html>" | |
| 2196 "<head>" | |
| 2197 "<title></title>" | |
| 2198 "</head>" | |
| 2199 "<body>" | |
| 2200 "<iframe id='frame' src='about:blank'></iframe>" | |
| 2201 "</body>" | |
| 2202 "</html>"); | |
| 2203 } | |
| 2204 | |
| 2153 } // namespace content | 2205 } // namespace content |
| OLD | NEW |