| 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 <UIKit/UIKit.h> | 5 #import <UIKit/UIKit.h> |
| 6 #import <WebKit/WebKit.h> | 6 #import <WebKit/WebKit.h> |
| 7 #import <XCTest/XCTest.h> | 7 #import <XCTest/XCTest.h> |
| 8 | 8 |
| 9 #import <EarlGrey/EarlGrey.h> | 9 #import <EarlGrey/EarlGrey.h> |
| 10 | 10 |
| (...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 164 | 164 |
| 165 web::shell_test_util::TapWebViewElementWithId("overrides-href"); | 165 web::shell_test_util::TapWebViewElementWithId("overrides-href"); |
| 166 | 166 |
| 167 [[EarlGrey selectElementWithMatcher:web::addressFieldText(URL.spec())] | 167 [[EarlGrey selectElementWithMatcher:web::addressFieldText(URL.spec())] |
| 168 assertWithMatcher:grey_notNil()]; | 168 assertWithMatcher:grey_notNil()]; |
| 169 [[EarlGrey | 169 [[EarlGrey |
| 170 selectElementWithMatcher:web::webViewContainingText("Default prevented!")] | 170 selectElementWithMatcher:web::webViewContainingText("Default prevented!")] |
| 171 assertWithMatcher:grey_notNil()]; | 171 assertWithMatcher:grey_notNil()]; |
| 172 } | 172 } |
| 173 | 173 |
| 174 // Tests tapping on a link with unsupported URL scheme. |
| 175 - (void)testNavigationUnsupportedSchema { |
| 176 // Create map of canned responses and set up the test HTML server. |
| 177 std::map<GURL, std::string> responses; |
| 178 const GURL URL = |
| 179 web::test::HttpServer::MakeUrl("http://urlWithUnsupportedSchemeLink"); |
| 180 const char pageHTML[] = |
| 181 "<script>" |
| 182 " function printMsg() {" |
| 183 " document.body.appendChild(document.createTextNode(" |
| 184 " 'No navigation!'));" |
| 185 " }" |
| 186 "</script>" |
| 187 "<a href='aaa://unsupported' id='link' " |
| 188 "onclick='printMsg();'>unsupportedScheme</a>"; |
| 189 responses[URL] = pageHTML; |
| 190 |
| 191 web::test::SetUpSimpleHttpServer(responses); |
| 192 |
| 193 web::shell_test_util::LoadUrl(URL); |
| 194 [[EarlGrey selectElementWithMatcher:web::addressFieldText(URL.spec())] |
| 195 assertWithMatcher:grey_notNil()]; |
| 196 |
| 197 web::shell_test_util::TapWebViewElementWithId("link"); |
| 198 |
| 199 [[EarlGrey selectElementWithMatcher:web::addressFieldText(URL.spec())] |
| 200 assertWithMatcher:grey_notNil()]; |
| 201 [[EarlGrey |
| 202 selectElementWithMatcher:web::webViewContainingText("No navigation!")] |
| 203 assertWithMatcher:grey_notNil()]; |
| 204 } |
| 205 |
| 174 @end | 206 @end |
| OLD | NEW |