| OLD | NEW |
| 1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 2012 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 #include <vector> | 5 #include <vector> |
| 6 #import <Foundation/Foundation.h> | 6 #import <Foundation/Foundation.h> |
| 7 | 7 |
| 8 #include "base/macros.h" | 8 #include "base/macros.h" |
| 9 #include "base/strings/stringprintf.h" | 9 #include "base/strings/stringprintf.h" |
| 10 #import "ios/web/test/web_test.h" | 10 #import "ios/web/public/test/web_test_with_web_state.h" |
| 11 #include "testing/gtest/include/gtest/gtest.h" | 11 #include "testing/gtest/include/gtest/gtest.h" |
| 12 #include "testing/gtest_mac.h" | 12 #include "testing/gtest_mac.h" |
| 13 | 13 |
| 14 // Unit tests for ios/web/web_state/js/resources/core.js. | 14 // Unit tests for ios/web/web_state/js/resources/core.js. |
| 15 | 15 |
| 16 namespace { | 16 namespace { |
| 17 | 17 |
| 18 struct TestScriptAndExpectedValue { | 18 struct TestScriptAndExpectedValue { |
| 19 NSString* testScript; | 19 NSString* testScript; |
| 20 NSString* expectedValue; | 20 NSString* expectedValue; |
| 21 }; | 21 }; |
| 22 | 22 |
| 23 } // namespace | 23 } // namespace |
| 24 | 24 |
| 25 namespace web { | 25 namespace web { |
| 26 | 26 |
| 27 // Test fixture to test core.js. | 27 // Test fixture to test core.js. |
| 28 class CoreJsTest : public web::WebTestWithWebController { | 28 class CoreJsTest : public web::WebTestWithWebState { |
| 29 protected: | 29 protected: |
| 30 void ImageTesterHelper( | 30 void ImageTesterHelper( |
| 31 NSString* htmlForImage, | 31 NSString* htmlForImage, |
| 32 NSString* expectedValueWhenClickingOnImage) { | 32 NSString* expectedValueWhenClickingOnImage) { |
| 33 NSString* pageContentTemplate = | 33 NSString* pageContentTemplate = |
| 34 @"<html><body style='margin-left:10px;margin-top:10px;'>" | 34 @"<html><body style='margin-left:10px;margin-top:10px;'>" |
| 35 "<div style='width:100px;height:100px;'>" | 35 "<div style='width:100px;height:100px;'>" |
| 36 " <p style='position:absolute;left:25px;top:25px;" | 36 " <p style='position:absolute;left:25px;top:25px;" |
| 37 " width:50px;height:50px'>" | 37 " width:50px;height:50px'>" |
| 38 "%@" | 38 "%@" |
| (...skipping 236 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 275 result = EvaluateJavaScriptAsString( | 275 result = EvaluateJavaScriptAsString( |
| 276 @"__gCrWeb['getElementFromPoint'](200, 200)"); | 276 @"__gCrWeb['getElementFromPoint'](200, 200)"); |
| 277 expected_result = R"({"src":"foo","referrerPolicy":"default"})"; | 277 expected_result = R"({"src":"foo","referrerPolicy":"default"})"; |
| 278 | 278 |
| 279 // Make sure the returned JSON does not have an 'href' key. | 279 // Make sure the returned JSON does not have an 'href' key. |
| 280 EXPECT_EQ(expected_result, [result UTF8String]); | 280 EXPECT_EQ(expected_result, [result UTF8String]); |
| 281 } | 281 } |
| 282 } | 282 } |
| 283 | 283 |
| 284 } // namespace web | 284 } // namespace web |
| OLD | NEW |