OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2010 Google Inc. All rights reserved. | 2 * Copyright (C) 2010 Google Inc. All rights reserved. |
3 * | 3 * |
4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
6 * met: | 6 * met: |
7 * | 7 * |
8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
(...skipping 12 matching lines...) Expand all Loading... |
23 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | 23 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | 24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | 25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
29 */ | 29 */ |
30 | 30 |
31 #include "config.h" | 31 #include "config.h" |
32 | 32 |
33 #include "FrameTestHelpers.h" | |
34 #include "ResourceError.h" | 33 #include "ResourceError.h" |
35 #include "WebDocument.h" | 34 #include "WebDocument.h" |
36 #include "WebFormElement.h" | 35 #include "WebFormElement.h" |
37 #include "WebFrame.h" | 36 #include "WebFrame.h" |
38 #include "WebFrameClient.h" | 37 #include "WebFrameClient.h" |
39 #include "WebScriptSource.h" | 38 #include "WebScriptSource.h" |
40 #include "WebSearchableFormData.h" | 39 #include "WebSearchableFormData.h" |
41 #include "WebSecurityPolicy.h" | 40 #include "WebSecurityPolicy.h" |
42 #include "WebSettings.h" | 41 #include "WebSettings.h" |
| 42 #include "WebString.h" |
| 43 #include "WebURL.h" |
| 44 #include "WebURLRequest.h" |
| 45 #include "WebURLResponse.h" |
| 46 #include "WebViewClient.h" |
43 #include "WebViewImpl.h" | 47 #include "WebViewImpl.h" |
44 #include "v8.h" | 48 #include "v8.h" |
| 49 #include <googleurl/src/gurl.h> |
45 #include <gtest/gtest.h> | 50 #include <gtest/gtest.h> |
46 #include <webkit/support/webkit_support.h> | 51 #include <webkit/support/webkit_support.h> |
47 | 52 |
48 using namespace WebKit; | 53 using namespace WebKit; |
49 | 54 |
50 namespace { | 55 namespace { |
51 | 56 |
52 class WebFrameTest : public testing::Test { | 57 class WebFrameTest : public testing::Test { |
53 public: | 58 public: |
54 WebFrameTest() | 59 WebFrameTest() |
55 : m_baseURL("http://www.test.com/"), | 60 : baseURL("http://www.test.com/"), |
56 m_chromeURL("chrome://") | 61 chromeURL("chrome://") |
57 { | 62 { |
58 } | 63 } |
59 | 64 |
60 virtual void TearDown() | 65 virtual void TearDown() |
61 { | 66 { |
62 webkit_support::UnregisterAllMockedURLs(); | 67 webkit_support::UnregisterAllMockedURLs(); |
63 } | 68 } |
64 | 69 |
65 void registerMockedHttpURLLoad(const std::string& fileName) | 70 void registerMockedHttpURLLoad(const std::string& fileName) |
66 { | 71 { |
67 FrameTestHelpers::registerMockedURLLoad(m_baseURL, fileName); | 72 registerMockedURLLoad(baseURL, fileName); |
68 } | 73 } |
69 | 74 |
70 void registerMockedChromeURLLoad(const std::string& fileName) | 75 void registerMockedChromeURLLoad(const std::string& fileName) |
71 { | 76 { |
72 FrameTestHelpers::registerMockedURLLoad(m_chromeURL, fileName); | 77 registerMockedURLLoad(chromeURL, fileName); |
| 78 } |
| 79 |
| 80 void serveRequests() |
| 81 { |
| 82 webkit_support::ServeAsynchronousMockedRequests(); |
| 83 } |
| 84 |
| 85 void loadHttpFrame(WebFrame* frame, const std::string& fileName) |
| 86 { |
| 87 loadFrame(frame, baseURL, fileName); |
| 88 } |
| 89 |
| 90 void loadChromeFrame(WebFrame* frame, const std::string& fileName) |
| 91 { |
| 92 loadFrame(frame, chromeURL, fileName); |
| 93 } |
| 94 |
| 95 void registerMockedURLLoad(const std::string& base, const std::string& fileN
ame) |
| 96 { |
| 97 WebURLResponse response; |
| 98 response.initialize(); |
| 99 response.setMIMEType("text/html"); |
| 100 |
| 101 std::string filePath = webkit_support::GetWebKitRootDir().utf8(); |
| 102 filePath += "/Source/WebKit/chromium/tests/data/"; |
| 103 filePath += fileName; |
| 104 |
| 105 webkit_support::RegisterMockedURL(WebURL(GURL(base + fileName)), respons
e, WebString::fromUTF8(filePath)); |
| 106 } |
| 107 |
| 108 void loadFrame(WebFrame* frame, const std::string& base, const std::string&
fileName) |
| 109 { |
| 110 WebURLRequest urlRequest; |
| 111 urlRequest.initialize(); |
| 112 urlRequest.setURL(WebURL(GURL(base + fileName))); |
| 113 frame->loadRequest(urlRequest); |
73 } | 114 } |
74 | 115 |
75 protected: | 116 protected: |
76 std::string m_baseURL; | 117 std::string baseURL; |
77 std::string m_chromeURL; | 118 std::string chromeURL; |
| 119 }; |
| 120 |
| 121 class TestWebFrameClient : public WebFrameClient { |
| 122 }; |
| 123 |
| 124 class TestWebViewClient : public WebViewClient { |
78 }; | 125 }; |
79 | 126 |
80 TEST_F(WebFrameTest, ContentText) | 127 TEST_F(WebFrameTest, ContentText) |
81 { | 128 { |
82 registerMockedHttpURLLoad("iframes_test.html"); | 129 registerMockedHttpURLLoad("iframes_test.html"); |
83 registerMockedHttpURLLoad("visible_iframe.html"); | 130 registerMockedHttpURLLoad("visible_iframe.html"); |
84 registerMockedHttpURLLoad("invisible_iframe.html"); | 131 registerMockedHttpURLLoad("invisible_iframe.html"); |
85 registerMockedHttpURLLoad("zero_sized_iframe.html"); | 132 registerMockedHttpURLLoad("zero_sized_iframe.html"); |
86 | 133 |
87 WebView* webView = FrameTestHelpers::createWebViewAndLoad(m_baseURL + "ifram
es_test.html"); | 134 // Create and initialize the WebView. |
| 135 TestWebFrameClient webFrameClient; |
| 136 WebView* webView = WebView::create(0); |
| 137 webView->initializeMainFrame(&webFrameClient); |
| 138 |
| 139 loadHttpFrame(webView->mainFrame(), "iframes_test.html"); |
| 140 serveRequests(); |
88 | 141 |
89 // Now retrieve the frames text and test it only includes visible elements. | 142 // Now retrieve the frames text and test it only includes visible elements. |
90 std::string content = webView->mainFrame()->contentAsText(1024).utf8(); | 143 std::string content = webView->mainFrame()->contentAsText(1024).utf8(); |
91 EXPECT_NE(std::string::npos, content.find(" visible paragraph")); | 144 EXPECT_NE(std::string::npos, content.find(" visible paragraph")); |
92 EXPECT_NE(std::string::npos, content.find(" visible iframe")); | 145 EXPECT_NE(std::string::npos, content.find(" visible iframe")); |
93 EXPECT_EQ(std::string::npos, content.find(" invisible pararaph")); | 146 EXPECT_EQ(std::string::npos, content.find(" invisible pararaph")); |
94 EXPECT_EQ(std::string::npos, content.find(" invisible iframe")); | 147 EXPECT_EQ(std::string::npos, content.find(" invisible iframe")); |
95 EXPECT_EQ(std::string::npos, content.find("iframe with zero size")); | 148 EXPECT_EQ(std::string::npos, content.find("iframe with zero size")); |
96 | 149 |
97 webView->close(); | 150 webView->close(); |
98 } | 151 } |
99 | 152 |
100 TEST_F(WebFrameTest, FrameForEnteredContext) | 153 TEST_F(WebFrameTest, FrameForEnteredContext) |
101 { | 154 { |
102 registerMockedHttpURLLoad("iframes_test.html"); | 155 registerMockedHttpURLLoad("iframes_test.html"); |
103 registerMockedHttpURLLoad("visible_iframe.html"); | 156 registerMockedHttpURLLoad("visible_iframe.html"); |
104 registerMockedHttpURLLoad("invisible_iframe.html"); | 157 registerMockedHttpURLLoad("invisible_iframe.html"); |
105 registerMockedHttpURLLoad("zero_sized_iframe.html"); | 158 registerMockedHttpURLLoad("zero_sized_iframe.html"); |
106 | 159 |
107 WebView* webView = FrameTestHelpers::createWebViewAndLoad(m_baseURL + "ifram
es_test.html", true); | 160 // Create and initialize the WebView. |
| 161 TestWebFrameClient webFrameClient; |
| 162 WebView* webView = WebView::create(0); |
| 163 webView->settings()->setJavaScriptEnabled(true); |
| 164 webView->initializeMainFrame(&webFrameClient); |
| 165 |
| 166 loadHttpFrame(webView->mainFrame(), "iframes_test.html"); |
| 167 serveRequests(); |
108 | 168 |
109 v8::HandleScope scope; | 169 v8::HandleScope scope; |
110 EXPECT_EQ(webView->mainFrame(), | 170 EXPECT_EQ(webView->mainFrame(), |
111 WebFrame::frameForContext( | 171 WebFrame::frameForContext( |
112 webView->mainFrame()->mainWorldScriptContext())); | 172 webView->mainFrame()->mainWorldScriptContext())); |
113 EXPECT_EQ(webView->mainFrame()->firstChild(), | 173 EXPECT_EQ(webView->mainFrame()->firstChild(), |
114 WebFrame::frameForContext( | 174 WebFrame::frameForContext( |
115 webView->mainFrame()->firstChild()->mainWorldScriptContext()))
; | 175 webView->mainFrame()->firstChild()->mainWorldScriptContext()))
; |
116 | 176 |
117 webView->close(); | 177 webView->close(); |
118 } | 178 } |
119 | 179 |
120 TEST_F(WebFrameTest, FormWithNullFrame) | 180 TEST_F(WebFrameTest, FormWithNullFrame) |
121 { | 181 { |
122 registerMockedHttpURLLoad("form.html"); | 182 registerMockedHttpURLLoad("form.html"); |
123 | 183 |
124 WebView* webView = FrameTestHelpers::createWebViewAndLoad(m_baseURL + "form.
html"); | 184 TestWebFrameClient webFrameClient; |
| 185 WebView* webView = WebView::create(0); |
| 186 webView->initializeMainFrame(&webFrameClient); |
| 187 |
| 188 loadHttpFrame(webView->mainFrame(), "form.html"); |
| 189 serveRequests(); |
125 | 190 |
126 WebVector<WebFormElement> forms; | 191 WebVector<WebFormElement> forms; |
127 webView->mainFrame()->document().forms(forms); | 192 webView->mainFrame()->document().forms(forms); |
128 webView->close(); | 193 webView->close(); |
129 | 194 |
130 EXPECT_EQ(forms.size(), 1U); | 195 EXPECT_EQ(forms.size(), 1U); |
131 | 196 |
132 // This test passes if this doesn't crash. | 197 // This test passes if this doesn't crash. |
133 WebSearchableFormData searchableDataForm(forms[0]); | 198 WebSearchableFormData searchableDataForm(forms[0]); |
134 } | 199 } |
135 | 200 |
136 TEST_F(WebFrameTest, ChromePageNoJavascript) | 201 TEST_F(WebFrameTest, ChromePageNoJavascript) |
137 { | 202 { |
138 registerMockedChromeURLLoad("history.html"); | 203 registerMockedChromeURLLoad("history.html"); |
139 | 204 |
140 WebView* webView = FrameTestHelpers::createWebViewAndLoad(m_chromeURL + "his
tory.html", true); | 205 // Create and initialize the WebView. |
| 206 TestWebFrameClient webFrameClient; |
| 207 WebView* webView = WebView::create(0); |
| 208 webView->settings()->setJavaScriptEnabled(true); |
| 209 webView->initializeMainFrame(&webFrameClient); |
| 210 |
| 211 loadChromeFrame(webView->mainFrame(), "history.html"); |
| 212 serveRequests(); |
141 | 213 |
142 // Try to run JS against the chrome-style URL. | 214 // Try to run JS against the chrome-style URL. |
143 WebSecurityPolicy::registerURLSchemeAsNotAllowingJavascriptURLs("chrome"); | 215 WebSecurityPolicy::registerURLSchemeAsNotAllowingJavascriptURLs("chrome"); |
144 FrameTestHelpers::loadFrame(webView->mainFrame(), "javascript:document.body.
appendChild(document.createTextNode('Clobbered'))"); | 216 loadFrame(webView->mainFrame(), "javascript:", "document.body.appendChild(do
cument.createTextNode('Clobbered'))"); |
145 | 217 |
146 // Now retrieve the frames text and see if it was clobbered. | 218 // Now retrieve the frames text and see if it was clobbered. |
147 std::string content = webView->mainFrame()->contentAsText(1024).utf8(); | 219 std::string content = webView->mainFrame()->contentAsText(1024).utf8(); |
148 EXPECT_NE(std::string::npos, content.find("Simulated Chromium History Page")
); | 220 EXPECT_NE(std::string::npos, content.find("Simulated Chromium History Page")
); |
149 EXPECT_EQ(std::string::npos, content.find("Clobbered")); | 221 EXPECT_EQ(std::string::npos, content.find("Clobbered")); |
150 } | 222 } |
151 | 223 |
152 class TestReloadDoesntRedirectWebFrameClient : public WebFrameClient { | 224 class TestReloadDoesntRedirectWebFrameClient : public WebFrameClient { |
153 public: | 225 public: |
154 virtual WebNavigationPolicy decidePolicyForNavigation( | 226 virtual WebNavigationPolicy decidePolicyForNavigation( |
(...skipping 13 matching lines...) Expand all Loading... |
168 } | 240 } |
169 }; | 241 }; |
170 | 242 |
171 TEST_F(WebFrameTest, ReloadDoesntSetRedirect) | 243 TEST_F(WebFrameTest, ReloadDoesntSetRedirect) |
172 { | 244 { |
173 // Test for case in http://crbug.com/73104. Reloading a frame very quickly | 245 // Test for case in http://crbug.com/73104. Reloading a frame very quickly |
174 // would sometimes call decidePolicyForNavigation with isRedirect=true | 246 // would sometimes call decidePolicyForNavigation with isRedirect=true |
175 registerMockedHttpURLLoad("form.html"); | 247 registerMockedHttpURLLoad("form.html"); |
176 | 248 |
177 TestReloadDoesntRedirectWebFrameClient webFrameClient; | 249 TestReloadDoesntRedirectWebFrameClient webFrameClient; |
178 WebView* webView = FrameTestHelpers::createWebViewAndLoad(m_baseURL + "form.
html", false, &webFrameClient); | 250 WebView* webView = WebView::create(0); |
| 251 webView->initializeMainFrame(&webFrameClient); |
| 252 |
| 253 loadHttpFrame(webView->mainFrame(), "form.html"); |
| 254 serveRequests(); |
| 255 // Frame is loaded. |
179 | 256 |
180 webView->mainFrame()->reload(true); | 257 webView->mainFrame()->reload(true); |
181 // start reload before request is delivered. | 258 // start reload before request is delivered. |
182 webView->mainFrame()->reload(true); | 259 webView->mainFrame()->reload(true); |
183 webkit_support::ServeAsynchronousMockedRequests(); | 260 serveRequests(); |
184 } | 261 } |
185 | 262 |
186 TEST_F(WebFrameTest, ClearFocusedNodeTest) | 263 TEST_F(WebFrameTest, ClearFocusedNodeTest) |
187 { | 264 { |
188 registerMockedHttpURLLoad("iframe_clear_focused_node_test.html"); | 265 registerMockedHttpURLLoad("iframe_clear_focused_node_test.html"); |
189 registerMockedHttpURLLoad("autofocus_input_field_iframe.html"); | 266 registerMockedHttpURLLoad("autofocus_input_field_iframe.html"); |
190 | 267 |
191 WebViewImpl* webViewImpl = static_cast<WebViewImpl*>(FrameTestHelpers::creat
eWebViewAndLoad(m_baseURL + "iframe_clear_focused_node_test.html", true)); | 268 // Create and initialize the WebView. |
| 269 TestWebFrameClient webFrameClient; |
| 270 TestWebViewClient webviewClient; |
| 271 WebViewImpl* webViewImpl = static_cast<WebViewImpl*>(WebView::create(&webvie
wClient)); |
| 272 webViewImpl->settings()->setJavaScriptEnabled(true); |
| 273 webViewImpl->initializeMainFrame(&webFrameClient); |
| 274 |
| 275 loadHttpFrame(webViewImpl->mainFrame(), "iframe_clear_focused_node_test.html
"); |
| 276 serveRequests(); |
192 | 277 |
193 // Clear the focused node. | 278 // Clear the focused node. |
194 webViewImpl->clearFocusedNode(); | 279 webViewImpl->clearFocusedNode(); |
195 | 280 |
196 // Now retrieve the FocusedNode and test it should be null. | 281 // Now retrieve the FocusedNode and test it should be null. |
197 EXPECT_EQ(0, webViewImpl->focusedWebCoreNode()); | 282 EXPECT_EQ(0, webViewImpl->focusedWebCoreNode()); |
198 | 283 |
199 webViewImpl->close(); | 284 webViewImpl->close(); |
200 } | 285 } |
201 | 286 |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
261 | 346 |
262 TEST_F(WebFrameTest, ContextNotificationsLoadUnload) | 347 TEST_F(WebFrameTest, ContextNotificationsLoadUnload) |
263 { | 348 { |
264 v8::HandleScope handleScope; | 349 v8::HandleScope handleScope; |
265 | 350 |
266 registerMockedHttpURLLoad("context_notifications_test.html"); | 351 registerMockedHttpURLLoad("context_notifications_test.html"); |
267 registerMockedHttpURLLoad("context_notifications_test_frame.html"); | 352 registerMockedHttpURLLoad("context_notifications_test_frame.html"); |
268 | 353 |
269 // Load a frame with an iframe, make sure we get the right create notificati
ons. | 354 // Load a frame with an iframe, make sure we get the right create notificati
ons. |
270 ContextLifetimeTestWebFrameClient webFrameClient; | 355 ContextLifetimeTestWebFrameClient webFrameClient; |
271 WebView* webView = FrameTestHelpers::createWebViewAndLoad(m_baseURL + "conte
xt_notifications_test.html", true, &webFrameClient); | 356 WebView* webView = WebView::create(0); |
| 357 webView->settings()->setJavaScriptEnabled(true); |
| 358 webView->initializeMainFrame(&webFrameClient); |
| 359 loadHttpFrame(webView->mainFrame(), "context_notifications_test.html"); |
| 360 serveRequests(); |
272 | 361 |
273 WebFrame* mainFrame = webView->mainFrame(); | 362 WebFrame* mainFrame = webView->mainFrame(); |
274 WebFrame* childFrame = mainFrame->firstChild(); | 363 WebFrame* childFrame = mainFrame->firstChild(); |
275 | 364 |
276 ASSERT_EQ(2u, webFrameClient.createNotifications.size()); | 365 ASSERT_EQ(2u, webFrameClient.createNotifications.size()); |
277 EXPECT_EQ(0u, webFrameClient.releaseNotifications.size()); | 366 EXPECT_EQ(0u, webFrameClient.releaseNotifications.size()); |
278 | 367 |
279 ContextLifetimeTestWebFrameClient::Notification* firstCreateNotification = w
ebFrameClient.createNotifications[0]; | 368 ContextLifetimeTestWebFrameClient::Notification* firstCreateNotification = w
ebFrameClient.createNotifications[0]; |
280 ContextLifetimeTestWebFrameClient::Notification* secondCreateNotification =
webFrameClient.createNotifications[1]; | 369 ContextLifetimeTestWebFrameClient::Notification* secondCreateNotification =
webFrameClient.createNotifications[1]; |
281 | 370 |
(...skipping 17 matching lines...) Expand all Loading... |
299 } | 388 } |
300 | 389 |
301 TEST_F(WebFrameTest, ContextNotificationsReload) | 390 TEST_F(WebFrameTest, ContextNotificationsReload) |
302 { | 391 { |
303 v8::HandleScope handleScope; | 392 v8::HandleScope handleScope; |
304 | 393 |
305 registerMockedHttpURLLoad("context_notifications_test.html"); | 394 registerMockedHttpURLLoad("context_notifications_test.html"); |
306 registerMockedHttpURLLoad("context_notifications_test_frame.html"); | 395 registerMockedHttpURLLoad("context_notifications_test_frame.html"); |
307 | 396 |
308 ContextLifetimeTestWebFrameClient webFrameClient; | 397 ContextLifetimeTestWebFrameClient webFrameClient; |
309 WebView* webView = FrameTestHelpers::createWebViewAndLoad(m_baseURL + "conte
xt_notifications_test.html", true, &webFrameClient); | 398 WebView* webView = WebView::create(0); |
| 399 webView->settings()->setJavaScriptEnabled(true); |
| 400 webView->initializeMainFrame(&webFrameClient); |
| 401 loadHttpFrame(webView->mainFrame(), "context_notifications_test.html"); |
| 402 serveRequests(); |
310 | 403 |
311 // Refresh, we should get two release notifications and two more create noti
fications. | 404 // Refresh, we should get two release notifications and two more create noti
fications. |
312 webView->mainFrame()->reload(false); | 405 webView->mainFrame()->reload(false); |
313 webkit_support::ServeAsynchronousMockedRequests(); | 406 serveRequests(); |
314 ASSERT_EQ(4u, webFrameClient.createNotifications.size()); | 407 ASSERT_EQ(4u, webFrameClient.createNotifications.size()); |
315 ASSERT_EQ(2u, webFrameClient.releaseNotifications.size()); | 408 ASSERT_EQ(2u, webFrameClient.releaseNotifications.size()); |
316 | 409 |
317 // The two release notifications we got should be exactly the same as the fi
rst two create notifications. | 410 // The two release notifications we got should be exactly the same as the fi
rst two create notifications. |
318 for (size_t i = 0; i < webFrameClient.releaseNotifications.size(); ++i) { | 411 for (size_t i = 0; i < webFrameClient.releaseNotifications.size(); ++i) { |
319 EXPECT_TRUE(webFrameClient.releaseNotifications[i]->Equals( | 412 EXPECT_TRUE(webFrameClient.releaseNotifications[i]->Equals( |
320 webFrameClient.createNotifications[webFrameClient.createNotifications.
size() - 3 - i])); | 413 webFrameClient.createNotifications[webFrameClient.createNotifications.
size() - 3 - i])); |
321 } | 414 } |
322 | 415 |
323 // The last two create notifications should be for the current frames and co
ntext. | 416 // The last two create notifications should be for the current frames and co
ntext. |
(...skipping 14 matching lines...) Expand all Loading... |
338 } | 431 } |
339 | 432 |
340 TEST_F(WebFrameTest, ContextNotificationsIsolatedWorlds) | 433 TEST_F(WebFrameTest, ContextNotificationsIsolatedWorlds) |
341 { | 434 { |
342 v8::HandleScope handleScope; | 435 v8::HandleScope handleScope; |
343 | 436 |
344 registerMockedHttpURLLoad("context_notifications_test.html"); | 437 registerMockedHttpURLLoad("context_notifications_test.html"); |
345 registerMockedHttpURLLoad("context_notifications_test_frame.html"); | 438 registerMockedHttpURLLoad("context_notifications_test_frame.html"); |
346 | 439 |
347 ContextLifetimeTestWebFrameClient webFrameClient; | 440 ContextLifetimeTestWebFrameClient webFrameClient; |
348 WebView* webView = FrameTestHelpers::createWebViewAndLoad(m_baseURL + "conte
xt_notifications_test.html", true, &webFrameClient); | 441 WebView* webView = WebView::create(0); |
| 442 webView->settings()->setJavaScriptEnabled(true); |
| 443 webView->initializeMainFrame(&webFrameClient); |
| 444 loadHttpFrame(webView->mainFrame(), "context_notifications_test.html"); |
| 445 serveRequests(); |
349 | 446 |
350 // Add an isolated world. | 447 // Add an isolated world. |
351 webFrameClient.reset(); | 448 webFrameClient.reset(); |
352 | 449 |
353 int isolatedWorldId = 42; | 450 int isolatedWorldId = 42; |
354 WebScriptSource scriptSource("hi!"); | 451 WebScriptSource scriptSource("hi!"); |
355 int numSources = 1; | 452 int numSources = 1; |
356 int extensionGroup = 0; | 453 int extensionGroup = 0; |
357 webView->mainFrame()->executeScriptInIsolatedWorld(isolatedWorldId, &scriptS
ource, numSources, extensionGroup); | 454 webView->mainFrame()->executeScriptInIsolatedWorld(isolatedWorldId, &scriptS
ource, numSources, extensionGroup); |
358 | 455 |
(...skipping 14 matching lines...) Expand all Loading... |
373 // And one of them should be exactly the same as the create notification for
the isolated context. | 470 // And one of them should be exactly the same as the create notification for
the isolated context. |
374 int matchCount = 0; | 471 int matchCount = 0; |
375 for (size_t i = 0; i < webFrameClient.releaseNotifications.size(); ++i) { | 472 for (size_t i = 0; i < webFrameClient.releaseNotifications.size(); ++i) { |
376 if (webFrameClient.releaseNotifications[i]->Equals(webFrameClient.createNo
tifications[0])) | 473 if (webFrameClient.releaseNotifications[i]->Equals(webFrameClient.createNo
tifications[0])) |
377 ++matchCount; | 474 ++matchCount; |
378 } | 475 } |
379 EXPECT_EQ(1, matchCount); | 476 EXPECT_EQ(1, matchCount); |
380 } | 477 } |
381 | 478 |
382 } // namespace | 479 } // namespace |
OLD | NEW |