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