OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 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 <map> | 5 #include <map> |
6 #include <set> | 6 #include <set> |
7 #include <string> | 7 #include <string> |
8 | 8 |
9 #include "base/basictypes.h" | 9 #include "base/basictypes.h" |
10 #include "base/bind.h" | 10 #include "base/bind.h" |
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
113 "https://mock.captive.portal.long.timeout2/title2.html"; | 113 "https://mock.captive.portal.long.timeout2/title2.html"; |
114 | 114 |
115 // Same as kMockHttpsUrl, except the timeout happens instantly. | 115 // Same as kMockHttpsUrl, except the timeout happens instantly. |
116 const char* const kMockHttpsQuickTimeoutUrl = | 116 const char* const kMockHttpsQuickTimeoutUrl = |
117 "https://mock.captive.portal.quick.timeout/title2.html"; | 117 "https://mock.captive.portal.quick.timeout/title2.html"; |
118 | 118 |
119 // Expected title of a tab once an HTTPS load completes, when not behind a | 119 // Expected title of a tab once an HTTPS load completes, when not behind a |
120 // captive portal. | 120 // captive portal. |
121 const char* const kInternetConnectedTitle = "Title Of Awesomeness"; | 121 const char* const kInternetConnectedTitle = "Title Of Awesomeness"; |
122 | 122 |
123 // Wait until all resources have loaded in an interstitial page. | |
124 bool WaitForInterstitialReady(content::InterstitialPage* interstitial) { | |
125 content::RenderFrameHost* rfh = interstitial->GetMainFrame(); | |
126 if (!rfh) | |
127 return false; | |
128 bool load_complete = false; | |
129 EXPECT_TRUE( | |
130 content::ExecuteScriptAndExtractBool( | |
131 rfh, | |
132 "(function() {" | |
133 " var done = false;" | |
134 " function checkState() {" | |
135 " if (!done && document.readyState == 'complete') {" | |
136 " done = true;" | |
137 " window.domAutomationController.send(true);" | |
138 " }" | |
139 " }" | |
140 " checkState();" | |
141 " document.addEventListener('readystatechange', checkState);" | |
142 "})();", | |
143 &load_complete)); | |
144 return load_complete; | |
145 } | |
146 | |
147 // A URL request job that hangs until FailJobs() is called. Started jobs | 123 // A URL request job that hangs until FailJobs() is called. Started jobs |
148 // are stored in a static class variable containing a linked list so that | 124 // are stored in a static class variable containing a linked list so that |
149 // FailJobs() can locate them. | 125 // FailJobs() can locate them. |
150 class URLRequestTimeoutOnDemandJob : public net::URLRequestJob, | 126 class URLRequestTimeoutOnDemandJob : public net::URLRequestJob, |
151 public base::NonThreadSafe { | 127 public base::NonThreadSafe { |
152 public: | 128 public: |
153 // net::URLRequestJob: | 129 // net::URLRequestJob: |
154 void Start() override; | 130 void Start() override; |
155 | 131 |
156 // All the public static methods below can be called on any thread. | 132 // All the public static methods below can be called on any thread. |
(...skipping 2580 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2737 | 2713 |
2738 EXPECT_EQ(CaptivePortalTabReloader::STATE_NEEDS_RELOAD, | 2714 EXPECT_EQ(CaptivePortalTabReloader::STATE_NEEDS_RELOAD, |
2739 GetStateOfTabReloaderAt(browser(), broken_tab_index)); | 2715 GetStateOfTabReloaderAt(browser(), broken_tab_index)); |
2740 | 2716 |
2741 WaitForInterstitialAttach(broken_tab_contents); | 2717 WaitForInterstitialAttach(broken_tab_contents); |
2742 portal_observer.WaitForResults(1); | 2718 portal_observer.WaitForResults(1); |
2743 | 2719 |
2744 EXPECT_EQ(SSLBlockingPage::kTypeForTesting, | 2720 EXPECT_EQ(SSLBlockingPage::kTypeForTesting, |
2745 GetInterstitialType(broken_tab_contents)); | 2721 GetInterstitialType(broken_tab_contents)); |
2746 } | 2722 } |
OLD | NEW |