| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 <WebKit/WebKit.h> | 5 #import <WebKit/WebKit.h> |
| 6 | 6 |
| 7 #include <memory> | 7 #include <memory> |
| 8 #include <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "base/mac/foundation_util.h" | 10 #include "base/mac/foundation_util.h" |
| 11 #import "base/mac/scoped_nsobject.h" | 11 #import "base/mac/scoped_nsobject.h" |
| 12 #include "base/memory/ptr_util.h" | 12 #include "base/memory/ptr_util.h" |
| 13 #import "base/test/ios/wait_util.h" | 13 #import "base/test/ios/wait_util.h" |
| 14 #include "base/test/test_timeouts.h" |
| 14 #include "ios/web/public/browser_state.h" | 15 #include "ios/web/public/browser_state.h" |
| 15 #import "ios/web/public/test/http_server.h" | 16 #import "ios/web/public/test/http_server.h" |
| 16 #import "ios/web/public/test/js_test_util.h" | 17 #import "ios/web/public/test/js_test_util.h" |
| 17 #import "ios/web/public/test/response_providers/string_response_provider.h" | 18 #import "ios/web/public/test/response_providers/string_response_provider.h" |
| 18 #import "ios/web/public/web_view_creation_util.h" | 19 #import "ios/web/public/web_view_creation_util.h" |
| 19 #import "ios/web/test/web_int_test.h" | 20 #import "ios/web/test/web_int_test.h" |
| 20 #import "net/base/mac/url_conversions.h" | 21 #import "net/base/mac/url_conversions.h" |
| 21 #include "testing/gtest/include/gtest/gtest.h" | 22 #include "testing/gtest/include/gtest/gtest.h" |
| 22 #import "testing/gtest_mac.h" | 23 #import "testing/gtest_mac.h" |
| 23 | 24 |
| (...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 107 [[TestNavigationDelegate alloc] init]); | 108 [[TestNavigationDelegate alloc] init]); |
| 108 | 109 |
| 109 id old_navigation_delegate = web_view.navigationDelegate; | 110 id old_navigation_delegate = web_view.navigationDelegate; |
| 110 web_view.navigationDelegate = navigation_delegate; | 111 web_view.navigationDelegate = navigation_delegate; |
| 111 | 112 |
| 112 web::test::HttpServer& server = web::test::HttpServer::GetSharedInstance(); | 113 web::test::HttpServer& server = web::test::HttpServer::GetSharedInstance(); |
| 113 ASSERT_TRUE(server.IsRunning()); | 114 ASSERT_TRUE(server.IsRunning()); |
| 114 | 115 |
| 115 NSURL* url = net::NSURLWithGURL(server.MakeUrl("http://whatever/")); | 116 NSURL* url = net::NSURLWithGURL(server.MakeUrl("http://whatever/")); |
| 116 [web_view loadRequest:[NSURLRequest requestWithURL:url]]; | 117 [web_view loadRequest:[NSURLRequest requestWithURL:url]]; |
| 117 base::test::ios::WaitUntilCondition(^bool { | 118 base::test::ios::WaitUntilCondition( |
| 118 return [navigation_delegate didFinishNavigation]; | 119 ^bool { |
| 119 }); | 120 return [navigation_delegate didFinishNavigation]; |
| 121 }, |
| 122 false, TestTimeouts::action_max_timeout()); |
| 120 | 123 |
| 121 web_view.navigationDelegate = old_navigation_delegate; | 124 web_view.navigationDelegate = old_navigation_delegate; |
| 122 } | 125 } |
| 123 | 126 |
| 124 // Returns the BrowserState that is used for testing. | 127 // Returns the BrowserState that is used for testing. |
| 125 web::BrowserState* GetOtrBrowserState() { return &otr_browser_state_; } | 128 web::BrowserState* GetOtrBrowserState() { return &otr_browser_state_; } |
| 126 | 129 |
| 127 private: | 130 private: |
| 128 // The ResponseProvider used to load a simple web page. | 131 // The ResponseProvider used to load a simple web page. |
| 129 web::ResponseProvider* provider_; | 132 web::ResponseProvider* provider_; |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 171 SetLocalStorageItem(@"someKey2", @"someValue2", web_view_2); | 174 SetLocalStorageItem(@"someKey2", @"someValue2", web_view_2); |
| 172 // Due to platform limitation, it's not possible to actually set localStorage | 175 // Due to platform limitation, it's not possible to actually set localStorage |
| 173 // item on an OTR BrowserState. Therefore, it's not possible to verify that a | 176 // item on an OTR BrowserState. Therefore, it's not possible to verify that a |
| 174 // localStorage item has been correctly set. | 177 // localStorage item has been correctly set. |
| 175 // Look at | 178 // Look at |
| 176 // http://stackoverflow.com/questions/14555347/html5-localstorage-error-with-s
afari-quota-exceeded-err-dom-exception-22-an | 179 // http://stackoverflow.com/questions/14555347/html5-localstorage-error-with-s
afari-quota-exceeded-err-dom-exception-22-an |
| 177 // for more details. | 180 // for more details. |
| 178 // Test that LocalStorage has not leaked over to |web_view_1|. | 181 // Test that LocalStorage has not leaked over to |web_view_1|. |
| 179 EXPECT_NSEQ([NSNull null], GetLocalStorageItem(@"someKey2", web_view_1)); | 182 EXPECT_NSEQ([NSNull null], GetLocalStorageItem(@"someKey2", web_view_1)); |
| 180 } | 183 } |
| OLD | NEW |