Merge lp:~osomon/oxide/backport-42-patch-for-isError into lp:oxide/1.5
- backport-42-patch-for-isError
- Merge into 1.5
Proposed by
Olivier Tilloy
Status: | Merged |
---|---|
Merged at revision: | 966 |
Proposed branch: | lp:~osomon/oxide/backport-42-patch-for-isError |
Merge into: | lp:oxide/1.5 |
Diff against target: |
298 lines (+266/-0) 4 files modified
patches/bug1423531.patch (+202/-0) patches/series (+1/-0) qt/tests/qmltests/api/tst_WebView_loading.qml (+23/-0) qt/tests/qmltests/api/tst_WebView_save_restore_state.qml (+40/-0) |
To merge this branch: | bzr merge lp:~osomon/oxide/backport-42-patch-for-isError |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Chris Coulson | Approve | ||
Review via email: mp+251749@code.launchpad.net |
Commit message
Backport commit 7431bb2983db683
Description of the change
To post a comment you must log in.
Preview Diff
[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1 | === added file 'patches/bug1423531.patch' | |||
2 | --- patches/bug1423531.patch 1970-01-01 00:00:00 +0000 | |||
3 | +++ patches/bug1423531.patch 2015-03-04 14:35:28 +0000 | |||
4 | @@ -0,0 +1,202 @@ | |||
5 | 1 | # Description: backport commit 7431bb2983db683dcc4556e1918556254c3d5589 | ||
6 | 2 | # from the 42 branch to fix https://launchpad.net/bugs/1423531 | ||
7 | 3 | # Author: Olivier Tilloy <olivier.tilloy@canonical.com> | ||
8 | 4 | |||
9 | 5 | diff --git a/chrome/browser/ui/zoom/zoom_controller_browsertest.cc b/chrome/browser/ui/zoom/zoom_controller_browsertest.cc | ||
10 | 6 | --- a/chrome/browser/ui/zoom/zoom_controller_browsertest.cc | ||
11 | 7 | +++ b/chrome/browser/ui/zoom/zoom_controller_browsertest.cc | ||
12 | 8 | @@ -8,6 +8,7 @@ | ||
13 | 9 | #include "base/process/kill.h" | ||
14 | 10 | #include "chrome/browser/profiles/profile.h" | ||
15 | 11 | #include "chrome/browser/ui/browser.h" | ||
16 | 12 | +#include "chrome/browser/ui/browser_commands.h" | ||
17 | 13 | #include "chrome/browser/ui/tabs/tab_strip_model.h" | ||
18 | 14 | #include "chrome/browser/ui/webui/signin/login_ui_test_utils.h" | ||
19 | 15 | #include "chrome/browser/ui/zoom/chrome_zoom_level_prefs.h" | ||
20 | 16 | @@ -140,6 +141,57 @@ | ||
21 | 17 | EXPECT_FLOAT_EQ(new_zoom_level, zoom_controller->GetZoomLevel()); | ||
22 | 18 | } | ||
23 | 19 | |||
24 | 20 | +IN_PROC_BROWSER_TEST_F(ZoomControllerBrowserTest, | ||
25 | 21 | + ErrorPagesCanZoomAfterTabRestore) { | ||
26 | 22 | + // This url is meant to cause a network error page to be loaded. | ||
27 | 23 | + // Tests can't reach the network, so this test should continue | ||
28 | 24 | + // to work even if the domain listed is someday registered. | ||
29 | 25 | + GURL url("http://kjfhkjsdf.com"); | ||
30 | 26 | + | ||
31 | 27 | + TabStripModel* tab_strip = browser()->tab_strip_model(); | ||
32 | 28 | + ASSERT_TRUE(tab_strip); | ||
33 | 29 | + | ||
34 | 30 | + ui_test_utils::NavigateToURLWithDisposition( | ||
35 | 31 | + browser(), url, NEW_FOREGROUND_TAB, | ||
36 | 32 | + ui_test_utils::BROWSER_TEST_WAIT_FOR_NAVIGATION); | ||
37 | 33 | + { | ||
38 | 34 | + content::WebContents* web_contents = tab_strip->GetActiveWebContents(); | ||
39 | 35 | + | ||
40 | 36 | + EXPECT_EQ( | ||
41 | 37 | + content::PAGE_TYPE_ERROR, | ||
42 | 38 | + web_contents->GetController().GetLastCommittedEntry()->GetPageType()); | ||
43 | 39 | + | ||
44 | 40 | + content::WebContentsDestroyedWatcher destroyed_watcher(web_contents); | ||
45 | 41 | + tab_strip->CloseWebContentsAt(tab_strip->active_index(), | ||
46 | 42 | + TabStripModel::CLOSE_CREATE_HISTORICAL_TAB); | ||
47 | 43 | + destroyed_watcher.Wait(); | ||
48 | 44 | + } | ||
49 | 45 | + EXPECT_EQ(1, tab_strip->count()); | ||
50 | 46 | + | ||
51 | 47 | + content::WebContentsAddedObserver new_web_contents_observer; | ||
52 | 48 | + chrome::RestoreTab(browser()); | ||
53 | 49 | + content::WebContents* web_contents = | ||
54 | 50 | + new_web_contents_observer.GetWebContents(); | ||
55 | 51 | + content::WaitForLoadStop(web_contents); | ||
56 | 52 | + | ||
57 | 53 | + EXPECT_EQ(2, tab_strip->count()); | ||
58 | 54 | + | ||
59 | 55 | + EXPECT_EQ( | ||
60 | 56 | + content::PAGE_TYPE_ERROR, | ||
61 | 57 | + web_contents->GetController().GetLastCommittedEntry()->GetPageType()); | ||
62 | 58 | + | ||
63 | 59 | + ZoomController* zoom_controller = | ||
64 | 60 | + ZoomController::FromWebContents(web_contents); | ||
65 | 61 | + | ||
66 | 62 | + double old_zoom_level = zoom_controller->GetZoomLevel(); | ||
67 | 63 | + double new_zoom_level = old_zoom_level + 0.5; | ||
68 | 64 | + | ||
69 | 65 | + // The following attempt to change the zoom level for an error page should | ||
70 | 66 | + // fail. | ||
71 | 67 | + zoom_controller->SetZoomLevel(new_zoom_level); | ||
72 | 68 | + EXPECT_FLOAT_EQ(new_zoom_level, zoom_controller->GetZoomLevel()); | ||
73 | 69 | +} | ||
74 | 70 | + | ||
75 | 71 | IN_PROC_BROWSER_TEST_F(ZoomControllerBrowserTest, Observe) { | ||
76 | 72 | content::WebContents* web_contents = | ||
77 | 73 | browser()->tab_strip_model()->GetActiveWebContents(); | ||
78 | 74 | diff --git a/content/browser/frame_host/navigation_controller_impl.cc b/content/browser/frame_host/navigation_controller_impl.cc | ||
79 | 75 | --- a/content/browser/frame_host/navigation_controller_impl.cc | ||
80 | 76 | +++ b/content/browser/frame_host/navigation_controller_impl.cc | ||
81 | 77 | @@ -1050,10 +1050,6 @@ | ||
82 | 78 | pending_entry_->site_instance() == rfh->GetSiteInstance())) { | ||
83 | 79 | new_entry = new NavigationEntryImpl(*pending_entry_); | ||
84 | 80 | |||
85 | 81 | - // Don't use the page type from the pending entry. Some interstitial page | ||
86 | 82 | - // may have set the type to interstitial. Once we commit, however, the page | ||
87 | 83 | - // type must always be normal. | ||
88 | 84 | - new_entry->set_page_type(PAGE_TYPE_NORMAL); | ||
89 | 85 | update_virtual_url = new_entry->update_virtual_url_with_url(); | ||
90 | 86 | } else { | ||
91 | 87 | new_entry = new NavigationEntryImpl; | ||
92 | 88 | @@ -1074,8 +1070,12 @@ | ||
93 | 89 | update_virtual_url = needs_update; | ||
94 | 90 | } | ||
95 | 91 | |||
96 | 92 | - if (params.url_is_unreachable) | ||
97 | 93 | - new_entry->set_page_type(PAGE_TYPE_ERROR); | ||
98 | 94 | + // Don't use the page type from the pending entry. Some interstitial page | ||
99 | 95 | + // may have set the type to interstitial. Once we commit, however, the page | ||
100 | 96 | + // type must always be normal or error. | ||
101 | 97 | + new_entry->set_page_type(params.url_is_unreachable ? PAGE_TYPE_ERROR | ||
102 | 98 | + : PAGE_TYPE_NORMAL); | ||
103 | 99 | + | ||
104 | 100 | new_entry->SetURL(params.url); | ||
105 | 101 | if (update_virtual_url) | ||
106 | 102 | UpdateVirtualURLToURL(new_entry, params.url); | ||
107 | 103 | @@ -1126,6 +1126,8 @@ | ||
108 | 104 | NavigationEntryImpl* entry = entries_[entry_index].get(); | ||
109 | 105 | |||
110 | 106 | // The URL may have changed due to redirects. | ||
111 | 107 | + entry->set_page_type(params.url_is_unreachable ? PAGE_TYPE_ERROR | ||
112 | 108 | + : PAGE_TYPE_NORMAL); | ||
113 | 109 | entry->SetURL(params.url); | ||
114 | 110 | entry->SetReferrer(params.referrer); | ||
115 | 111 | if (entry->update_virtual_url_with_url()) | ||
116 | 112 | @@ -1178,6 +1180,8 @@ | ||
117 | 113 | existing_entry->set_unique_id(pending_entry_->GetUniqueID()); | ||
118 | 114 | |||
119 | 115 | // The URL may have changed due to redirects. | ||
120 | 116 | + existing_entry->set_page_type(params.url_is_unreachable ? PAGE_TYPE_ERROR | ||
121 | 117 | + : PAGE_TYPE_NORMAL); | ||
122 | 118 | if (existing_entry->update_virtual_url_with_url()) | ||
123 | 119 | UpdateVirtualURLToURL(existing_entry, params.url); | ||
124 | 120 | existing_entry->SetURL(params.url); | ||
125 | 121 | @@ -1204,6 +1208,8 @@ | ||
126 | 122 | // entry and it will be the same page as the new navigation (minus the | ||
127 | 123 | // reference fragments, of course). We'll update the URL of the existing | ||
128 | 124 | // entry without pruning the forward history. | ||
129 | 125 | + existing_entry->set_page_type(params.url_is_unreachable ? PAGE_TYPE_ERROR | ||
130 | 126 | + : PAGE_TYPE_NORMAL); | ||
131 | 127 | existing_entry->SetURL(params.url); | ||
132 | 128 | if (existing_entry->update_virtual_url_with_url()) | ||
133 | 129 | UpdateVirtualURLToURL(existing_entry, params.url); | ||
134 | 130 | diff --git a/content/browser/frame_host/navigation_controller_impl_unittest.cc b/content/browser/frame_host/navigation_controller_impl_unittest.cc | ||
135 | 131 | --- a/content/browser/frame_host/navigation_controller_impl_unittest.cc | ||
136 | 132 | +++ b/content/browser/frame_host/navigation_controller_impl_unittest.cc | ||
137 | 133 | @@ -28,6 +28,7 @@ | ||
138 | 134 | #include "content/public/browser/web_contents_observer.h" | ||
139 | 135 | #include "content/public/common/content_switches.h" | ||
140 | 136 | #include "content/public/common/page_state.h" | ||
141 | 137 | +#include "content/public/common/page_type.h" | ||
142 | 138 | #include "content/public/common/url_constants.h" | ||
143 | 139 | #include "content/public/test/mock_render_process_host.h" | ||
144 | 140 | #include "content/public/test/test_notification_tracker.h" | ||
145 | 141 | @@ -4456,4 +4457,61 @@ | ||
146 | 142 | EXPECT_EQ(0, delegate->repost_form_warning_count()); | ||
147 | 143 | } | ||
148 | 144 | |||
149 | 145 | +TEST_F(NavigationControllerTest, UnreachableURLGivesErrorPage) { | ||
150 | 146 | + GURL url("http://foo"); | ||
151 | 147 | + FrameHostMsg_DidCommitProvisionalLoad_Params params; | ||
152 | 148 | + params.page_id = 1; | ||
153 | 149 | + params.url = url; | ||
154 | 150 | + params.transition = ui::PAGE_TRANSITION_LINK; | ||
155 | 151 | + params.gesture = NavigationGestureUser; | ||
156 | 152 | + params.page_state = PageState::CreateFromURL(url); | ||
157 | 153 | + params.was_within_same_page = false; | ||
158 | 154 | + params.is_post = true; | ||
159 | 155 | + params.post_id = 2; | ||
160 | 156 | + params.url_is_unreachable = true; | ||
161 | 157 | + // Navigate to new page | ||
162 | 158 | + { | ||
163 | 159 | + LoadCommittedDetails details; | ||
164 | 160 | + controller_impl().RendererDidNavigate(main_test_rfh(), params, &details); | ||
165 | 161 | + EXPECT_EQ(PAGE_TYPE_ERROR, | ||
166 | 162 | + controller_impl().GetLastCommittedEntry()->GetPageType()); | ||
167 | 163 | + EXPECT_EQ(NAVIGATION_TYPE_NEW_PAGE, details.type); | ||
168 | 164 | + } | ||
169 | 165 | + | ||
170 | 166 | + // Navigate to existing page. | ||
171 | 167 | + { | ||
172 | 168 | + LoadCommittedDetails details; | ||
173 | 169 | + controller_impl().RendererDidNavigate(main_test_rfh(), params, &details); | ||
174 | 170 | + EXPECT_EQ(PAGE_TYPE_ERROR, | ||
175 | 171 | + controller_impl().GetLastCommittedEntry()->GetPageType()); | ||
176 | 172 | + EXPECT_EQ(NAVIGATION_TYPE_EXISTING_PAGE, details.type); | ||
177 | 173 | + } | ||
178 | 174 | + | ||
179 | 175 | + // Navigate to same page. | ||
180 | 176 | + // Note: The call to LoadURL() creates a pending entry in order to trigger the | ||
181 | 177 | + // same-page transition. | ||
182 | 178 | + controller_impl().LoadURL( | ||
183 | 179 | + url, Referrer(), ui::PAGE_TRANSITION_TYPED, std::string()); | ||
184 | 180 | + params.transition = ui::PAGE_TRANSITION_TYPED; | ||
185 | 181 | + { | ||
186 | 182 | + LoadCommittedDetails details; | ||
187 | 183 | + controller_impl().RendererDidNavigate(main_test_rfh(), params, &details); | ||
188 | 184 | + EXPECT_EQ(PAGE_TYPE_ERROR, | ||
189 | 185 | + controller_impl().GetLastCommittedEntry()->GetPageType()); | ||
190 | 186 | + EXPECT_EQ(NAVIGATION_TYPE_SAME_PAGE, details.type); | ||
191 | 187 | + } | ||
192 | 188 | + | ||
193 | 189 | + // Navigate in page. | ||
194 | 190 | + params.url = GURL("http://foo#foo"); | ||
195 | 191 | + params.transition = ui::PAGE_TRANSITION_LINK; | ||
196 | 192 | + params.was_within_same_page = true; | ||
197 | 193 | + { | ||
198 | 194 | + LoadCommittedDetails details; | ||
199 | 195 | + controller_impl().RendererDidNavigate(main_test_rfh(), params, &details); | ||
200 | 196 | + EXPECT_EQ(PAGE_TYPE_ERROR, | ||
201 | 197 | + controller_impl().GetLastCommittedEntry()->GetPageType()); | ||
202 | 198 | + EXPECT_EQ(NAVIGATION_TYPE_IN_PAGE, details.type); | ||
203 | 199 | + } | ||
204 | 200 | +} | ||
205 | 201 | + | ||
206 | 202 | } // namespace content | ||
207 | 0 | 203 | ||
208 | === modified file 'patches/series' | |||
209 | --- patches/series 2015-02-06 22:41:44 +0000 | |||
210 | +++ patches/series 2015-03-04 14:35:28 +0000 | |||
211 | @@ -29,3 +29,4 @@ | |||
212 | 29 | allow-os-override-for-gpu-manager.patch | 29 | allow-os-override-for-gpu-manager.patch |
213 | 30 | viewport-min-width.patch | 30 | viewport-min-width.patch |
214 | 31 | dont-hide-desktop-scrollbars-without-pinch-viewport.patch | 31 | dont-hide-desktop-scrollbars-without-pinch-viewport.patch |
215 | 32 | bug1423531.patch | ||
216 | 32 | 33 | ||
217 | === modified file 'qt/tests/qmltests/api/tst_WebView_loading.qml' | |||
218 | --- qt/tests/qmltests/api/tst_WebView_loading.qml 2015-01-13 12:31:34 +0000 | |||
219 | +++ qt/tests/qmltests/api/tst_WebView_loading.qml 2015-03-04 14:35:28 +0000 | |||
220 | @@ -162,6 +162,29 @@ | |||
221 | 162 | compare(spy.count, 1, | 162 | compare(spy.count, 1, |
222 | 163 | "WebView.loading should have changed twice during the load"); | 163 | "WebView.loading should have changed twice during the load"); |
223 | 164 | compare(expectedLoadEvents.length, 0, "Some load events are missing"); | 164 | compare(expectedLoadEvents.length, 0, "Some load events are missing"); |
224 | 165 | |||
225 | 166 | // Verify that reloading a page that triggered an error | ||
226 | 167 | // generates the same sequence of load events | ||
227 | 168 | spy.clear(); | ||
228 | 169 | expectedLoadEvents = [ | ||
229 | 170 | { type: LoadEvent.TypeStarted, url: url, loading: true }, | ||
230 | 171 | { type: LoadEvent.TypeFailed, url: url, loading: true }, | ||
231 | 172 | { type: LoadEvent.TypeCommitted, url: url, error: true, loading: true } | ||
232 | 173 | ]; | ||
233 | 174 | webView.reload(); | ||
234 | 175 | |||
235 | 176 | verify(webView.loading, | ||
236 | 177 | "WebView.loading should be true once we start loading"); | ||
237 | 178 | compare(spy.count, 1); | ||
238 | 179 | |||
239 | 180 | spy.clear(); | ||
240 | 181 | spy.wait(); | ||
241 | 182 | |||
242 | 183 | verify(!webView.loading, | ||
243 | 184 | "WebView.loading should be false after we finish loading"); | ||
244 | 185 | compare(spy.count, 1, | ||
245 | 186 | "WebView.loading should have changed twice during the load"); | ||
246 | 187 | compare(expectedLoadEvents.length, 0, "Some load events are missing"); | ||
247 | 165 | } | 188 | } |
248 | 166 | 189 | ||
249 | 167 | function test_WebView_loading5_redirection() { | 190 | function test_WebView_loading5_redirection() { |
250 | 168 | 191 | ||
251 | === modified file 'qt/tests/qmltests/api/tst_WebView_save_restore_state.qml' | |||
252 | --- qt/tests/qmltests/api/tst_WebView_save_restore_state.qml 2014-11-20 12:37:10 +0000 | |||
253 | +++ qt/tests/qmltests/api/tst_WebView_save_restore_state.qml 2015-03-04 14:35:28 +0000 | |||
254 | @@ -149,4 +149,44 @@ | |||
255 | 149 | "document.querySelector('#textInput').value") == "Te$t"; }); | 149 | "document.querySelector('#textInput').value") == "Te$t"; }); |
256 | 150 | restored.destroy(); | 150 | restored.destroy(); |
257 | 151 | } | 151 | } |
258 | 152 | |||
259 | 153 | function test_WebView_save_and_restore_error_page_data() { | ||
260 | 154 | return get_restore_types(); | ||
261 | 155 | } | ||
262 | 156 | |||
263 | 157 | // Test that restoring the state of a navigation that had triggered an error | ||
264 | 158 | // triggers the error again (see https://launchpad.net/bugs/1423531). | ||
265 | 159 | function test_WebView_save_and_restore_error_page(data) { | ||
266 | 160 | var url = "http://invalid/"; | ||
267 | 161 | webView.url = url; | ||
268 | 162 | verify(webView.waitForLoadCommitted(), | ||
269 | 163 | "Timed out waiting for error page"); | ||
270 | 164 | |||
271 | 165 | var state = webView.currentState; | ||
272 | 166 | verify(state.length > 0); | ||
273 | 167 | |||
274 | 168 | var restored = webViewComponent.createObject( | ||
275 | 169 | webView, {"restoreType": data.restoreType, "restoreState": state}); | ||
276 | 170 | verify(restored !== null); | ||
277 | 171 | |||
278 | 172 | var expectedLoadEvents = [ | ||
279 | 173 | { type: LoadEvent.TypeStarted, isError: false }, | ||
280 | 174 | { type: LoadEvent.TypeFailed, isError: false }, | ||
281 | 175 | { type: LoadEvent.TypeCommitted, isError: true } | ||
282 | 176 | ]; | ||
283 | 177 | function _loadEvent(event) { | ||
284 | 178 | var expected = expectedLoadEvents[0]; | ||
285 | 179 | compare(event.type, expected.type); | ||
286 | 180 | compare(event.url, url); | ||
287 | 181 | compare(event.isError, expected.isError); | ||
288 | 182 | expectedLoadEvents.shift(); | ||
289 | 183 | } | ||
290 | 184 | restored.loadEvent.connect(_loadEvent); | ||
291 | 185 | |||
292 | 186 | tryCompare(restored, "url", url); | ||
293 | 187 | restored.waitFor(function() { | ||
294 | 188 | return (expectedLoadEvents.length === 0); | ||
295 | 189 | }); | ||
296 | 190 | restored.destroy(); | ||
297 | 191 | } | ||
298 | 152 | } | 192 | } |
Thanks - I wasn't sure if you'd get a chance to do it today, so I've merged this in to 1.5