[tests] Add support for loading local files without full URI
authorKalle Vahlman <kalle.vahlman@movial.com>
Tue, 21 Apr 2009 10:48:07 +0000 (13:48 +0300)
committerKalle Vahlman <kalle.vahlman@movial.com>
Tue, 21 Apr 2009 10:48:07 +0000 (13:48 +0300)
tests/jscorebus-webkit.c

index 8087e265dab4581cef5353af43ec17f225c069ec..1b20867c312e730f84b413c06da44fc473d2817b 100644 (file)
@@ -95,7 +95,19 @@ int main(int argc, char *argv[])
   g_signal_connect(view, "window-object-cleared",
                    G_CALLBACK(_window_object_cleared), session_connection);
 
-  webkit_web_view_open(WEBKIT_WEB_VIEW(view), argv[1]);
+  if (g_str_has_prefix("http://", argv[1])
+   || g_str_has_prefix("https://", argv[1])
+   || g_str_has_prefix("file://", argv[1]))
+  {
+    webkit_web_view_open(WEBKIT_WEB_VIEW(view), argv[1]);
+  } else {
+    gchar *pwd = g_get_current_dir();
+    gchar *url = g_strjoin("/", "file://", pwd, argv[1]);
+    webkit_web_view_open(WEBKIT_WEB_VIEW(view), url);
+    g_free(url);
+    g_free(pwd);
+  }
+
   gtk_widget_set_size_request(window,
                               640,
                               480);