<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array"/>
  <modified type="array">
    <modified>
      <diff>@@ -16,12 +16,6 @@ void
 set_icon();
 
 void
-cmd_cookie_handler();
-
-void
-cmd_scheme_handler();
-
-void
 move_statusbar();
 
 void</diff>
      <filename>callbacks.h</filename>
    </modified>
    <modified>
      <diff>@@ -28,7 +28,7 @@ set scripts_dir    = $XDG_DATA_HOME/uzbl:/usr/local/share/uzbl/examples/data/uzb
 
 set download_handler   = spawn @scripts_dir/download.sh
 set cookie_handler     = talk_to_socket $XDG_CACHE_HOME/uzbl/cookie_daemon_socket
-set scheme_handler     = spawn @scripts_dir/scheme.py
+set scheme_handler     = sync_spawn @scripts_dir/scheme.py
 
 # New window handler options
 #set new_window        = sh 'echo uri &quot;$8&quot; &gt; $4' # open in same window</diff>
      <filename>examples/config/uzbl/config</filename>
    </modified>
    <modified>
      <diff>@@ -29,6 +29,33 @@ extern UzblCore uzbl;
 
 #define INSTANCE_NAME &quot;testing&quot;
 
+gchar*
+assert_str_beginswith(GString *expected, gchar *actual) {
+    gchar *actual_beginning = g_strndup(actual, expected-&gt;len);
+    g_assert_cmpstr(expected-&gt;str, ==, actual_beginning);
+    g_free(actual_beginning);
+
+    /* return the part of the actual string that hasn't been compared yet */
+    return &amp;actual[expected-&gt;len];
+}
+
+/* compare the contents of uzbl.comm.sync_stdout to the standard arguments that
+ * should have been passed. This is meant to be called after something like &quot;sync echo&quot;. */
+gchar*
+assert_sync_beginswith_stdarg() {
+    GString *stdargs = g_string_new(&quot;&quot;);
+
+    g_string_append_printf(stdargs, &quot;%s %d %d &quot;, uzbl.state.config_file, getpid(), (int)uzbl.xwin);
+    g_string_append_printf(stdargs, &quot;%s %s &quot;, uzbl.comm.fifo_path, uzbl.comm.socket_path);
+    g_string_append_printf(stdargs, &quot;%s %s &quot;, uzbl.state.uri, uzbl.gui.main_title);
+
+    gchar *rest = assert_str_beginswith(stdargs, uzbl.comm.sync_stdout);
+
+    g_string_free(stdargs, TRUE);
+
+    return rest;
+}
+
 #define ASSERT_EVENT(EF, STR) { read_event(ef); \
     g_assert_cmpstr(&quot;EVENT [&quot; INSTANCE_NAME &quot;] &quot; STR &quot;\n&quot;, ==, ef-&gt;event_buffer); }
 
@@ -96,8 +123,6 @@ event_fixture_setup(struct EventFixture *ef, const void* data)
     ef-&gt;test_sock = socks[1];
 
     /* attach uzbl_sock to uzbl's event dispatcher. */
-    uzbl.comm.socket_path = &quot;/tmp/some-nonexistant-socket&quot;;
-
     GIOChannel *iochan = g_io_channel_unix_new(ef-&gt;uzbl_sock);
     g_io_channel_set_encoding(iochan, NULL, NULL);
 
