| Index: ios/web/shell/test/web_shell_navigation_egtest.mm
|
| diff --git a/ios/web/shell/test/web_shell_navigation_egtest.mm b/ios/web/shell/test/web_shell_navigation_egtest.mm
|
| index e3a58281a5b9764af9cfc3d648af87073c3298d2..7646dfa8c000ca96499c5b05dd1b41e61b9dae83 100644
|
| --- a/ios/web/shell/test/web_shell_navigation_egtest.mm
|
| +++ b/ios/web/shell/test/web_shell_navigation_egtest.mm
|
| @@ -8,6 +8,7 @@
|
|
|
| #import <EarlGrey/EarlGrey.h>
|
|
|
| +#include "base/strings/stringprintf.h"
|
| #include "base/strings/sys_string_conversions.h"
|
| #import "ios/web/public/test/http_server.h"
|
| #include "ios/web/public/test/http_server_util.h"
|
| @@ -139,4 +140,33 @@
|
| assertWithMatcher:grey_notNil()];
|
| }
|
|
|
| +// Tests tapping a link with onclick="event.preventDefault()" and verifies that
|
| +// the URL didn't change..
|
| +- (void)testNavigationLinkPreventDefaultOverridesHref {
|
| + // Create map of canned responses and set up the test HTML server.
|
| + std::map<GURL, std::string> responses;
|
| + const GURL URL = web::test::HttpServer::MakeUrl("http://overridesHrefLink");
|
| + const GURL destURL = web::test::HttpServer::MakeUrl("http://destination");
|
| +
|
| + const std::string response = base::StringPrintf(
|
| + "<a href='%s' id='overrides-href' "
|
| + "onclick='event.preventDefault()'>redirectLink</a>",
|
| + destURL.spec().c_str());
|
| + responses[URL] = response;
|
| + std::string destResponse = "You're here!";
|
| + responses[destURL] = destResponse;
|
| +
|
| + web::test::SetUpSimpleHttpServer(responses);
|
| + web::shell_test_util::LoadUrl(URL);
|
| + [[EarlGrey selectElementWithMatcher:web::addressFieldText(URL.spec())]
|
| + assertWithMatcher:grey_notNil()];
|
| +
|
| + web::shell_test_util::TapWebViewElementWithId("overrides-href");
|
| +
|
| + [[EarlGrey selectElementWithMatcher:web::addressFieldText(URL.spec())]
|
| + assertWithMatcher:grey_notNil()];
|
| + [[EarlGrey selectElementWithMatcher:web::webViewContainingText(destResponse)]
|
| + assertWithMatcher:grey_nil()];
|
| +}
|
| +
|
| @end
|
|
|