| 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 #include <string> | |
| 6 #import <WebKit/WebKit.h> | 5 #import <WebKit/WebKit.h> |
| 7 | 6 |
| 7 #include <memory> |
| 8 #include <string> |
| 9 |
| 8 #import "base/mac/scoped_nsobject.h" | 10 #import "base/mac/scoped_nsobject.h" |
| 9 #include "base/memory/scoped_ptr.h" | |
| 10 #include "base/test/ios/wait_util.h" | 11 #include "base/test/ios/wait_util.h" |
| 11 #include "ios/web/public/browser_state.h" | 12 #include "ios/web/public/browser_state.h" |
| 12 #import "ios/web/public/test/http_server.h" | 13 #import "ios/web/public/test/http_server.h" |
| 13 #include "ios/web/public/test/response_providers/string_response_provider.h" | 14 #include "ios/web/public/test/response_providers/string_response_provider.h" |
| 14 #import "ios/web/public/web_view_creation_util.h" | 15 #import "ios/web/public/web_view_creation_util.h" |
| 15 #import "ios/web/test/web_int_test.h" | 16 #import "ios/web/test/web_int_test.h" |
| 16 #import "ios/web/web_state/ui/web_view_js_utils.h" | 17 #import "ios/web/web_state/ui/web_view_js_utils.h" |
| 17 #import "net/base/mac/url_conversions.h" | 18 #import "net/base/mac/url_conversions.h" |
| 18 #include "testing/gtest/include/gtest/gtest.h" | 19 #include "testing/gtest/include/gtest/gtest.h" |
| 19 #include "testing/gtest_mac.h" | 20 #include "testing/gtest_mac.h" |
| (...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 126 }); | 127 }); |
| 127 | 128 |
| 128 web_view.navigationDelegate = old_navigation_delegate; | 129 web_view.navigationDelegate = old_navigation_delegate; |
| 129 } | 130 } |
| 130 | 131 |
| 131 // Returns the BrowserState that is used for testing. | 132 // Returns the BrowserState that is used for testing. |
| 132 web::BrowserState* GetOtrBrowserState() { return &otr_browser_state_; } | 133 web::BrowserState* GetOtrBrowserState() { return &otr_browser_state_; } |
| 133 | 134 |
| 134 private: | 135 private: |
| 135 // The ResponseProvider used to load a simple web page. | 136 // The ResponseProvider used to load a simple web page. |
| 136 scoped_ptr<web::ResponseProvider> provider_; | 137 std::unique_ptr<web::ResponseProvider> provider_; |
| 137 // The OTR browser state used in tests. | 138 // The OTR browser state used in tests. |
| 138 web::TestBrowserState otr_browser_state_; | 139 web::TestBrowserState otr_browser_state_; |
| 139 }; | 140 }; |
| 140 | 141 |
| 141 // Tests that cookies are partitioned between web views created with a | 142 // Tests that cookies are partitioned between web views created with a |
| 142 // non-OTR BrowserState and an OTR BrowserState. | 143 // non-OTR BrowserState and an OTR BrowserState. |
| 143 TEST_F(BrowserStateWebViewPartitionTest, Cookies) { | 144 TEST_F(BrowserStateWebViewPartitionTest, Cookies) { |
| 144 base::scoped_nsobject<WKWebView> web_view_1( | 145 base::scoped_nsobject<WKWebView> web_view_1( |
| 145 web::CreateWKWebView(CGRectZero, GetBrowserState())); | 146 web::CreateWKWebView(CGRectZero, GetBrowserState())); |
| 146 LoadTestWebPage(web_view_1); | 147 LoadTestWebPage(web_view_1); |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 181 SetLocalStorageItem(@"someKey2", @"someValue2", web_view_2); | 182 SetLocalStorageItem(@"someKey2", @"someValue2", web_view_2); |
| 182 // Due to platform limitation, it's not possible to actually set localStorage | 183 // Due to platform limitation, it's not possible to actually set localStorage |
| 183 // item on an OTR BrowserState. Therefore, it's not possible to verify that a | 184 // item on an OTR BrowserState. Therefore, it's not possible to verify that a |
| 184 // localStorage item has been correctly set. | 185 // localStorage item has been correctly set. |
| 185 // Look at | 186 // Look at |
| 186 // http://stackoverflow.com/questions/14555347/html5-localstorage-error-with-s
afari-quota-exceeded-err-dom-exception-22-an | 187 // http://stackoverflow.com/questions/14555347/html5-localstorage-error-with-s
afari-quota-exceeded-err-dom-exception-22-an |
| 187 // for more details. | 188 // for more details. |
| 188 // Test that LocalStorage has not leaked over to |web_view_1|. | 189 // Test that LocalStorage has not leaked over to |web_view_1|. |
| 189 EXPECT_NSEQ(@"", GetLocalStorageItem(@"someKey2", web_view_1)); | 190 EXPECT_NSEQ(@"", GetLocalStorageItem(@"someKey2", web_view_1)); |
| 190 } | 191 } |
| OLD | NEW |