[Xfce4-commits] <midori:master> Test case for embedded plugin causing download
Christian Dywan
noreply at xfce.org
Fri Nov 23 00:40:02 CET 2012
Updating branch refs/heads/master
to 209ceed2b052de4b0868ef8eaff1acfbd30102b0 (commit)
from d74aac33ccd0bec4fea5e601b0f3fea955717fb6 (commit)
commit 209ceed2b052de4b0868ef8eaff1acfbd30102b0
Author: Christian Dywan <christian at twotoasts.de>
Date: Fri Nov 23 00:37:33 2012 +0100
Test case for embedded plugin causing download
data/midori.swf | Bin 0 -> 652 bytes
midori/midori-view.c | 21 +++++++++++----------
midori/midori.vapi | 1 +
tests/tab.vala | 19 +++++++++++++++++++
4 files changed, 31 insertions(+), 10 deletions(-)
diff --git a/data/midori.swf b/data/midori.swf
new file mode 100644
index 0000000..d16df89
Binary files /dev/null and b/data/midori.swf differ
diff --git a/midori/midori-view.c b/midori/midori-view.c
index e27394f..fb7d5ee 100644
--- a/midori/midori-view.c
+++ b/midori/midori-view.c
@@ -1200,15 +1200,18 @@ midori_view_web_view_geolocation_decision_cb (WebKitWebView* w
}
#endif
-static void
-midori_view_load_alternate_string (MidoriView* view,
- const gchar* data,
- const gchar* uri,
- WebKitWebFrame* web_frame)
+void
+midori_view_set_html (MidoriView* view,
+ const gchar* data,
+ const gchar* uri,
+ WebKitWebFrame* web_frame)
{
WebKitWebView* web_view = WEBKIT_WEB_VIEW (view->web_view);
+ if (!uri)
+ uri = "about:blank";
if (!web_frame)
web_frame = webkit_web_view_get_main_frame (web_view);
+ katze_item_set_uri (view->item, uri);
midori_tab_set_special (MIDORI_TAB (view), TRUE);
webkit_web_frame_load_alternate_string (
web_frame, data, uri, uri);
@@ -1258,9 +1261,7 @@ midori_view_display_error (MidoriView* view,
g_free (title_escaped);
g_free (template);
- midori_view_load_alternate_string (view,
- result, uri, web_frame);
- katze_item_set_uri (view->item, uri);
+ midori_view_set_html (view, result, uri, web_frame);
g_free (result);
g_free (path);
@@ -2915,7 +2916,7 @@ webkit_web_view_download_requested_cb (GtkWidget* web_view,
GTK_STOCK_OPEN, MIDORI_DOWNLOAD_OPEN,
NULL);
- response = gtk_dialog_run (GTK_DIALOG (dialog));
+ response = midori_dialog_run (GTK_DIALOG (dialog));
gtk_widget_destroy (dialog);
if (response == GTK_RESPONSE_DELETE_EVENT)
response = MIDORI_DOWNLOAD_CANCEL;
@@ -3826,7 +3827,7 @@ midori_view_set_uri (MidoriView* view,
katze_item_set_meta_integer (view->item, "delay", MIDORI_DELAY_UNDELAYED);
html = midori_speed_dial_get_html (dial, NULL);
- midori_view_load_alternate_string (view, html, "about:blank", NULL);
+ midori_view_set_html (view, html, NULL, NULL);
#ifdef G_ENABLE_DEBUG
if (midori_debug ("startup"))
diff --git a/midori/midori.vapi b/midori/midori.vapi
index 1c70e6d..4ca9055 100644
--- a/midori/midori.vapi
+++ b/midori/midori.vapi
@@ -137,6 +137,7 @@ namespace Midori {
public View.with_title (string? title=null, WebSettings? settings=null
, bool append=false);
public void set_uri (string uri);
+ public void set_html (string data, string? uri=null, WebKit.WebFrame? frame=null);
public unowned string get_display_uri ();
public unowned string get_display_title ();
public unowned string get_icon_uri ();
diff --git a/tests/tab.vala b/tests/tab.vala
index 42743f9..01e5524 100644
--- a/tests/tab.vala
+++ b/tests/tab.vala
@@ -161,6 +161,24 @@ void tab_special () {
assert (!source.web_view.get_view_source_mode ());
}
+void tab_download_dialog () {
+ var loop = MainContext.default ();
+ var browser = new Gtk.Window (Gtk.WindowType.TOPLEVEL);
+ var tab = new Midori.View.with_title ();
+ browser.add (tab);
+ /* An embedded plugin shouldn't cause a download dialog */
+ Midori.Test.set_dialog_response (Gtk.ResponseType.DELETE_EVENT);
+ bool did_request_download = false;
+ tab.download_requested.connect ((download) => {
+ did_request_download = true;
+ return true;
+ });
+ /* png2swf -z -j 1 -o data/midori.swf ./icons/16x16/midori.png */
+ tab.set_html ("<embed src=\"res:///midori.swf\">");
+ do { loop.iteration (true); } while (tab.load_status != Midori.LoadStatus.FINISHED);
+ assert (!did_request_download);
+}
+
void main (string[] args) {
Test.init (ref args);
Midori.App.setup (ref args, null);
@@ -170,6 +188,7 @@ void main (string[] args) {
Test.add_func ("/tab/display-title", tab_display_title);
Test.add_func ("/tab/ellipsize", tab_display_ellipsize);
Test.add_func ("/tab/special", tab_special);
+ Test.add_func ("/tab/download", tab_download_dialog);
Test.run ();
}
More information about the Xfce4-commits
mailing list