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