Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(141)

Unified Diff: Source/WebKit/chromium/tests/WebFrameTest.cpp

Issue 19275006: Fix a use-after-free in spellcheck client (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 7 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: Source/WebKit/chromium/tests/WebFrameTest.cpp
diff --git a/Source/WebKit/chromium/tests/WebFrameTest.cpp b/Source/WebKit/chromium/tests/WebFrameTest.cpp
index ac3158719c1ed8d1d615e058ac22feeb6a5ca04e..8c70c4b7928a843ffd35db37d03135f0b52d72ab 100644
--- a/Source/WebKit/chromium/tests/WebFrameTest.cpp
+++ b/Source/WebKit/chromium/tests/WebFrameTest.cpp
@@ -59,7 +59,9 @@
#include "core/dom/DocumentMarkerController.h"
#include "core/dom/MouseEvent.h"
#include "core/dom/Range.h"
+#include "core/editing/Editor.h"
#include "core/editing/FrameSelection.h"
+#include "core/editing/SpellChecker.h"
#include "core/html/HTMLFormElement.h"
#include "core/loader/FrameLoadRequest.h"
#include "core/page/EventHandler.h"
@@ -3162,6 +3164,30 @@ TEST_F(WebFrameTest, SlowSpellcheckMarkerPosition)
m_webView = 0;
}
+// This test verifies that cancelling spelling request does not cause a
+// write-after-free when there's no spellcheck client set.
+TEST_F(WebFrameTest, CancelSpellingRequestCrash)
+{
+ registerMockedHttpURLLoad("spell.html");
+ m_webView = FrameTestHelpers::createWebViewAndLoad(m_baseURL + "spell.html");
+ m_webView->setSpellCheckClient(0);
+
+ WebFrameImpl* frame = static_cast<WebFrameImpl*>(m_webView->mainFrame());
+ Document* document = frame->frame()->document();
+ Element* element = document->getElementById("data");
+
+ m_webView->settings()->setAsynchronousSpellCheckingEnabled(true);
+ m_webView->settings()->setUnifiedTextCheckerEnabled(true);
+ m_webView->settings()->setEditingBehavior(WebSettings::EditingBehaviorWin);
+
+ element->focus();
+ frame->frame()->editor()->replaceSelectionWithText("A", false, false);
+ frame->frame()->editor()->spellChecker()->cancelCheck();
+
+ m_webView->close();
+ m_webView = 0;
+}
+
class TestAccessInitialDocumentWebFrameClient : public WebFrameClient {
public:
TestAccessInitialDocumentWebFrameClient() : m_didAccessInitialDocument(false)

Powered by Google App Engine
This is Rietveld 408576698