Changeset 93692 in webkit


Ignore:
Timestamp:
Aug 23, 2011 9:32:42 PM (13 years ago)
Author:
abarth@webkit.org
Message:

WebSearchableFormData crashes when given a detached HTMLFormElement
https://bugs.webkit.org/show_bug.cgi?id=66831

Reviewed by Dimitri Glazkov.

We need to null-check the Frame.

  • src/WebSearchableFormData.cpp:

(HTMLNames::GetFormEncoding):

  • tests/WebFrameTest.cpp:

(WebKit::TEST_F):

  • tests/data/form.html: Added.
Location:
trunk/Source/WebKit/chromium
Files:
1 added
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebKit/chromium/ChangeLog

    r93689 r93692  
     12011-08-23  Adam Barth  <abarth@webkit.org>
     2
     3        WebSearchableFormData crashes when given a detached HTMLFormElement
     4        https://bugs.webkit.org/show_bug.cgi?id=66831
     5
     6        Reviewed by Dimitri Glazkov.
     7
     8        We need to null-check the Frame.
     9
     10        * src/WebSearchableFormData.cpp:
     11        (HTMLNames::GetFormEncoding):
     12        * tests/WebFrameTest.cpp:
     13        (WebKit::TEST_F):
     14        * tests/data/form.html: Added.
     15
    1162011-08-23  Iain Merrick  <husky@google.com>
    217
  • trunk/Source/WebKit/chromium/src/WebSearchableFormData.cpp

    r91404 r93692  
    6565            return;
    6666    }
     67    if (!form->document()->frame())
     68         return;
    6769    *encoding = TextEncoding(form->document()->loader()->writer()->encoding());
    6870}
  • trunk/Source/WebKit/chromium/tests/WebFrameTest.cpp

    r83366 r93692  
    3131#include "config.h"
    3232
    33 #include <googleurl/src/gurl.h>
    34 #include <gtest/gtest.h>
    35 #include <webkit/support/webkit_support.h>
     33#include "WebDocument.h"
     34#include "WebFormElement.h"
    3635#include "WebFrame.h"
    3736#include "WebFrameClient.h"
     37#include "WebSearchableFormData.h"
    3838#include "WebSettings.h"
    3939#include "WebString.h"
     
    4343#include "WebView.h"
    4444#include "v8.h"
     45#include <googleurl/src/gurl.h>
     46#include <gtest/gtest.h>
     47#include <webkit/support/webkit_support.h>
    4548
    4649using namespace WebKit;
     
    146149}
    147150
     151TEST_F(WebFrameTest, FormWithNullFrame)
     152{
     153    registerMockedURLLoad("form.html");
     154
     155    TestWebFrameClient webFrameClient;
     156    WebView* webView = WebView::create(0);
     157    webView->initializeMainFrame(&webFrameClient);
     158
     159    loadFrame(webView->mainFrame(), "form.html");
     160    serveRequests();
     161
     162    WebVector<WebFormElement> forms;
     163    webView->mainFrame()->document().forms(forms);
     164    webView->close();
     165
     166    EXPECT_EQ(forms.size(), 1U);
     167
     168    // This test passes if this doesn't crash.
     169    WebSearchableFormData searchableDataForm(forms[0]);
    148170}
     171
     172}
Note: See TracChangeset for help on using the changeset viewer.