Merge lp:~gue5t/midori/child-frame-errorpages into lp:midori

Proposed by gue5t gue5t
Status: Merged
Approved by: André Stösel
Approved revision: 6309
Merged at revision: 6338
Proposed branch: lp:~gue5t/midori/child-frame-errorpages
Merge into: lp:midori
Diff against target: 28 lines (+10/-3)
1 file modified
midori/midori-view.c (+10/-3)
To merge this branch: bzr merge lp:~gue5t/midori/child-frame-errorpages
Reviewer Review Type Date Requested Status
André Stösel Approve
Paweł Forysiuk Approve
Review via email: mp+178386@code.launchpad.net

Commit message

Don't set tab title/special when a non-main frame displays an error

Description of the change

This isn't getting much attention so I'll copy-paste my explanation from the bug report in case that wasn't visible enough:

I think I figured this out. This only happens when the ad loads in an iframe and is blocked in /etc/hosts, leading the frame to display an error page. I opened midori, attached gdb, and set a breakpoint on midori_view_display_error. Then I browsed to <http://www.handletheheat.com/2013/07/the-ultimate-guide-to-chocolate-chip-cookies.html>, with a /etc/hosts entry causing "dg.specificclick.net" to resolve to "0.0.0.0".

gdb showed midori_view_display_error called from webkit_web_view_load_error_cb, which makes sense. In both calls, the web_frame argument indicated the child frame for the ad, not the webview's main frame. Then, the code of midori_view_display_error calls midori_view_set_html, passing the web_frame along. But midori_view_set_html proceeds to, without considering whether it has a child frame or the main frame, run:

katze_item_set_uri (view->item, uri);
midori_tab_set_special (MIDORI_TAB (view), TRUE);

These should only be done if the errored frame is the webview's main frame. I'll reference this from a branch that fixes the bug, but it looks like a similar problem exists under wk2 with a less clear fix.

This branch fixes wk1; wk2 is untested and its behavior unchanged.

To post a comment you must log in.
Revision history for this message
Paweł Forysiuk (tuxator) :
review: Approve
Revision history for this message
André Stösel (ivaldi) wrote :

The redirect bug is fixed, but after I restart midori the css for the error page in the frame is missing.

review: Needs Fixing
Revision history for this message
gue5t gue5t (gue5t) wrote :

Interesting indeed. I also notice that the page scrolls to the iframe when it loads: this is noticeable if you use a test page that looks like this:

<style>p{height: 100%}</style>
<p></p>
<iframe src="http://mekong:6060/sedus-3ds/" width="90%" height="90%"/>

I'll try to figure out and fix these issues.

Revision history for this message
gue5t gue5t (gue5t) wrote :

The page scrolls to the iframe because our error template has the "autofocus" attribute on its button. We'll have to change that to something interpolated into the template only for main-frame error pages.

Revision history for this message
gue5t gue5t (gue5t) wrote :

The CSS is missing because midori_view_web_view_resource_request_cb denies access to res:// as follows:
    /* Only apply custom URIs to special pages for security purposes */
    if (!midori_tab_get_special (MIDORI_TAB (view)))
        return;

This checks if the entire tab is an error page, and since it isn't, doesn't allow the frame which needs an error page to load res://about.css. :(

I'll see what can be done.

Revision history for this message
André Stösel (ivaldi) wrote :

The bug fix works, the styling issue is no regression and I think this should be merged before release.

(I opened a new bug #1210841 for the styling issue.)

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'midori/midori-view.c'
2--- midori/midori-view.c 2013-08-02 12:00:42 +0000
3+++ midori/midori-view.c 2013-08-02 20:59:28 +0000
4@@ -1140,14 +1140,21 @@
5 WebKitWebView* web_view = WEBKIT_WEB_VIEW (view->web_view);
6 if (!uri)
7 uri = "about:blank";
8- katze_item_set_uri (view->item, uri);
9- midori_tab_set_special (MIDORI_TAB (view), TRUE);
10 #ifndef HAVE_WEBKIT2
11+ WebKitWebFrame* main_frame = webkit_web_view_get_main_frame (web_view);
12+ if (web_frame == main_frame)
13+ {
14+ katze_item_set_uri (view->item, uri);
15+ midori_tab_set_special (MIDORI_TAB (view), TRUE);
16+ }
17 if (!web_frame)
18- web_frame = webkit_web_view_get_main_frame (web_view);
19+ web_frame = main_frame;
20 webkit_web_frame_load_alternate_string (
21 web_frame, data, uri, uri);
22 #else
23+ /* XXX: with webkit2 ensure child frames do not set tab URI/special/html */
24+ katze_item_set_uri (view->item, uri);
25+ midori_tab_set_special (MIDORI_TAB (view), TRUE);
26 webkit_web_view_load_alternate_html (web_view, data, uri, uri);
27 #endif
28 }

Subscribers

People subscribed via source and target branches

to all changes: