| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 | 6 |
| 7 #include <memory> | 7 #include <memory> |
| 8 | 8 |
| 9 #include "base/ios/ios_util.h" | 9 #include "base/ios/ios_util.h" |
| 10 #include "base/json/json_reader.h" | 10 #include "base/json/json_reader.h" |
| (...skipping 361 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 372 ExecuteJavaScript( | 372 ExecuteJavaScript( |
| 373 @"document.getElementById('test').innerText = 'mutation is ';"); | 373 @"document.getElementById('test').innerText = 'mutation is ';"); |
| 374 ASSERT_EQ(0, GetMutatedNodeCount()); | 374 ASSERT_EQ(0, GetMutatedNodeCount()); |
| 375 ContextualSearchStruct searchContext; | 375 ContextualSearchStruct searchContext; |
| 376 | 376 |
| 377 ASSERT_TRUE(GetContextFromId(@"taphere", &searchContext)); | 377 ASSERT_TRUE(GetContextFromId(@"taphere", &searchContext)); |
| 378 }; | 378 }; |
| 379 | 379 |
| 380 // Test that related text DOM mutation prevents contextual search. | 380 // Test that related text DOM mutation prevents contextual search. |
| 381 TEST_F(ContextualSearchJsTest, TestHighlightRelatedDOMMutationText) { | 381 TEST_F(ContextualSearchJsTest, TestHighlightRelatedDOMMutationText) { |
| 382 // TODO(crbug.com/736989): Test failures in GetMutatedNodeCount. |
| 383 if (base::ios::IsRunningOnIOS11OrLater()) |
| 384 return; |
| 382 LoadHtml(kHTMLWithRelatedTextMutation); | 385 LoadHtml(kHTMLWithRelatedTextMutation); |
| 383 ExecuteJavaScript(@"document.getElementById('test').innerText = 'mutated';"); | 386 ExecuteJavaScript(@"document.getElementById('test').innerText = 'mutated';"); |
| 384 ASSERT_EQ(1, GetMutatedNodeCount()); | 387 ASSERT_EQ(1, GetMutatedNodeCount()); |
| 385 ContextualSearchStruct searchContext; | 388 ContextualSearchStruct searchContext; |
| 386 | 389 |
| 387 ASSERT_FALSE(GetContextFromId(@"taphere", &searchContext)); | 390 ASSERT_FALSE(GetContextFromId(@"taphere", &searchContext)); |
| 388 }; | 391 }; |
| 389 | 392 |
| 390 // Test that unrelated text DOM mutation doesn't prevent contextual search. | 393 // Test that unrelated text DOM mutation doesn't prevent contextual search. |
| 391 TEST_F(ContextualSearchJsTest, TestHighlightUnrelatedDOMMutationTextIgnored) { | 394 TEST_F(ContextualSearchJsTest, TestHighlightUnrelatedDOMMutationTextIgnored) { |
| (...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 500 NSString* stringHTML = BuildLongTestString(0, 10, 5, true); | 503 NSString* stringHTML = BuildLongTestString(0, 10, 5, true); |
| 501 NSString* expectedHTML = BuildLongTestString(0, 10, -1, false); | 504 NSString* expectedHTML = BuildLongTestString(0, 10, -1, false); |
| 502 // LoadHtml will trim the last space. | 505 // LoadHtml will trim the last space. |
| 503 LoadHtml( | 506 LoadHtml( |
| 504 [NSString stringWithFormat:@"<html><body>%@</body></html>", stringHTML]); | 507 [NSString stringWithFormat:@"<html><body>%@</body></html>", stringHTML]); |
| 505 ContextualSearchStruct searchContext; | 508 ContextualSearchStruct searchContext; |
| 506 ASSERT_TRUE(GetContextFromId(@"taphere", &searchContext)); | 509 ASSERT_TRUE(GetContextFromId(@"taphere", &searchContext)); |
| 507 CheckContextOffsets(searchContext, base::SysNSStringToUTF8(expectedHTML)); | 510 CheckContextOffsets(searchContext, base::SysNSStringToUTF8(expectedHTML)); |
| 508 }; | 511 }; |
| 509 } // namespace | 512 } // namespace |
| OLD | NEW |