| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #import <XCTest/XCTest.h> | 5 #import <XCTest/XCTest.h> |
| 6 #include <map> | 6 #include <map> |
| 7 #include <memory> | 7 #include <memory> |
| 8 #include <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "base/ios/ios_util.h" | 10 #include "base/ios/ios_util.h" |
| (...skipping 17 matching lines...) Expand all Loading... |
| 28 #import "ios/testing/wait_util.h" | 28 #import "ios/testing/wait_util.h" |
| 29 #import "ios/web/public/test/earl_grey/web_view_actions.h" | 29 #import "ios/web/public/test/earl_grey/web_view_actions.h" |
| 30 #import "ios/web/public/test/earl_grey/web_view_matchers.h" | 30 #import "ios/web/public/test/earl_grey/web_view_matchers.h" |
| 31 #import "ios/web/public/test/http_server.h" | 31 #import "ios/web/public/test/http_server.h" |
| 32 #include "ios/web/public/test/http_server_util.h" | 32 #include "ios/web/public/test/http_server_util.h" |
| 33 #include "ios/web/public/test/response_providers/data_response_provider.h" | 33 #include "ios/web/public/test/response_providers/data_response_provider.h" |
| 34 #include "net/http/http_response_headers.h" | 34 #include "net/http/http_response_headers.h" |
| 35 #include "ui/base/l10n/l10n_util.h" | 35 #include "ui/base/l10n/l10n_util.h" |
| 36 #include "url/gurl.h" | 36 #include "url/gurl.h" |
| 37 | 37 |
| 38 #if !defined(__has_feature) || !__has_feature(objc_arc) |
| 39 #error "This file requires ARC support." |
| 40 #endif |
| 41 |
| 38 using chrome_test_util::OmniboxText; | 42 using chrome_test_util::OmniboxText; |
| 39 using chrome_test_util::WebViewContainingText; | 43 using chrome_test_util::WebViewContainingText; |
| 40 | 44 |
| 41 namespace { | 45 namespace { |
| 42 | 46 |
| 43 // URL used for the reload test. | 47 // URL used for the reload test. |
| 44 const char kReloadTestUrl[] = "http://mock/reloadTest"; | 48 const char kReloadTestUrl[] = "http://mock/reloadTest"; |
| 45 | 49 |
| 46 // Returns the number of serviced requests in HTTP body. | 50 // Returns the number of serviced requests in HTTP body. |
| 47 class ReloadResponseProvider : public web::DataResponseProvider { | 51 class ReloadResponseProvider : public web::DataResponseProvider { |
| (...skipping 328 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 376 assertWithMatcher:grey_notNil()]; | 380 assertWithMatcher:grey_notNil()]; |
| 377 | 381 |
| 378 [self goBack]; | 382 [self goBack]; |
| 379 [[EarlGrey selectElementWithMatcher:OmniboxText(URL.GetContent())] | 383 [[EarlGrey selectElementWithMatcher:OmniboxText(URL.GetContent())] |
| 380 assertWithMatcher:grey_notNil()]; | 384 assertWithMatcher:grey_notNil()]; |
| 381 } | 385 } |
| 382 | 386 |
| 383 // TODO(crbug.com/638674): Evaluate if this can move to shared code | 387 // TODO(crbug.com/638674): Evaluate if this can move to shared code |
| 384 // Navigates back to the previous webpage. | 388 // Navigates back to the previous webpage. |
| 385 - (void)goBack { | 389 - (void)goBack { |
| 386 base::scoped_nsobject<GenericChromeCommand> backCommand( | 390 GenericChromeCommand* backCommand = |
| 387 [[GenericChromeCommand alloc] initWithTag:IDC_BACK]); | 391 [[GenericChromeCommand alloc] initWithTag:IDC_BACK]; |
| 388 chrome_test_util::RunCommandWithActiveViewController(backCommand); | 392 chrome_test_util::RunCommandWithActiveViewController(backCommand); |
| 389 | 393 |
| 390 [ChromeEarlGrey waitForPageToFinishLoading]; | 394 [ChromeEarlGrey waitForPageToFinishLoading]; |
| 391 } | 395 } |
| 392 | 396 |
| 393 // Navigates forward to a previous webpage. | 397 // Navigates forward to a previous webpage. |
| 394 // TODO(crbug.com/638674): Evaluate if this can move to shared code | 398 // TODO(crbug.com/638674): Evaluate if this can move to shared code |
| 395 - (void)goForward { | 399 - (void)goForward { |
| 396 base::scoped_nsobject<GenericChromeCommand> forwardCommand( | 400 GenericChromeCommand* forwardCommand = |
| 397 [[GenericChromeCommand alloc] initWithTag:IDC_FORWARD]); | 401 [[GenericChromeCommand alloc] initWithTag:IDC_FORWARD]; |
| 398 chrome_test_util::RunCommandWithActiveViewController(forwardCommand); | 402 chrome_test_util::RunCommandWithActiveViewController(forwardCommand); |
| 399 | 403 |
| 400 [ChromeEarlGrey waitForPageToFinishLoading]; | 404 [ChromeEarlGrey waitForPageToFinishLoading]; |
| 401 } | 405 } |
| 402 | 406 |
| 403 // Tests that a link with WebUI URL does not trigger a load. WebUI pages may | 407 // Tests that a link with WebUI URL does not trigger a load. WebUI pages may |
| 404 // have increased power and using the same web process (which may potentially | 408 // have increased power and using the same web process (which may potentially |
| 405 // be controlled by an attacker) is dangerous. | 409 // be controlled by an attacker) is dangerous. |
| 406 - (void)testTapLinkWithWebUIURL { | 410 - (void)testTapLinkWithWebUIURL { |
| 407 // Create map of canned responses and set up the test HTML server. | 411 // Create map of canned responses and set up the test HTML server. |
| (...skipping 240 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 648 | 652 |
| 649 // Go back and verify that the browser navigates to the original URL. | 653 // Go back and verify that the browser navigates to the original URL. |
| 650 [self goBack]; | 654 [self goBack]; |
| 651 [[EarlGrey selectElementWithMatcher:WebViewContainingText("hello!")] | 655 [[EarlGrey selectElementWithMatcher:WebViewContainingText("hello!")] |
| 652 assertWithMatcher:grey_notNil()]; | 656 assertWithMatcher:grey_notNil()]; |
| 653 [[EarlGrey selectElementWithMatcher:OmniboxText(URL.GetContent())] | 657 [[EarlGrey selectElementWithMatcher:OmniboxText(URL.GetContent())] |
| 654 assertWithMatcher:grey_notNil()]; | 658 assertWithMatcher:grey_notNil()]; |
| 655 } | 659 } |
| 656 | 660 |
| 657 @end | 661 @end |
| OLD | NEW |