Changeset 41340 in webkit


Ignore:
Timestamp:
Mar 1, 2009 11:21:48 AM (15 years ago)
Author:
jmalonzo@webkit.org
Message:

2009-03-01 Jan Michael Alonzo <jmalonzo@webkit.org>

Reviewed by Holger Freyther.

[Gtk] get the HTTP layout tests going
https://bugs.webkit.org/show_bug.cgi?id=24259

Implement dumping of WebKitWebBackForwardList and its history
items.

  • DumpRenderTree/gtk/DumpRenderTree.cpp: (compareHistoryItems): (dumpHistoryItem): (dumpBackForwardListForWebView): (dump): (runTest):
  • DumpRenderTree/gtk/LayoutTestControllerGtk.cpp: (LayoutTestController::clearBackForwardList):
  • DumpRenderTree/gtk/WorkQueueItemGtk.cpp: (BackForwardItem::invoke):
Location:
trunk/WebKitTools
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/WebKitTools/ChangeLog

    r41336 r41340  
     12009-03-01  Jan Michael Alonzo  <jmalonzo@webkit.org>
     2
     3        Reviewed by Holger Freyther.
     4
     5        [Gtk] get the HTTP layout tests going
     6        https://bugs.webkit.org/show_bug.cgi?id=24259
     7
     8         Implement dumping of WebKitWebBackForwardList and its history
     9         items.
     10
     11        * DumpRenderTree/gtk/DumpRenderTree.cpp:
     12        (compareHistoryItems):
     13        (dumpHistoryItem):
     14        (dumpBackForwardListForWebView):
     15        (dump):
     16        (runTest):
     17        * DumpRenderTree/gtk/LayoutTestControllerGtk.cpp:
     18        (LayoutTestController::clearBackForwardList):
     19        * DumpRenderTree/gtk/WorkQueueItemGtk.cpp:
     20        (BackForwardItem::invoke):
     21
    1222009-02-28  Zan Dobersek  <zandobersek@gmail.com>
    223
  • trunk/WebKitTools/DumpRenderTree/gtk/DumpRenderTree.cpp

    r41336 r41340  
    22 * Copyright (C) 2007 Eric Seidel <eric@webkit.org>
    33 * Copyright (C) 2008 Alp Toker <alp@nuanti.com>
     4 * Copyright (C) 2009 Jan Alonzo <jmalonzo@gmail.com>
    45 *
    56 * Redistribution and use in source and binary forms, with or without
     
    5051extern "C" {
    5152// This API is not yet public.
     53extern G_CONST_RETURN gchar* webkit_web_history_item_get_target(WebKitWebHistoryItem*);
     54extern gboolean webkit_web_history_item_is_target_item(WebKitWebHistoryItem*);
     55extern GList* webkit_web_history_item_get_children(WebKitWebHistoryItem*);
    5256extern GSList* webkit_web_frame_get_children(WebKitWebFrame* frame);
    5357extern gchar* webkit_web_frame_get_inner_text(WebKitWebFrame* frame);
     
    6771guint waitToDumpWatchdog = 0;
    6872
     73// current b/f item at the end of the previous test
     74static WebKitWebHistoryItem* prevTestBFItem = NULL;
     75
    6976const unsigned maxViewHeight = 600;
    7077const unsigned maxViewWidth = 800;
     78const unsigned historyItemIndent = 8;
    7179
    7280static gchar* autocorrectURL(const gchar* url)
     
    127135
    128136    return result;
     137}
     138
     139static gint compareHistoryItems(gpointer* item1, gpointer* item2)
     140{
     141    return g_ascii_strcasecmp(webkit_web_history_item_get_target(WEBKIT_WEB_HISTORY_ITEM(item1)),
     142                              webkit_web_history_item_get_target(WEBKIT_WEB_HISTORY_ITEM(item2)));
     143}
     144
     145static void dumpHistoryItem(WebKitWebHistoryItem* item, int indent, bool current)
     146{
     147    ASSERT(item != NULL);
     148    int start = 0;
     149    g_object_ref(item);
     150    if (current) {
     151        printf("curr->");
     152        start = 6;
     153    }
     154    for (int i = start; i < indent; i++)
     155        putchar(' ');
     156    printf("%s", webkit_web_history_item_get_uri(item));
     157    const gchar* target = webkit_web_history_item_get_target(item);
     158    if (target && g_utf8_strlen(target, 0) > 0)
     159        printf(" (in frame \"%s\")", target);
     160    if (webkit_web_history_item_is_target_item(item))
     161        printf("  **nav target**");
     162    putchar('\n');
     163    GList* kids = webkit_web_history_item_get_children(item);
     164    if (kids) {
     165        // must sort to eliminate arbitrary result ordering which defeats reproducible testing
     166        kids = g_list_sort(kids, (GCompareFunc) compareHistoryItems);
     167        for (unsigned i = 0; i < g_list_length(kids); i++)
     168            dumpHistoryItem(WEBKIT_WEB_HISTORY_ITEM(g_list_nth_data(kids, i)), indent+4, FALSE);
     169    }
     170    g_object_unref(item);
     171}
     172
     173static void dumpBackForwardListForWebView(WebKitWebView* view)
     174{
     175    printf("\n============== Back Forward List ==============\n");
     176    WebKitWebBackForwardList* bfList = webkit_web_view_get_back_forward_list(view);
     177
     178    // Print out all items in the list after prevTestBFItem, which was from the previous test
     179    // Gather items from the end of the list, the print them out from oldest to newest
     180    GList* itemsToPrint = NULL;
     181    gint forwardListCount = webkit_web_back_forward_list_get_forward_length(bfList);
     182    for (int i = forwardListCount; i > 0; i--) {
     183        WebKitWebHistoryItem* item = webkit_web_back_forward_list_get_nth_item(bfList, i);
     184        // something is wrong if the item from the last test is in the forward part of the b/f list
     185        ASSERT(item != prevTestBFItem);
     186        g_object_ref(item);
     187        itemsToPrint = g_list_append(itemsToPrint, item);
     188    }
     189
     190    WebKitWebHistoryItem* currentItem = webkit_web_back_forward_list_get_current_item(bfList);
     191
     192    g_object_ref(currentItem);
     193    itemsToPrint = g_list_append(itemsToPrint, currentItem);
     194
     195    gint backListCount = webkit_web_back_forward_list_get_back_length(bfList);
     196    for (int i = -1; i >= -(backListCount); i--) {
     197        WebKitWebHistoryItem* item = webkit_web_back_forward_list_get_nth_item(bfList, i);
     198        if (item == prevTestBFItem)
     199            break;
     200        g_object_ref(item);
     201        itemsToPrint = g_list_append(itemsToPrint, item);
     202    }
     203
     204    gint currentItemIndex = g_list_length(itemsToPrint) - 1;
     205    for (int i = currentItemIndex; i >= 0; i--) {
     206        WebKitWebHistoryItem* item = WEBKIT_WEB_HISTORY_ITEM(g_list_nth_data(itemsToPrint, i));
     207        dumpHistoryItem(item, historyItemIndent, i == currentItemIndex);
     208        g_object_unref(item);
     209    }
     210    g_list_free(itemsToPrint);
     211    printf("===============================================\n");
    129212}
    130213
     
    167250            if (!gLayoutTestController->dumpAsText() && !gLayoutTestController->dumpDOMAsWebArchive() && !gLayoutTestController->dumpSourceAsWebArchive())
    168251                dumpFrameScrollPosition(mainFrame);
    169         }
    170 
    171         if (gLayoutTestController->dumpBackForwardList()) {
    172             // FIXME: not implemented
     252
     253            if (gLayoutTestController->dumpBackForwardList()) {
     254                // FIXME: multiple windows support
     255                dumpBackForwardListForWebView(webView);
     256
     257            }
    173258        }
    174259
     
    250335    gtk_widget_size_allocate(GTK_WIDGET(webView), &size);
    251336
     337    if (prevTestBFItem)
     338        g_object_unref(prevTestBFItem);
     339    WebKitWebBackForwardList* bfList = webkit_web_view_get_back_forward_list(webView);
     340    prevTestBFItem = webkit_web_back_forward_list_get_current_item(bfList);
     341    if (prevTestBFItem)
     342        g_object_ref(prevTestBFItem);
     343
     344
    252345    webkit_web_view_open(webView, url);
    253346
  • trunk/WebKitTools/DumpRenderTree/gtk/LayoutTestControllerGtk.cpp

    r41283 r41340  
    7070    webkit_web_back_forward_list_set_limit(list, 0);
    7171    webkit_web_back_forward_list_set_limit(list, limit);
    72     // FIXME: implement add_item()
    73     //webkit_web_back_forward_list_add_item(list, item);
     72    webkit_web_back_forward_list_add_item(list, item);
    7473    webkit_web_back_forward_list_go_to_item(list, item);
    7574    g_object_unref(item);
  • trunk/WebKitTools/DumpRenderTree/gtk/WorkQueueItemGtk.cpp

    r37587 r41340  
    7171{
    7272    WebKitWebView* webView = webkit_web_frame_get_web_view(mainFrame);
    73     webkit_web_view_go_back_or_forward(webView, m_howFar);
     73    if (m_howFar == 1)
     74        webkit_web_view_go_forward(webView);
     75    else if (m_howFar == -1)
     76        webkit_web_view_go_back(webView);
     77    else {
     78        WebKitWebBackForwardList* webBackForwardList = webkit_web_view_get_back_forward_list(webView);
     79        WebKitWebHistoryItem* item = webkit_web_back_forward_list_get_nth_item(webBackForwardList, m_howFar);
     80        webkit_web_view_go_to_back_forward_item(webView, item);
     81    }
    7482}
Note: See TracChangeset for help on using the changeset viewer.