[Xfce4-commits] <midori:master> Unit test view source and reset source tabs for new URLs

Christian Dywan noreply at xfce.org
Mon Oct 29 11:12:01 CET 2012


Updating branch refs/heads/master
         to bc557f9988141f5ed14ad259edeb7d17a86e1261 (commit)
       from 6891492f1ee56b86caf495650a22fd82c910219a (commit)

commit bc557f9988141f5ed14ad259edeb7d17a86e1261
Author: Christian Dywan <christian at twotoasts.de>
Date:   Mon Oct 29 11:07:50 2012 +0100

    Unit test view source and reset source tabs for new URLs
    
    Fixes: https://bugs.launchpad.net/midori/+bug/875295

 midori/midori-tab.vala |    2 +-
 midori/midori-view.c   |    8 +-------
 tests/tab.vala         |   21 +++++++++++++++++++++
 3 files changed, 23 insertions(+), 8 deletions(-)

diff --git a/midori/midori-tab.vala b/midori/midori-tab.vala
index d70e9c3..b6c78a9 100644
--- a/midori/midori-tab.vala
+++ b/midori/midori-tab.vala
@@ -119,7 +119,7 @@ namespace Midori {
         }
 
         public bool can_view_source () {
-            if (is_blank () || special)
+            if (is_blank () || special || web_view.get_view_source_mode ())
                 return false;
             string content_type = ContentType.from_mime_type (mime_type);
 #if HAVE_WIN32
diff --git a/midori/midori-view.c b/midori/midori-view.c
index a2bda09..59df6a6 100644
--- a/midori/midori-view.c
+++ b/midori/midori-view.c
@@ -2767,13 +2767,6 @@ webkit_web_view_mime_type_decision_cb (GtkWidget*               web_view,
 {
     if (webkit_web_view_can_show_mime_type (WEBKIT_WEB_VIEW (web_view), mime_type))
     {
-        gboolean view_source = FALSE;
-        /* Dedicated source code views are always pseudo-blank pages */
-        if (midori_view_is_blank (view))
-            view_source = webkit_web_view_get_view_source_mode (WEBKIT_WEB_VIEW (web_view));
-
-        webkit_web_view_set_view_source_mode (WEBKIT_WEB_VIEW (web_view), view_source);
-
         if (web_frame == webkit_web_view_get_main_frame (WEBKIT_WEB_VIEW (web_view)))
         {
             g_warn_if_fail (mime_type != NULL);
@@ -4061,6 +4054,7 @@ midori_view_set_uri (MidoriView*  view,
             midori_tab_set_uri (MIDORI_TAB (view), uri);
             katze_item_set_uri (view->item, midori_tab_get_uri (MIDORI_TAB (view)));
             katze_assign (view->title, NULL);
+            webkit_web_view_set_view_source_mode (WEBKIT_WEB_VIEW (view->web_view), FALSE);
             webkit_web_view_load_uri (WEBKIT_WEB_VIEW (view->web_view), uri);
         }
     }
diff --git a/tests/tab.vala b/tests/tab.vala
index c01868b..3fe1439 100644
--- a/tests/tab.vala
+++ b/tests/tab.vala
@@ -127,6 +127,27 @@ void tab_special () {
     assert (tab.can_view_source ());
     assert (!tab.special);
     assert (tab.can_save ());
+    tab.destroy ();
+
+    /* Mimic browser: SourceView with no external editor */
+    var source = new Midori.View.with_title ();
+    browser.add (source);
+    source.web_view.set_view_source_mode (true);
+    source.web_view.load_uri ("http://example.com");
+    do { loop.iteration (true); } while (source.load_status != Midori.LoadStatus.FINISHED);
+    assert (!source.is_blank ());
+    assert (!source.can_view_source ());
+    /* FIXME assert (!source.special); */
+    /* FIXME assert (source.can_save ()); */
+    assert (source.web_view.get_view_source_mode ());
+
+    source.set_uri ("http://.invalid");
+    do { loop.iteration (true); } while (source.load_status != Midori.LoadStatus.FINISHED);
+    assert (!source.is_blank ());
+    assert (!source.can_view_source ());
+    assert (source.special);
+    assert (!source.can_save ());
+    assert (!source.web_view.get_view_source_mode ());
 }
 
 void main (string[] args) {


More information about the Xfce4-commits mailing list