@@ -163,8 +188,17 @@ test_set_variable (struct EventFixture *ef, const void *data) {
     g_assert_cmpint(0, ==, uzbl.behave.forward_keys);
 
     /* set a float */
-    parse_cmd_line(&quot;set zoom_level = 0.25&quot;, NULL);
-    ASSERT_EVENT(ef, &quot;VARIABLE_SET zoom_level float 0.250000&quot;);
+    /* we have to be careful about locales here */
+    GString *cmd, *ev;
+    cmd = g_string_new(&quot;set zoom_level = &quot;);
+    g_string_append_printf(cmd, &quot;%f&quot;, 0.25);
+    parse_cmd_line(g_string_free(cmd, FALSE), NULL);
+
+    ev = g_string_new(&quot;EVENT [&quot; INSTANCE_NAME &quot;] VARIABLE_SET zoom_level float &quot;);
+    g_string_append_printf(ev, &quot;%f\n&quot;, 0.25);
+    read_event(ef);
+    g_assert_cmpstr(g_string_free(ev, FALSE), ==, ef-&gt;event_buffer);
+
     g_assert_cmpfloat(0.25, ==, uzbl.behave.zoom_level);
 
     /* set a constant int (nothing should happen) */
@@ -209,6 +243,9 @@ test_print (void) {
 
 void
 test_scroll (void) {
+    uzbl.gui.scbar_v = (GtkScrollbar*) gtk_vscrollbar_new (NULL);
+    uzbl.gui.bar_v = gtk_range_get_adjustment((GtkRange*) uzbl.gui.scbar_v);
+
     gtk_adjustment_set_lower(uzbl.gui.bar_v, 0);
     gtk_adjustment_set_upper(uzbl.gui.bar_v, 100);
     gtk_adjustment_set_page_size(uzbl.gui.bar_v, 5);
@@ -255,6 +292,9 @@ void
 test_sync_sh (void) {
     parse_cmd_line(&quot;sync_sh 'echo Test echo.'&quot;, NULL);
     g_assert_cmpstr(&quot;Test echo.\n&quot;, ==, uzbl.comm.sync_stdout);
+
+    /* clean up after ourselves */
+    uzbl.comm.sync_stdout = strfree(uzbl.comm.sync_stdout);
 }
 
 void
@@ -273,6 +313,36 @@ test_js (void) {
     g_string_free(result, TRUE);
 }
 
+void
+test_run_handler_arg_order (void) {
+    run_handler(&quot;sync_spawn echo uvw xyz&quot;, &quot;abc def&quot;);
+
+    assert(uzbl.comm.sync_stdout);
+
+    /* the result should begin with the standard handler arguments */
+    gchar *rest = assert_sync_beginswith_stdarg();
+
+    /* the rest of the result should be the arguments passed to run_handler. */
+    /* the arguments in the second argument to run_handler should be placed before any
+     * included in the first argument to run handler. */
+    g_assert_cmpstr(&quot;abc def uvw xyz\n&quot;, ==, rest);
+}
+
+void
+test_run_handler_expand (void) {
+    uzbl.gui.sbar.msg = &quot;Test message&quot;;
+    run_handler(&quot;sync_spawn echo @status_message&quot;, &quot;result:&quot;);
+
+    assert(uzbl.comm.sync_stdout);
+
+    /* the result should begin with the standard handler arguments */
+    gchar *rest = assert_sync_beginswith_stdarg();
+
+    /* the rest of the result should be the arguments passed to run_handler. */
+    /* the user-specified arguments to the handler should have been expanded */
+    g_assert_cmpstr(&quot;result: Test message\n&quot;, ==, rest);
+}
+
 int
 main (int argc, char *argv[]) {
     /* set up tests */
@@ -289,9 +359,20 @@ main (int argc, char *argv[]) {
 
     g_test_add_func(&quot;/test-command/js&quot;,             test_js);
 
+    /* the following aren't really &quot;command&quot; tests, but they're not worth
+     * splitting into a separate file yet */
+    g_test_add_func(&quot;/test-command/run_handler/arg-order&quot;,      test_run_handler_arg_order);
+    g_test_add_func(&quot;/test-command/run_handler/expand&quot;,         test_run_handler_expand);
+
     /* set up uzbl */
     initialize(argc, argv);
 
+    uzbl.state.config_file = &quot;/tmp/uzbl-config&quot;;
+    uzbl.comm.fifo_path = &quot;/tmp/some-nonexistant-fifo&quot;;
+    uzbl.comm.socket_path = &quot;/tmp/some-nonexistant-socket&quot;;
+    uzbl.state.uri = &quot;http://example.org/&quot;;
+    uzbl.gui.main_title = &quot;Example.Org&quot;;
+
     uzbl.state.instance_name = INSTANCE_NAME;
     uzbl.behave.shell_cmd = &quot;sh -c&quot;;
 </diff>
      <filename>tests/test-command.c</filename>
    </modified>
    <modified>
      <diff>@@ -103,9 +103,9 @@ const struct var_name_to_ptr_t {
     { &quot;load_start_handler&quot;,     PTR_V_STR(uzbl.behave.load_start_handler,       1,   NULL)},
     { &quot;load_commit_handler&quot;,    PTR_V_STR(uzbl.behave.load_commit_handler,      1,   NULL)},
     { &quot;download_handler&quot;,       PTR_V_STR(uzbl.behave.download_handler,         1,   NULL)},
-    { &quot;cookie_handler&quot;,         PTR_V_STR(uzbl.behave.cookie_handler,           1,   cmd_cookie_handler)},
+    { &quot;cookie_handler&quot;,         PTR_V_STR(uzbl.behave.cookie_handler,           1,   NULL)},
     { &quot;new_window&quot;,             PTR_V_STR(uzbl.behave.new_window,               1,   NULL)},
-    { &quot;scheme_handler&quot;,         PTR_V_STR(uzbl.behave.scheme_handler,           1,   cmd_scheme_handler)},
+    { &quot;scheme_handler&quot;,         PTR_V_STR(uzbl.behave.scheme_handler,           1,   NULL)},
     { &quot;fifo_dir&quot;,               PTR_V_STR(uzbl.behave.fifo_dir,                 1,   cmd_fifo_dir)},
     { &quot;socket_dir&quot;,             PTR_V_STR(uzbl.behave.socket_dir,               1,   cmd_socket_dir)},
     { &quot;http_debug&quot;,             PTR_V_INT(uzbl.behave.http_debug,               1,   cmd_http_debug)},
@@ -2058,10 +2058,15 @@ run_handler (const gchar *act, const gchar *args) {
         g_strfreev(chainparts);
 
     } else {
-        gchar **inparts = inject_handler_args(parts[0], parts[1], args);
+        /* expand the user-specified arguments */
+        gchar* expanded = expand(parts[1], 0);
+        gchar **inparts = inject_handler_args(parts[0], expanded, args);
+
         parse_command(inparts[0], inparts[1], NULL);
+
         g_free(inparts[0]);
         g_free(inparts[1]);
+        g_free(expanded);
     }
     g_strfreev(parts);
 }</diff>
      <filename>uzbl-core.c</filename>
    </modified>
  </modified>
  <removed type="array"/>
  <parents type="array">
    <parent>
      <id>ff952dd40fc7cef8e2c31f08b4a6ff56589fe999</id>
    </parent>
    <parent>
      <id>1c28354f0e6e54395f494a79b4a43285f0dfa71f</id>
    </parent>
  </parents>
  <author>
    <name>Robert Manea</name>
    <email>gotmor@gmail.com</email>
  </author>
  <url>http://github.com/bct/uzbl/commit/4f177df009acadaeadfb273c411c4d78dc46128a</url>
  <id>4f177df009acadaeadfb273c411c4d78dc46128a</id>
  <committed-date>2009-10-25T15:09:38-07:00</committed-date>
  <authored-date>2009-10-25T15:09:38-07:00</authored-date>
  <message>Merge branch 'master' of git://github.com/bct/uzbl into experimental</message>
  <tree>fdd08e96ea0de3228a406407e1cc51ed7b125fb6</tree>
  <committer>
    <name>Robert Manea</name>
    <email>gotmor@gmail.com</email>
  </committer>
</commit>
