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 181 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
192 : m_baseURL("http://internal.test/"), | 192 : m_baseURL("http://internal.test/"), |
193 m_notBaseURL("http://external.test/"), | 193 m_notBaseURL("http://external.test/"), |
194 m_chromeURL("chrome://") {} | 194 m_chromeURL("chrome://") {} |
195 | 195 |
196 ~WebFrameTest() override { | 196 ~WebFrameTest() override { |
197 Platform::current()->getURLLoaderMockFactory()->unregisterAllURLs(); | 197 Platform::current()->getURLLoaderMockFactory()->unregisterAllURLs(); |
198 WebCache::clear(); | 198 WebCache::clear(); |
199 } | 199 } |
200 | 200 |
201 void registerMockedHttpURLLoad(const std::string& fileName) { | 201 void registerMockedHttpURLLoad(const std::string& fileName) { |
202 URLTestHelpers::registerMockedURLFromBaseURL( | 202 registerMockedURLLoadFromBase(m_baseURL, fileName); |
203 WebString::fromUTF8(m_baseURL.c_str()), | |
204 WebString::fromUTF8(fileName.c_str())); | |
205 } | 203 } |
206 | 204 |
207 void registerMockedChromeURLLoad(const std::string& fileName) { | 205 void registerMockedChromeURLLoad(const std::string& fileName) { |
208 URLTestHelpers::registerMockedURLFromBaseURL( | 206 registerMockedURLLoadFromBase(m_chromeURL, fileName); |
209 WebString::fromUTF8(m_chromeURL.c_str()), | 207 } |
210 WebString::fromUTF8(fileName.c_str())); | 208 |
| 209 void registerMockedURLLoadFromBase(const std::string& baseURL, |
| 210 const std::string& fileName) { |
| 211 URLTestHelpers::registerMockedURLLoadFromBase( |
| 212 WebString::fromUTF8(baseURL), testing::webTestDataPath(), |
| 213 WebString::fromUTF8(fileName)); |
211 } | 214 } |
212 | 215 |
213 void registerMockedHttpURLLoadWithCSP(const std::string& fileName, | 216 void registerMockedHttpURLLoadWithCSP(const std::string& fileName, |
214 const std::string& csp, | 217 const std::string& csp, |
215 bool reportOnly = false) { | 218 bool reportOnly = false) { |
216 WebURLResponse response; | 219 WebURLResponse response; |
217 response.setMIMEType("text/html"); | 220 response.setMIMEType("text/html"); |
218 response.addHTTPHeaderField( | 221 response.addHTTPHeaderField( |
219 reportOnly ? WebString("Content-Security-Policy-Report-Only") | 222 reportOnly ? WebString("Content-Security-Policy-Report-Only") |
220 : WebString("Content-Security-Policy"), | 223 : WebString("Content-Security-Policy"), |
221 WebString::fromUTF8(csp)); | 224 WebString::fromUTF8(csp)); |
222 std::string fullString = m_baseURL + fileName; | 225 std::string fullString = m_baseURL + fileName; |
223 URLTestHelpers::registerMockedURLLoadWithCustomResponse( | 226 URLTestHelpers::registerMockedURLLoadWithCustomResponse( |
224 toKURL(fullString.c_str()), WebString::fromUTF8(fileName.c_str()), | 227 toKURL(fullString), |
225 WebString::fromUTF8(""), response); | 228 testing::webTestDataPath(WebString::fromUTF8(fileName)), response); |
226 } | 229 } |
227 | 230 |
228 void registerMockedHttpURLLoadWithMimeType(const std::string& fileName, | 231 void registerMockedHttpURLLoadWithMimeType(const std::string& fileName, |
229 const std::string& mimeType) { | 232 const std::string& mimeType) { |
230 URLTestHelpers::registerMockedURLFromBaseURL( | 233 URLTestHelpers::registerMockedURLLoadFromBase( |
231 WebString::fromUTF8(m_baseURL.c_str()), | 234 WebString::fromUTF8(m_baseURL), testing::webTestDataPath(), |
232 WebString::fromUTF8(fileName.c_str()), WebString::fromUTF8(mimeType)); | 235 WebString::fromUTF8(fileName), WebString::fromUTF8(mimeType)); |
233 } | 236 } |
234 | 237 |
235 void applyViewportStyleOverride( | 238 void applyViewportStyleOverride( |
236 FrameTestHelpers::WebViewHelper* webViewHelper) { | 239 FrameTestHelpers::WebViewHelper* webViewHelper) { |
237 webViewHelper->webView()->settings()->setViewportStyle( | 240 webViewHelper->webView()->settings()->setViewportStyle( |
238 WebViewportStyle::Mobile); | 241 WebViewportStyle::Mobile); |
239 } | 242 } |
240 | 243 |
241 static void configureCompositingWebView(WebSettings* settings) { | 244 static void configureCompositingWebView(WebSettings* settings) { |
242 settings->setAcceleratedCompositingEnabled(true); | 245 settings->setAcceleratedCompositingEnabled(true); |
(...skipping 374 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
617 // javascript. | 620 // javascript. |
618 std::string content = | 621 std::string content = |
619 WebFrameContentDumper::dumpWebViewAsText(webViewHelper.webView(), 1024) | 622 WebFrameContentDumper::dumpWebViewAsText(webViewHelper.webView(), 1024) |
620 .utf8(); | 623 .utf8(); |
621 EXPECT_EQ(std::string::npos, content.find("Clobbered")); | 624 EXPECT_EQ(std::string::npos, content.find("Clobbered")); |
622 } | 625 } |
623 | 626 |
624 TEST_P(ParameterizedWebFrameTest, LocationSetHostWithMissingPort) { | 627 TEST_P(ParameterizedWebFrameTest, LocationSetHostWithMissingPort) { |
625 std::string fileName = "print-location-href.html"; | 628 std::string fileName = "print-location-href.html"; |
626 registerMockedHttpURLLoad(fileName); | 629 registerMockedHttpURLLoad(fileName); |
627 URLTestHelpers::registerMockedURLLoad( | 630 registerMockedURLLoadFromBase("http://internal.test:0/", fileName); |
628 toKURL("http://internal.test:0/" + fileName), | |
629 WebString::fromUTF8(fileName)); | |
630 | 631 |
631 FrameTestHelpers::WebViewHelper webViewHelper; | 632 FrameTestHelpers::WebViewHelper webViewHelper; |
632 | 633 |
633 /// Pass true to enable JavaScript. | 634 /// Pass true to enable JavaScript. |
634 webViewHelper.initializeAndLoad(m_baseURL + fileName, true); | 635 webViewHelper.initializeAndLoad(m_baseURL + fileName, true); |
635 | 636 |
636 // Setting host to "hostname:" should be treated as "hostname:0". | 637 // Setting host to "hostname:" should be treated as "hostname:0". |
637 FrameTestHelpers::loadFrame( | 638 FrameTestHelpers::loadFrame( |
638 webViewHelper.webView()->mainFrame(), | 639 webViewHelper.webView()->mainFrame(), |
639 "javascript:location.host = 'internal.test:'; void 0;"); | 640 "javascript:location.host = 'internal.test:'; void 0;"); |
640 | 641 |
641 FrameTestHelpers::loadFrame( | 642 FrameTestHelpers::loadFrame( |
642 webViewHelper.webView()->mainFrame(), | 643 webViewHelper.webView()->mainFrame(), |
643 "javascript:document.body.textContent = location.href; void 0;"); | 644 "javascript:document.body.textContent = location.href; void 0;"); |
644 | 645 |
645 std::string content = | 646 std::string content = |
646 WebFrameContentDumper::dumpWebViewAsText(webViewHelper.webView(), 1024) | 647 WebFrameContentDumper::dumpWebViewAsText(webViewHelper.webView(), 1024) |
647 .utf8(); | 648 .utf8(); |
648 EXPECT_EQ("http://internal.test:0/" + fileName, content); | 649 EXPECT_EQ("http://internal.test:0/" + fileName, content); |
649 } | 650 } |
650 | 651 |
651 TEST_P(ParameterizedWebFrameTest, LocationSetEmptyPort) { | 652 TEST_P(ParameterizedWebFrameTest, LocationSetEmptyPort) { |
652 std::string fileName = "print-location-href.html"; | 653 std::string fileName = "print-location-href.html"; |
653 registerMockedHttpURLLoad(fileName); | 654 registerMockedHttpURLLoad(fileName); |
654 URLTestHelpers::registerMockedURLLoad( | 655 registerMockedURLLoadFromBase("http://internal.test:0/", fileName); |
655 toKURL("http://internal.test:0/" + fileName), | |
656 WebString::fromUTF8(fileName)); | |
657 | 656 |
658 FrameTestHelpers::WebViewHelper webViewHelper; | 657 FrameTestHelpers::WebViewHelper webViewHelper; |
659 | 658 |
660 /// Pass true to enable JavaScript. | 659 /// Pass true to enable JavaScript. |
661 webViewHelper.initializeAndLoad(m_baseURL + fileName, true); | 660 webViewHelper.initializeAndLoad(m_baseURL + fileName, true); |
662 | 661 |
663 FrameTestHelpers::loadFrame(webViewHelper.webView()->mainFrame(), | 662 FrameTestHelpers::loadFrame(webViewHelper.webView()->mainFrame(), |
664 "javascript:location.port = ''; void 0;"); | 663 "javascript:location.port = ''; void 0;"); |
665 | 664 |
666 FrameTestHelpers::loadFrame( | 665 FrameTestHelpers::loadFrame( |
(...skipping 6149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6816 client.reset(); | 6815 client.reset(); |
6817 | 6816 |
6818 // Programmatic scroll to same offset. No scroll event should be generated. | 6817 // Programmatic scroll to same offset. No scroll event should be generated. |
6819 frameImpl->executeScript(WebScriptSource("window.scrollTo(0, 20);")); | 6818 frameImpl->executeScript(WebScriptSource("window.scrollTo(0, 20);")); |
6820 EXPECT_FALSE(client.wasFrameScrolled()); | 6819 EXPECT_FALSE(client.wasFrameScrolled()); |
6821 EXPECT_FALSE(initialScrollState.wasScrolledByUser); | 6820 EXPECT_FALSE(initialScrollState.wasScrolledByUser); |
6822 client.reset(); | 6821 client.reset(); |
6823 } | 6822 } |
6824 | 6823 |
6825 TEST_P(ParameterizedWebFrameTest, FirstPartyForCookiesForRedirect) { | 6824 TEST_P(ParameterizedWebFrameTest, FirstPartyForCookiesForRedirect) { |
6826 String filePath = testing::blinkRootDir(); | 6825 String filePath = testing::webTestDataPath("first_party.html"); |
6827 filePath.append("/Source/web/tests/data/first_party.html"); | |
6828 | 6826 |
6829 WebURL testURL(toKURL("http://internal.test/first_party_redirect.html")); | 6827 WebURL testURL(toKURL("http://internal.test/first_party_redirect.html")); |
6830 char redirect[] = "http://internal.test/first_party.html"; | 6828 char redirect[] = "http://internal.test/first_party.html"; |
6831 WebURL redirectURL(toKURL(redirect)); | 6829 WebURL redirectURL(toKURL(redirect)); |
6832 WebURLResponse redirectResponse; | 6830 WebURLResponse redirectResponse; |
6833 redirectResponse.setMIMEType("text/html"); | 6831 redirectResponse.setMIMEType("text/html"); |
6834 redirectResponse.setHTTPStatusCode(302); | 6832 redirectResponse.setHTTPStatusCode(302); |
6835 redirectResponse.setHTTPHeaderField("Location", redirect); | 6833 redirectResponse.setHTTPHeaderField("Location", redirect); |
6836 Platform::current()->getURLLoaderMockFactory()->registerURL( | 6834 Platform::current()->getURLLoaderMockFactory()->registerURL( |
6837 testURL, redirectResponse, filePath); | 6835 testURL, redirectResponse, filePath); |
(...skipping 1405 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
8243 Document* document = | 8241 Document* document = |
8244 webViewHelper.webView()->mainFrameImpl()->frame()->document(); | 8242 webViewHelper.webView()->mainFrameImpl()->frame()->document(); |
8245 | 8243 |
8246 Resource* resource = | 8244 Resource* resource = |
8247 fetchManifest(document, toKURL(m_baseURL + "link-manifest-fetch.json")); | 8245 fetchManifest(document, toKURL(m_baseURL + "link-manifest-fetch.json")); |
8248 | 8246 |
8249 EXPECT_TRUE(resource->isLoaded()); | 8247 EXPECT_TRUE(resource->isLoaded()); |
8250 } | 8248 } |
8251 | 8249 |
8252 TEST_P(ParameterizedWebFrameTest, ManifestCSPFetchAllow) { | 8250 TEST_P(ParameterizedWebFrameTest, ManifestCSPFetchAllow) { |
8253 URLTestHelpers::registerMockedURLLoad( | 8251 registerMockedURLLoadFromBase(m_notBaseURL, "link-manifest-fetch.json"); |
8254 toKURL(m_notBaseURL + "link-manifest-fetch.json"), | |
8255 "link-manifest-fetch.json"); | |
8256 registerMockedHttpURLLoadWithCSP("foo.html", "manifest-src *"); | 8252 registerMockedHttpURLLoadWithCSP("foo.html", "manifest-src *"); |
8257 | 8253 |
8258 FrameTestHelpers::WebViewHelper webViewHelper; | 8254 FrameTestHelpers::WebViewHelper webViewHelper; |
8259 webViewHelper.initializeAndLoad(m_baseURL + "foo.html"); | 8255 webViewHelper.initializeAndLoad(m_baseURL + "foo.html"); |
8260 Document* document = | 8256 Document* document = |
8261 webViewHelper.webView()->mainFrameImpl()->frame()->document(); | 8257 webViewHelper.webView()->mainFrameImpl()->frame()->document(); |
8262 | 8258 |
8263 Resource* resource = fetchManifest( | 8259 Resource* resource = fetchManifest( |
8264 document, toKURL(m_notBaseURL + "link-manifest-fetch.json")); | 8260 document, toKURL(m_notBaseURL + "link-manifest-fetch.json")); |
8265 | 8261 |
8266 EXPECT_TRUE(resource->isLoaded()); | 8262 EXPECT_TRUE(resource->isLoaded()); |
8267 } | 8263 } |
8268 | 8264 |
8269 TEST_P(ParameterizedWebFrameTest, ManifestCSPFetchSelf) { | 8265 TEST_P(ParameterizedWebFrameTest, ManifestCSPFetchSelf) { |
8270 URLTestHelpers::registerMockedURLLoad( | 8266 registerMockedURLLoadFromBase(m_notBaseURL, "link-manifest-fetch.json"); |
8271 toKURL(m_notBaseURL + "link-manifest-fetch.json"), | |
8272 "link-manifest-fetch.json"); | |
8273 registerMockedHttpURLLoadWithCSP("foo.html", "manifest-src 'self'"); | 8267 registerMockedHttpURLLoadWithCSP("foo.html", "manifest-src 'self'"); |
8274 | 8268 |
8275 FrameTestHelpers::WebViewHelper webViewHelper; | 8269 FrameTestHelpers::WebViewHelper webViewHelper; |
8276 webViewHelper.initializeAndLoad(m_baseURL + "foo.html"); | 8270 webViewHelper.initializeAndLoad(m_baseURL + "foo.html"); |
8277 Document* document = | 8271 Document* document = |
8278 webViewHelper.webView()->mainFrameImpl()->frame()->document(); | 8272 webViewHelper.webView()->mainFrameImpl()->frame()->document(); |
8279 | 8273 |
8280 Resource* resource = fetchManifest( | 8274 Resource* resource = fetchManifest( |
8281 document, toKURL(m_notBaseURL + "link-manifest-fetch.json")); | 8275 document, toKURL(m_notBaseURL + "link-manifest-fetch.json")); |
8282 | 8276 |
8283 // Fetching resource wasn't allowed. | 8277 // Fetching resource wasn't allowed. |
8284 ASSERT_TRUE(resource); | 8278 ASSERT_TRUE(resource); |
8285 EXPECT_TRUE(resource->errorOccurred()); | 8279 EXPECT_TRUE(resource->errorOccurred()); |
8286 EXPECT_TRUE(resource->resourceError().isAccessCheck()); | 8280 EXPECT_TRUE(resource->resourceError().isAccessCheck()); |
8287 } | 8281 } |
8288 | 8282 |
8289 TEST_P(ParameterizedWebFrameTest, ManifestCSPFetchSelfReportOnly) { | 8283 TEST_P(ParameterizedWebFrameTest, ManifestCSPFetchSelfReportOnly) { |
8290 URLTestHelpers::registerMockedURLLoad( | 8284 registerMockedURLLoadFromBase(m_notBaseURL, "link-manifest-fetch.json"); |
8291 toKURL(m_notBaseURL + "link-manifest-fetch.json"), | |
8292 "link-manifest-fetch.json"); | |
8293 registerMockedHttpURLLoadWithCSP("foo.html", "manifest-src 'self'", | 8285 registerMockedHttpURLLoadWithCSP("foo.html", "manifest-src 'self'", |
8294 /* report only */ true); | 8286 /* report only */ true); |
8295 | 8287 |
8296 FrameTestHelpers::WebViewHelper webViewHelper; | 8288 FrameTestHelpers::WebViewHelper webViewHelper; |
8297 webViewHelper.initializeAndLoad(m_baseURL + "foo.html"); | 8289 webViewHelper.initializeAndLoad(m_baseURL + "foo.html"); |
8298 Document* document = | 8290 Document* document = |
8299 webViewHelper.webView()->mainFrameImpl()->frame()->document(); | 8291 webViewHelper.webView()->mainFrameImpl()->frame()->document(); |
8300 | 8292 |
8301 Resource* resource = fetchManifest( | 8293 Resource* resource = fetchManifest( |
8302 document, toKURL(m_notBaseURL + "link-manifest-fetch.json")); | 8294 document, toKURL(m_notBaseURL + "link-manifest-fetch.json")); |
(...skipping 1974 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
10277 // Local methods | 10269 // Local methods |
10278 const WebString& result() const { return m_dataURL; } | 10270 const WebString& result() const { return m_dataURL; } |
10279 void reset() { m_dataURL = WebString(); } | 10271 void reset() { m_dataURL = WebString(); } |
10280 | 10272 |
10281 private: | 10273 private: |
10282 WebString m_dataURL; | 10274 WebString m_dataURL; |
10283 }; | 10275 }; |
10284 | 10276 |
10285 TEST_F(WebFrameTest, SaveImageAt) { | 10277 TEST_F(WebFrameTest, SaveImageAt) { |
10286 std::string url = m_baseURL + "image-with-data-url.html"; | 10278 std::string url = m_baseURL + "image-with-data-url.html"; |
10287 URLTestHelpers::registerMockedURLLoad(toKURL(url), | 10279 registerMockedURLLoadFromBase(m_baseURL, "image-with-data-url.html"); |
10288 "image-with-data-url.html"); | 10280 URLTestHelpers::registerMockedURLLoad( |
10289 URLTestHelpers::registerMockedURLLoad(toKURL("http://test"), "white-1x1.png"); | 10281 toKURL("http://test"), testing::webTestDataPath("white-1x1.png")); |
10290 | 10282 |
10291 FrameTestHelpers::WebViewHelper helper; | 10283 FrameTestHelpers::WebViewHelper helper; |
10292 SaveImageFromDataURLWebFrameClient client; | 10284 SaveImageFromDataURLWebFrameClient client; |
10293 WebViewImpl* webView = helper.initializeAndLoad(url, true, &client); | 10285 WebViewImpl* webView = helper.initializeAndLoad(url, true, &client); |
10294 webView->resize(WebSize(400, 400)); | 10286 webView->resize(WebSize(400, 400)); |
10295 webView->updateAllLifecyclePhases(); | 10287 webView->updateAllLifecyclePhases(); |
10296 | 10288 |
10297 WebLocalFrame* localFrame = webView->mainFrameImpl(); | 10289 WebLocalFrame* localFrame = webView->mainFrameImpl(); |
10298 | 10290 |
10299 client.reset(); | 10291 client.reset(); |
(...skipping 16 matching lines...) Expand all Loading... |
10316 WebString::fromUTF8("data:image/gif;base64" | 10308 WebString::fromUTF8("data:image/gif;base64" |
10317 ",R0lGODlhAQABAIAAAAUEBAAAACwAAAAAAQABAAACAkQBADs="), | 10309 ",R0lGODlhAQABAIAAAAUEBAAAACwAAAAAAQABAAACAkQBADs="), |
10318 client.result()); | 10310 client.result()); |
10319 | 10311 |
10320 // Explicitly reset to break dependency on locally scoped client. | 10312 // Explicitly reset to break dependency on locally scoped client. |
10321 helper.reset(); | 10313 helper.reset(); |
10322 } | 10314 } |
10323 | 10315 |
10324 TEST_F(WebFrameTest, SaveImageWithImageMap) { | 10316 TEST_F(WebFrameTest, SaveImageWithImageMap) { |
10325 std::string url = m_baseURL + "image-map.html"; | 10317 std::string url = m_baseURL + "image-map.html"; |
10326 URLTestHelpers::registerMockedURLLoad(toKURL(url), "image-map.html"); | 10318 registerMockedURLLoadFromBase(m_baseURL, "image-map.html"); |
10327 | 10319 |
10328 FrameTestHelpers::WebViewHelper helper; | 10320 FrameTestHelpers::WebViewHelper helper; |
10329 SaveImageFromDataURLWebFrameClient client; | 10321 SaveImageFromDataURLWebFrameClient client; |
10330 WebViewImpl* webView = helper.initializeAndLoad(url, true, &client); | 10322 WebViewImpl* webView = helper.initializeAndLoad(url, true, &client); |
10331 webView->resize(WebSize(400, 400)); | 10323 webView->resize(WebSize(400, 400)); |
10332 | 10324 |
10333 WebLocalFrame* localFrame = webView->mainFrameImpl(); | 10325 WebLocalFrame* localFrame = webView->mainFrameImpl(); |
10334 | 10326 |
10335 client.reset(); | 10327 client.reset(); |
10336 localFrame->saveImageAt(WebPoint(25, 25)); | 10328 localFrame->saveImageAt(WebPoint(25, 25)); |
(...skipping 12 matching lines...) Expand all Loading... |
10349 client.reset(); | 10341 client.reset(); |
10350 localFrame->saveImageAt(WebPoint(125, 25)); | 10342 localFrame->saveImageAt(WebPoint(125, 25)); |
10351 EXPECT_EQ(WebString(), client.result()); | 10343 EXPECT_EQ(WebString(), client.result()); |
10352 | 10344 |
10353 // Explicitly reset to break dependency on locally scoped client. | 10345 // Explicitly reset to break dependency on locally scoped client. |
10354 helper.reset(); | 10346 helper.reset(); |
10355 } | 10347 } |
10356 | 10348 |
10357 TEST_F(WebFrameTest, CopyImageAt) { | 10349 TEST_F(WebFrameTest, CopyImageAt) { |
10358 std::string url = m_baseURL + "canvas-copy-image.html"; | 10350 std::string url = m_baseURL + "canvas-copy-image.html"; |
10359 URLTestHelpers::registerMockedURLLoad(toKURL(url), "canvas-copy-image.html"); | 10351 registerMockedURLLoadFromBase(m_baseURL, "canvas-copy-image.html"); |
10360 | 10352 |
10361 FrameTestHelpers::WebViewHelper helper; | 10353 FrameTestHelpers::WebViewHelper helper; |
10362 WebViewImpl* webView = helper.initializeAndLoad(url, true, 0); | 10354 WebViewImpl* webView = helper.initializeAndLoad(url, true, 0); |
10363 webView->resize(WebSize(400, 400)); | 10355 webView->resize(WebSize(400, 400)); |
10364 | 10356 |
10365 uint64_t sequence = Platform::current()->clipboard()->sequenceNumber( | 10357 uint64_t sequence = Platform::current()->clipboard()->sequenceNumber( |
10366 WebClipboard::BufferStandard); | 10358 WebClipboard::BufferStandard); |
10367 | 10359 |
10368 WebLocalFrame* localFrame = webView->mainFrameImpl(); | 10360 WebLocalFrame* localFrame = webView->mainFrameImpl(); |
10369 localFrame->copyImageAt(WebPoint(50, 50)); | 10361 localFrame->copyImageAt(WebPoint(50, 50)); |
10370 | 10362 |
10371 EXPECT_NE(sequence, Platform::current()->clipboard()->sequenceNumber( | 10363 EXPECT_NE(sequence, Platform::current()->clipboard()->sequenceNumber( |
10372 WebClipboard::BufferStandard)); | 10364 WebClipboard::BufferStandard)); |
10373 | 10365 |
10374 WebImage image = | 10366 WebImage image = |
10375 static_cast<WebMockClipboard*>(Platform::current()->clipboard()) | 10367 static_cast<WebMockClipboard*>(Platform::current()->clipboard()) |
10376 ->readRawImage(WebClipboard::Buffer()); | 10368 ->readRawImage(WebClipboard::Buffer()); |
10377 | 10369 |
10378 SkAutoLockPixels autoLock(image.getSkBitmap()); | 10370 SkAutoLockPixels autoLock(image.getSkBitmap()); |
10379 EXPECT_EQ(SkColorSetARGB(255, 255, 0, 0), image.getSkBitmap().getColor(0, 0)); | 10371 EXPECT_EQ(SkColorSetARGB(255, 255, 0, 0), image.getSkBitmap().getColor(0, 0)); |
10380 }; | 10372 }; |
10381 | 10373 |
10382 TEST_F(WebFrameTest, CopyImageAtWithPinchZoom) { | 10374 TEST_F(WebFrameTest, CopyImageAtWithPinchZoom) { |
10383 std::string url = m_baseURL + "canvas-copy-image.html"; | 10375 std::string url = m_baseURL + "canvas-copy-image.html"; |
10384 URLTestHelpers::registerMockedURLLoad(toKURL(url), "canvas-copy-image.html"); | 10376 registerMockedURLLoadFromBase(m_baseURL, "canvas-copy-image.html"); |
10385 | 10377 |
10386 FrameTestHelpers::WebViewHelper helper; | 10378 FrameTestHelpers::WebViewHelper helper; |
10387 WebViewImpl* webView = helper.initializeAndLoad(url, true, 0); | 10379 WebViewImpl* webView = helper.initializeAndLoad(url, true, 0); |
10388 webView->resize(WebSize(400, 400)); | 10380 webView->resize(WebSize(400, 400)); |
10389 webView->updateAllLifecyclePhases(); | 10381 webView->updateAllLifecyclePhases(); |
10390 webView->setPageScaleFactor(2); | 10382 webView->setPageScaleFactor(2); |
10391 webView->setVisualViewportOffset(WebFloatPoint(200, 200)); | 10383 webView->setVisualViewportOffset(WebFloatPoint(200, 200)); |
10392 | 10384 |
10393 uint64_t sequence = Platform::current()->clipboard()->sequenceNumber( | 10385 uint64_t sequence = Platform::current()->clipboard()->sequenceNumber( |
10394 WebClipboard::BufferStandard); | 10386 WebClipboard::BufferStandard); |
10395 | 10387 |
10396 WebLocalFrame* localFrame = webView->mainFrameImpl(); | 10388 WebLocalFrame* localFrame = webView->mainFrameImpl(); |
10397 localFrame->copyImageAt(WebPoint(0, 0)); | 10389 localFrame->copyImageAt(WebPoint(0, 0)); |
10398 | 10390 |
10399 EXPECT_NE(sequence, Platform::current()->clipboard()->sequenceNumber( | 10391 EXPECT_NE(sequence, Platform::current()->clipboard()->sequenceNumber( |
10400 WebClipboard::BufferStandard)); | 10392 WebClipboard::BufferStandard)); |
10401 | 10393 |
10402 WebImage image = | 10394 WebImage image = |
10403 static_cast<WebMockClipboard*>(Platform::current()->clipboard()) | 10395 static_cast<WebMockClipboard*>(Platform::current()->clipboard()) |
10404 ->readRawImage(WebClipboard::Buffer()); | 10396 ->readRawImage(WebClipboard::Buffer()); |
10405 | 10397 |
10406 SkAutoLockPixels autoLock(image.getSkBitmap()); | 10398 SkAutoLockPixels autoLock(image.getSkBitmap()); |
10407 EXPECT_EQ(SkColorSetARGB(255, 255, 0, 0), image.getSkBitmap().getColor(0, 0)); | 10399 EXPECT_EQ(SkColorSetARGB(255, 255, 0, 0), image.getSkBitmap().getColor(0, 0)); |
10408 }; | 10400 }; |
10409 | 10401 |
10410 TEST_F(WebFrameTest, CopyImageWithImageMap) { | 10402 TEST_F(WebFrameTest, CopyImageWithImageMap) { |
10411 SaveImageFromDataURLWebFrameClient client; | 10403 SaveImageFromDataURLWebFrameClient client; |
10412 | 10404 |
10413 std::string url = m_baseURL + "image-map.html"; | 10405 std::string url = m_baseURL + "image-map.html"; |
10414 URLTestHelpers::registerMockedURLLoad(toKURL(url), "image-map.html"); | 10406 registerMockedURLLoadFromBase(m_baseURL, "image-map.html"); |
10415 | 10407 |
10416 FrameTestHelpers::WebViewHelper helper; | 10408 FrameTestHelpers::WebViewHelper helper; |
10417 WebViewImpl* webView = helper.initializeAndLoad(url, true, &client); | 10409 WebViewImpl* webView = helper.initializeAndLoad(url, true, &client); |
10418 webView->resize(WebSize(400, 400)); | 10410 webView->resize(WebSize(400, 400)); |
10419 | 10411 |
10420 client.reset(); | 10412 client.reset(); |
10421 WebLocalFrame* localFrame = webView->mainFrameImpl(); | 10413 WebLocalFrame* localFrame = webView->mainFrameImpl(); |
10422 localFrame->saveImageAt(WebPoint(25, 25)); | 10414 localFrame->saveImageAt(WebPoint(25, 25)); |
10423 EXPECT_EQ( | 10415 EXPECT_EQ( |
10424 WebString::fromUTF8("data:image/gif;base64" | 10416 WebString::fromUTF8("data:image/gif;base64" |
(...skipping 12 matching lines...) Expand all Loading... |
10437 EXPECT_EQ(WebString(), client.result()); | 10429 EXPECT_EQ(WebString(), client.result()); |
10438 // Explicitly reset to break dependency on locally scoped client. | 10430 // Explicitly reset to break dependency on locally scoped client. |
10439 helper.reset(); | 10431 helper.reset(); |
10440 } | 10432 } |
10441 | 10433 |
10442 TEST_F(WebFrameTest, LoadJavascriptURLInNewFrame) { | 10434 TEST_F(WebFrameTest, LoadJavascriptURLInNewFrame) { |
10443 FrameTestHelpers::WebViewHelper helper; | 10435 FrameTestHelpers::WebViewHelper helper; |
10444 helper.initialize(true); | 10436 helper.initialize(true); |
10445 | 10437 |
10446 std::string redirectURL = m_baseURL + "foo.html"; | 10438 std::string redirectURL = m_baseURL + "foo.html"; |
10447 URLTestHelpers::registerMockedURLLoad(toKURL(redirectURL), "foo.html"); | 10439 URLTestHelpers::registerMockedURLLoad(toKURL(redirectURL), |
| 10440 testing::webTestDataPath("foo.html")); |
10448 WebURLRequest request(toKURL("javascript:location='" + redirectURL + "'")); | 10441 WebURLRequest request(toKURL("javascript:location='" + redirectURL + "'")); |
10449 helper.webView()->mainFrameImpl()->loadRequest(request); | 10442 helper.webView()->mainFrameImpl()->loadRequest(request); |
10450 | 10443 |
10451 // Normally, the result of the JS url replaces the existing contents on the | 10444 // Normally, the result of the JS url replaces the existing contents on the |
10452 // Document. However, if the JS triggers a navigation, the contents should | 10445 // Document. However, if the JS triggers a navigation, the contents should |
10453 // not be replaced. | 10446 // not be replaced. |
10454 EXPECT_EQ("", toLocalFrame(helper.webView()->page()->mainFrame()) | 10447 EXPECT_EQ("", toLocalFrame(helper.webView()->page()->mainFrame()) |
10455 ->document() | 10448 ->document() |
10456 ->documentElement() | 10449 ->documentElement() |
10457 ->innerText()); | 10450 ->innerText()); |
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
10569 int dataLength) override { | 10562 int dataLength) override { |
10570 EXPECT_GT(dataLength, 16); | 10563 EXPECT_GT(dataLength, 16); |
10571 originalClient->didReceiveData(data, 16); | 10564 originalClient->didReceiveData(data, 16); |
10572 // This didReceiveData call shouldn't crash due to a failed assertion. | 10565 // This didReceiveData call shouldn't crash due to a failed assertion. |
10573 originalClient->didReceiveData(data + 16, dataLength - 16); | 10566 originalClient->didReceiveData(data + 16, dataLength - 16); |
10574 } | 10567 } |
10575 }; | 10568 }; |
10576 | 10569 |
10577 TEST_F(WebFrameTest, ImageDocumentDecodeError) { | 10570 TEST_F(WebFrameTest, ImageDocumentDecodeError) { |
10578 std::string url = m_baseURL + "not_an_image.ico"; | 10571 std::string url = m_baseURL + "not_an_image.ico"; |
10579 URLTestHelpers::registerMockedURLLoad(toKURL(url), "not_an_image.ico", | 10572 URLTestHelpers::registerMockedURLLoad( |
10580 "image/x-icon"); | 10573 toKURL(url), testing::webTestDataPath("not_an_image.ico"), |
| 10574 "image/x-icon"); |
10581 MultipleDataChunkDelegate delegate; | 10575 MultipleDataChunkDelegate delegate; |
10582 Platform::current()->getURLLoaderMockFactory()->setLoaderDelegate(&delegate); | 10576 Platform::current()->getURLLoaderMockFactory()->setLoaderDelegate(&delegate); |
10583 FrameTestHelpers::WebViewHelper helper; | 10577 FrameTestHelpers::WebViewHelper helper; |
10584 helper.initializeAndLoad(url, true); | 10578 helper.initializeAndLoad(url, true); |
10585 Platform::current()->getURLLoaderMockFactory()->setLoaderDelegate(nullptr); | 10579 Platform::current()->getURLLoaderMockFactory()->setLoaderDelegate(nullptr); |
10586 | 10580 |
10587 Document* document = | 10581 Document* document = |
10588 toLocalFrame(helper.webView()->page()->mainFrame())->document(); | 10582 toLocalFrame(helper.webView()->page()->mainFrame())->document(); |
10589 EXPECT_TRUE(document->isImageDocument()); | 10583 EXPECT_TRUE(document->isImageDocument()); |
10590 EXPECT_EQ(ResourceStatus::DecodeError, | 10584 EXPECT_EQ(ResourceStatus::DecodeError, |
(...skipping 735 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
11326 | 11320 |
11327 LoadingObserverFrameClient& childClient() { return m_childClient; } | 11321 LoadingObserverFrameClient& childClient() { return m_childClient; } |
11328 | 11322 |
11329 private: | 11323 private: |
11330 LoadingObserverFrameClient m_childClient; | 11324 LoadingObserverFrameClient m_childClient; |
11331 }; | 11325 }; |
11332 | 11326 |
11333 registerMockedHttpURLLoad("single_iframe.html"); | 11327 registerMockedHttpURLLoad("single_iframe.html"); |
11334 URLTestHelpers::registerMockedURLLoad( | 11328 URLTestHelpers::registerMockedURLLoad( |
11335 toKURL(m_baseURL + "visible_iframe.html"), | 11329 toKURL(m_baseURL + "visible_iframe.html"), |
11336 WebString::fromUTF8("frame_with_frame.html")); | 11330 testing::webTestDataPath("frame_with_frame.html")); |
11337 registerMockedHttpURLLoad("parent_detaching_frame.html"); | 11331 registerMockedHttpURLLoad("parent_detaching_frame.html"); |
11338 | 11332 |
11339 FrameTestHelpers::WebViewHelper webViewHelper; | 11333 FrameTestHelpers::WebViewHelper webViewHelper; |
11340 MainFrameClient mainFrameClient; | 11334 MainFrameClient mainFrameClient; |
11341 webViewHelper.initializeAndLoad(m_baseURL + "single_iframe.html", true, | 11335 webViewHelper.initializeAndLoad(m_baseURL + "single_iframe.html", true, |
11342 &mainFrameClient); | 11336 &mainFrameClient); |
11343 | 11337 |
11344 EXPECT_TRUE(mainFrameClient.childClient().didCallFrameDetached()); | 11338 EXPECT_TRUE(mainFrameClient.childClient().didCallFrameDetached()); |
11345 EXPECT_TRUE(mainFrameClient.childClient().didCallDidStopLoading()); | 11339 EXPECT_TRUE(mainFrameClient.childClient().didCallDidStopLoading()); |
11346 EXPECT_TRUE(mainFrameClient.childClient().didCallDidFinishDocumentLoad()); | 11340 EXPECT_TRUE(mainFrameClient.childClient().didCallDidFinishDocumentLoad()); |
11347 EXPECT_TRUE(mainFrameClient.childClient().didCallDidHandleOnloadEvents()); | 11341 EXPECT_TRUE(mainFrameClient.childClient().didCallDidHandleOnloadEvents()); |
11348 | 11342 |
11349 webViewHelper.reset(); | 11343 webViewHelper.reset(); |
11350 } | 11344 } |
11351 | 11345 |
11352 } // namespace blink | 11346 } // namespace blink |
OLD | NEW |