<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[178703] trunk</title>
</head>
<body>

<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt;  }
#msg dl a { font-weight: bold}
#msg dl a:link    { color:#fc3; }
#msg dl a:active  { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff  {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta">
<dt>Revision</dt> <dd><a href="http://trac.webkit.org/projects/webkit/changeset/178703">178703</a></dd>
<dt>Author</dt> <dd>commit-queue@webkit.org</dd>
<dt>Date</dt> <dd>2015-01-20 03:22:03 -0800 (Tue, 20 Jan 2015)</dd>
</dl>

<h3>Log Message</h3>
<pre>[GTK] Add API to set the web view editable into WebKit2 GTK+ API
https://bugs.webkit.org/show_bug.cgi?id=139443

Patch by Tomas Popela &lt;tpopela@redhat.com&gt; on 2015-01-20
Reviewed by Carlos Garcia Campos.

Source/WebKit2:

Provide a way to set the web view editable, without accessing the DOM
and setting the contenteditable attribute to elements.

* UIProcess/API/gtk/WebKitWebView.cpp:
(webkitWebViewSetProperty):
(webkitWebViewGetProperty):
(webkit_web_view_class_init):
(webkit_web_view_is_editable):
(webkit_web_view_set_editable):
* UIProcess/API/gtk/WebKitWebView.h:
* UIProcess/API/gtk/docs/webkit2gtk-sections.txt:

Tools:

Create the new test cases for setting the editable property on the web
view and on the contenteditable enabled document. Also rework the
current tests that are expecting that the web view is editable.

* TestWebKitAPI/Tests/WebKit2Gtk/TestWebViewEditor.cpp:
(loadTestHtml):
(testWebViewEditorCutCopyPasteNonEditable):
(testWebViewEditorCutCopyPasteEditable):
(testWebViewEditorSelectAllNonEditable):
(testWebViewEditorSelectAllEditable):
(runEditorEditableCutTests):
(testWebViewEditorEditableOnNonEditable):
(testWebViewEditorEditableOnContentEditable):
(testWebViewEditorNonEditable):
(beforeAll):
* TestWebKitAPI/gtk/WebKit2Gtk/WebViewTest.cpp:
(WebViewTest::isEditable):
(WebViewTest::setEditable):</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkSourceWebKit2ChangeLog">trunk/Source/WebKit2/ChangeLog</a></li>
<li><a href="#trunkSourceWebKit2UIProcessAPIgtkWebKitWebViewcpp">trunk/Source/WebKit2/UIProcess/API/gtk/WebKitWebView.cpp</a></li>
<li><a href="#trunkSourceWebKit2UIProcessAPIgtkWebKitWebViewh">trunk/Source/WebKit2/UIProcess/API/gtk/WebKitWebView.h</a></li>
<li><a href="#trunkSourceWebKit2UIProcessAPIgtkdocswebkit2gtksectionstxt">trunk/Source/WebKit2/UIProcess/API/gtk/docs/webkit2gtk-sections.txt</a></li>
<li><a href="#trunkToolsChangeLog">trunk/Tools/ChangeLog</a></li>
<li><a href="#trunkToolsTestWebKitAPITestsWebKit2GtkTestWebViewEditorcpp">trunk/Tools/TestWebKitAPI/Tests/WebKit2Gtk/TestWebViewEditor.cpp</a></li>
<li><a href="#trunkToolsTestWebKitAPIgtkWebKit2GtkWebViewTestcpp">trunk/Tools/TestWebKitAPI/gtk/WebKit2Gtk/WebViewTest.cpp</a></li>
<li><a href="#trunkToolsTestWebKitAPIgtkWebKit2GtkWebViewTesth">trunk/Tools/TestWebKitAPI/gtk/WebKit2Gtk/WebViewTest.h</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkSourceWebKit2ChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/ChangeLog (178702 => 178703)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/ChangeLog        2015-01-20 10:07:21 UTC (rev 178702)
+++ trunk/Source/WebKit2/ChangeLog        2015-01-20 11:22:03 UTC (rev 178703)
</span><span class="lines">@@ -1,3 +1,22 @@
</span><ins>+2015-01-20  Tomas Popela  &lt;tpopela@redhat.com&gt;
+
+        [GTK] Add API to set the web view editable into WebKit2 GTK+ API
+        https://bugs.webkit.org/show_bug.cgi?id=139443
+
+        Reviewed by Carlos Garcia Campos.
+
+        Provide a way to set the web view editable, without accessing the DOM
+        and setting the contenteditable attribute to elements.
+
+        * UIProcess/API/gtk/WebKitWebView.cpp:
+        (webkitWebViewSetProperty):
+        (webkitWebViewGetProperty):
+        (webkit_web_view_class_init):
+        (webkit_web_view_is_editable):
+        (webkit_web_view_set_editable):
+        * UIProcess/API/gtk/WebKitWebView.h:
+        * UIProcess/API/gtk/docs/webkit2gtk-sections.txt:
+
</ins><span class="cx"> 2015-01-20  Carlos Garcia Campos  &lt;cgarcia@igalia.com&gt;
</span><span class="cx"> 
</span><span class="cx">         [GTK] Add an option to create WebKitWebView snapshots with transparent background
</span></span></pre></div>
<a id="trunkSourceWebKit2UIProcessAPIgtkWebKitWebViewcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/UIProcess/API/gtk/WebKitWebView.cpp (178702 => 178703)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/API/gtk/WebKitWebView.cpp        2015-01-20 10:07:21 UTC (rev 178702)
+++ trunk/Source/WebKit2/UIProcess/API/gtk/WebKitWebView.cpp        2015-01-20 11:22:03 UTC (rev 178703)
</span><span class="lines">@@ -149,7 +149,8 @@
</span><span class="cx">     PROP_URI,
</span><span class="cx">     PROP_ZOOM_LEVEL,
</span><span class="cx">     PROP_IS_LOADING,
</span><del>-    PROP_IS_PLAYING_AUDIO
</del><ins>+    PROP_IS_PLAYING_AUDIO,
+    PROP_EDITABLE
</ins><span class="cx"> };
</span><span class="cx"> 
</span><span class="cx"> typedef HashMap&lt;uint64_t, GRefPtr&lt;WebKitWebResource&gt; &gt; LoadingResourcesMap;
</span><span class="lines">@@ -688,6 +689,9 @@
</span><span class="cx">     case PROP_ZOOM_LEVEL:
</span><span class="cx">         webkit_web_view_set_zoom_level(webView, g_value_get_double(value));
</span><span class="cx">         break;
</span><ins>+    case PROP_EDITABLE:
+        webkit_web_view_set_editable(webView, g_value_get_boolean(value));
+        break;
</ins><span class="cx">     default:
</span><span class="cx">         G_OBJECT_WARN_INVALID_PROPERTY_ID(object, propId, paramSpec);
</span><span class="cx">     }
</span><span class="lines">@@ -728,6 +732,9 @@
</span><span class="cx">     case PROP_IS_PLAYING_AUDIO:
</span><span class="cx">         g_value_set_boolean(value, webkit_web_view_is_playing_audio(webView));
</span><span class="cx">         break;
</span><ins>+    case PROP_EDITABLE:
+        g_value_set_boolean(value, webkit_web_view_is_editable(webView));
+        break;
</ins><span class="cx">     default:
</span><span class="cx">         G_OBJECT_WARN_INVALID_PROPERTY_ID(object, propId, paramSpec);
</span><span class="cx">     }
</span><span class="lines">@@ -959,6 +966,24 @@
</span><span class="cx">             WEBKIT_PARAM_READABLE));
</span><span class="cx"> 
</span><span class="cx">     /**
</span><ins>+     * WebKitWebView:editable:
+     *
+     * Whether the pages loaded inside #WebKitWebView are editable. For more
+     * information see webkit_web_view_set_editable().
+     *
+     * Since: 2.8
+     */
+    g_object_class_install_property(
+        gObjectClass,
+        PROP_EDITABLE,
+        g_param_spec_boolean(
+            &quot;editable&quot;,
+            _(&quot;Editable&quot;),
+            _(&quot;Whether the content can be modified by the user.&quot;),
+            FALSE,
+            WEBKIT_PARAM_READWRITE));
+
+    /**
</ins><span class="cx">      * WebKitWebView::load-changed:
</span><span class="cx">      * @web_view: the #WebKitWebView on which the signal is emitted
</span><span class="cx">      * @load_event: the #WebKitLoadEvent
</span><span class="lines">@@ -3573,3 +3598,53 @@
</span><span class="cx"> 
</span><span class="cx">     *rgba = getPage(webView)-&gt;backgroundColor();
</span><span class="cx"> }
</span><ins>+
+/*
+ * webkit_web_view_is_editable:
+ * @web_view: a #WebKitWebView
+ *
+ * Gets whether the user is allowed to edit the HTML document. When @web_view
+ * is not editable an element in the HTML document can only be edited if the
+ * CONTENTEDITABLE attribute has been set on the element or one of its parent
+ * elements. By default a #WebKitWebView is not editable.
+ *
+ * Returns: %TRUE if the user is allowed to edit the HTML document, or %FALSE otherwise.
+ *
+ * Since: 2.8
+ */
+gboolean webkit_web_view_is_editable(WebKitWebView* webView)
+{
+    g_return_val_if_fail(WEBKIT_IS_WEB_VIEW(webView), FALSE);
+
+    return getPage(webView)-&gt;isEditable();
+}
+
+/**
+ * webkit_web_view_set_editable:
+ * @web_view: a #WebKitWebView
+ * @editable: a #gboolean indicating the editable state
+ *
+ * Sets whether the user is allowed to edit the HTML document.
+ *
+ * If @editable is %TRUE, @web_view allows the user to edit the HTML document. If
+ * @editable is %FALSE, an element in @web_view's document can only be edited if the
+ * CONTENTEDITABLE attribute has been set on the element or one of its parent
+ * elements. By default a #WebKitWebView is not editable.
+ *
+ * Normally, a HTML document is not editable unless the elements within the
+ * document are editable. This function provides a way to make the contents
+ * of a #WebKitWebView editable without altering the document or DOM structure.
+ *
+ * Since: 2.8
+ */
+void webkit_web_view_set_editable(WebKitWebView* webView, gboolean editable)
+{
+    g_return_if_fail(WEBKIT_IS_WEB_VIEW(webView));
+
+    if (editable == getPage(webView)-&gt;isEditable())
+        return;
+
+    getPage(webView)-&gt;setEditable(editable);
+
+    g_object_notify(G_OBJECT(webView), &quot;editable&quot;);
+}
</ins></span></pre></div>
<a id="trunkSourceWebKit2UIProcessAPIgtkWebKitWebViewh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/UIProcess/API/gtk/WebKitWebView.h (178702 => 178703)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/API/gtk/WebKitWebView.h        2015-01-20 10:07:21 UTC (rev 178702)
+++ trunk/Source/WebKit2/UIProcess/API/gtk/WebKitWebView.h        2015-01-20 11:22:03 UTC (rev 178703)
</span><span class="lines">@@ -485,6 +485,13 @@
</span><span class="cx"> webkit_web_view_get_background_color                 (WebKitWebView             *web_view,
</span><span class="cx">                                                       GdkRGBA                   *rgba);
</span><span class="cx"> 
</span><ins>+WEBKIT_API gboolean
+webkit_web_view_is_editable                          (WebKitWebView             *web_view);
+
+WEBKIT_API void
+webkit_web_view_set_editable                         (WebKitWebView             *web_view,
+                                                      gboolean                  editable);
+
</ins><span class="cx"> G_END_DECLS
</span><span class="cx"> 
</span><span class="cx"> #endif
</span></span></pre></div>
<a id="trunkSourceWebKit2UIProcessAPIgtkdocswebkit2gtksectionstxt"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/UIProcess/API/gtk/docs/webkit2gtk-sections.txt (178702 => 178703)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/API/gtk/docs/webkit2gtk-sections.txt        2015-01-20 10:07:21 UTC (rev 178702)
+++ trunk/Source/WebKit2/UIProcess/API/gtk/docs/webkit2gtk-sections.txt        2015-01-20 11:22:03 UTC (rev 178703)
</span><span class="lines">@@ -201,6 +201,8 @@
</span><span class="cx"> webkit_web_view_get_snapshot_finish
</span><span class="cx"> webkit_web_view_set_background_color
</span><span class="cx"> webkit_web_view_get_background_color
</span><ins>+webkit_web_view_set_editable
+webkit_web_view_is_editable
</ins><span class="cx"> 
</span><span class="cx"> &lt;SUBSECTION WebKitJavascriptResult&gt;
</span><span class="cx"> WebKitJavascriptResult
</span></span></pre></div>
<a id="trunkToolsChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Tools/ChangeLog (178702 => 178703)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Tools/ChangeLog        2015-01-20 10:07:21 UTC (rev 178702)
+++ trunk/Tools/ChangeLog        2015-01-20 11:22:03 UTC (rev 178703)
</span><span class="lines">@@ -1,3 +1,29 @@
</span><ins>+2015-01-20  Tomas Popela  &lt;tpopela@redhat.com&gt;
+
+        [GTK] Add API to set the web view editable into WebKit2 GTK+ API
+        https://bugs.webkit.org/show_bug.cgi?id=139443
+
+        Reviewed by Carlos Garcia Campos.
+
+        Create the new test cases for setting the editable property on the web
+        view and on the contenteditable enabled document. Also rework the
+        current tests that are expecting that the web view is editable.
+
+        * TestWebKitAPI/Tests/WebKit2Gtk/TestWebViewEditor.cpp:
+        (loadTestHtml):
+        (testWebViewEditorCutCopyPasteNonEditable):
+        (testWebViewEditorCutCopyPasteEditable):
+        (testWebViewEditorSelectAllNonEditable):
+        (testWebViewEditorSelectAllEditable):
+        (runEditorEditableCutTests):
+        (testWebViewEditorEditableOnNonEditable):
+        (testWebViewEditorEditableOnContentEditable):
+        (testWebViewEditorNonEditable):
+        (beforeAll):
+        * TestWebKitAPI/gtk/WebKit2Gtk/WebViewTest.cpp:
+        (WebViewTest::isEditable):
+        (WebViewTest::setEditable):
+
</ins><span class="cx"> 2015-01-20  Carlos Garcia Campos  &lt;cgarcia@igalia.com&gt;
</span><span class="cx"> 
</span><span class="cx">         [GTK] Add an option to create WebKitWebView snapshots with transparent background
</span></span></pre></div>
<a id="trunkToolsTestWebKitAPITestsWebKit2GtkTestWebViewEditorcpp"></a>
<div class="modfile"><h4>Modified: trunk/Tools/TestWebKitAPI/Tests/WebKit2Gtk/TestWebViewEditor.cpp (178702 => 178703)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Tools/TestWebKitAPI/Tests/WebKit2Gtk/TestWebViewEditor.cpp        2015-01-20 10:07:21 UTC (rev 178702)
+++ trunk/Tools/TestWebKitAPI/Tests/WebKit2Gtk/TestWebViewEditor.cpp        2015-01-20 11:22:03 UTC (rev 178703)
</span><span class="lines">@@ -73,25 +73,42 @@
</span><span class="cx">         g_main_loop_run(m_mainLoop);
</span><span class="cx">     }
</span><span class="cx"> 
</span><ins>+    gchar* cutSelection()
+    {
+        g_assert(canExecuteEditingCommand(WEBKIT_EDITING_COMMAND_CUT));
+        g_assert(canExecuteEditingCommand(WEBKIT_EDITING_COMMAND_PASTE));
+
+        webkit_web_view_execute_editing_command(m_webView, WEBKIT_EDITING_COMMAND_CUT);
+        // There's no way to know when the selection has been cut to
+        // the clipboard, so use a timeout source to query the clipboard.
+        m_triesCount = 0;
+        g_timeout_add(kClipboardWaitTimeout, reinterpret_cast&lt;GSourceFunc&gt;(waitForClipboardText), this);
+        g_main_loop_run(m_mainLoop);
+
+        return gtk_clipboard_wait_for_text (m_clipboard);
+    }
+
</ins><span class="cx">     GtkClipboard* m_clipboard;
</span><span class="cx">     bool m_canExecuteEditingCommand;
</span><span class="cx">     size_t m_triesCount;
</span><span class="cx"> };
</span><span class="cx"> 
</span><ins>+static const char* selectedSpanHTMLFormat =
+    &quot;&lt;html&gt;&lt;body contentEditable=\&quot;%s\&quot;&gt;&quot;
+    &quot;&lt;span id=\&quot;mainspan\&quot;&gt;All work and no play &lt;span id=\&quot;subspan\&quot;&gt;make Jack a dull&lt;/span&gt; boy.&lt;/span&gt;&quot;
+    &quot;&lt;script&gt;document.getSelection().collapse();\n&quot;
+    &quot;document.getSelection().selectAllChildren(document.getElementById('subspan'));\n&quot;
+    &quot;&lt;/script&gt;&lt;/body&gt;&lt;/html&gt;&quot;;
+
</ins><span class="cx"> static void testWebViewEditorCutCopyPasteNonEditable(EditorTest* test, gconstpointer)
</span><span class="cx"> {
</span><del>-    static const char* selectedSpanHTML = &quot;&lt;html&gt;&lt;body contentEditable=\&quot;false\&quot;&gt;&quot;
-        &quot;&lt;span id=\&quot;mainspan\&quot;&gt;All work and no play &lt;span id=\&quot;subspan\&quot;&gt;make Jack a dull&lt;/span&gt; boy.&lt;/span&gt;&quot;
-        &quot;&lt;script&gt;document.getSelection().collapse();\n&quot;
-        &quot;document.getSelection().selectAllChildren(document.getElementById('subspan'));\n&quot;
-        &quot;&lt;/script&gt;&lt;/body&gt;&lt;/html&gt;&quot;;
-
</del><span class="cx">     // Nothing loaded yet.
</span><span class="cx">     g_assert(!test-&gt;canExecuteEditingCommand(WEBKIT_EDITING_COMMAND_CUT));
</span><span class="cx">     g_assert(!test-&gt;canExecuteEditingCommand(WEBKIT_EDITING_COMMAND_COPY));
</span><span class="cx">     g_assert(!test-&gt;canExecuteEditingCommand(WEBKIT_EDITING_COMMAND_PASTE));
</span><span class="cx"> 
</span><del>-    test-&gt;loadHtml(selectedSpanHTML, 0);
</del><ins>+    GUniquePtr&lt;char&gt; selectedSpanHTML(g_strdup_printf(selectedSpanHTMLFormat, &quot;false&quot;));
+    test-&gt;loadHtml(selectedSpanHTML.get(), nullptr);
</ins><span class="cx">     test-&gt;waitUntilLoadFinished();
</span><span class="cx"> 
</span><span class="cx">     g_assert(test-&gt;canExecuteEditingCommand(WEBKIT_EDITING_COMMAND_COPY));
</span><span class="lines">@@ -107,18 +124,17 @@
</span><span class="cx"> 
</span><span class="cx"> static void testWebViewEditorCutCopyPasteEditable(EditorTest* test, gconstpointer)
</span><span class="cx"> {
</span><del>-    static const char* selectedSpanHTML = &quot;&lt;html&gt;&lt;body contentEditable=\&quot;true\&quot;&gt;&quot;
-        &quot;&lt;span id=\&quot;mainspan\&quot;&gt;All work and no play &lt;span&gt;make Jack a dull&lt;/span&gt; boy.&lt;/span&gt;&quot;
-        &quot;&lt;script&gt;document.getSelection().collapse();\n&quot;
-        &quot;document.getSelection().selectAllChildren(document.getElementById('mainspan'));\n&quot;
-        &quot;&lt;/script&gt;&lt;/body&gt;&lt;/html&gt;&quot;;
-
</del><span class="cx">     // Nothing loaded yet.
</span><span class="cx">     g_assert(!test-&gt;canExecuteEditingCommand(WEBKIT_EDITING_COMMAND_CUT));
</span><span class="cx">     g_assert(!test-&gt;canExecuteEditingCommand(WEBKIT_EDITING_COMMAND_COPY));
</span><span class="cx">     g_assert(!test-&gt;canExecuteEditingCommand(WEBKIT_EDITING_COMMAND_PASTE));
</span><span class="cx"> 
</span><del>-    test-&gt;loadHtml(selectedSpanHTML, 0);
</del><ins>+    g_assert(!test-&gt;isEditable());
+    test-&gt;setEditable(true);
+    g_assert(test-&gt;isEditable());
+
+    GUniquePtr&lt;char&gt; selectedSpanHTML(g_strdup_printf(selectedSpanHTMLFormat, &quot;false&quot;));
+    test-&gt;loadHtml(selectedSpanHTML.get(), nullptr);
</ins><span class="cx">     test-&gt;waitUntilLoadFinished();
</span><span class="cx"> 
</span><span class="cx">     // There's a selection.
</span><span class="lines">@@ -128,20 +144,15 @@
</span><span class="cx"> 
</span><span class="cx">     test-&gt;copyClipboard();
</span><span class="cx">     GUniquePtr&lt;char&gt; clipboardText(gtk_clipboard_wait_for_text(test-&gt;m_clipboard));
</span><del>-    g_assert_cmpstr(clipboardText.get(), ==, &quot;All work and no play make Jack a dull boy.&quot;);
</del><ins>+    g_assert_cmpstr(clipboardText.get(), ==, &quot;make Jack a dull&quot;);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> static void testWebViewEditorSelectAllNonEditable(EditorTest* test, gconstpointer)
</span><span class="cx"> {
</span><del>-    static const char* selectedSpanHTML = &quot;&lt;html&gt;&lt;body contentEditable=\&quot;false\&quot;&gt;&quot;
-        &quot;&lt;span id=\&quot;mainspan\&quot;&gt;All work and no play &lt;span id=\&quot;subspan\&quot;&gt;make Jack a dull&lt;/span&gt; boy.&lt;/span&gt;&quot;
-        &quot;&lt;script&gt;document.getSelection().collapse();\n&quot;
-        &quot;document.getSelection().selectAllChildren(document.getElementById('subspan'));\n&quot;
-        &quot;&lt;/script&gt;&lt;/body&gt;&lt;/html&gt;&quot;;
-
</del><span class="cx">     g_assert(test-&gt;canExecuteEditingCommand(WEBKIT_EDITING_COMMAND_SELECT_ALL));
</span><span class="cx"> 
</span><del>-    test-&gt;loadHtml(selectedSpanHTML, 0);
</del><ins>+    GUniquePtr&lt;char&gt; selectedSpanHTML(g_strdup_printf(selectedSpanHTMLFormat, &quot;false&quot;));
+    test-&gt;loadHtml(selectedSpanHTML.get(), nullptr);
</ins><span class="cx">     test-&gt;waitUntilLoadFinished();
</span><span class="cx"> 
</span><span class="cx">     g_assert(test-&gt;canExecuteEditingCommand(WEBKIT_EDITING_COMMAND_SELECT_ALL));
</span><span class="lines">@@ -162,15 +173,14 @@
</span><span class="cx"> 
</span><span class="cx"> static void testWebViewEditorSelectAllEditable(EditorTest* test, gconstpointer)
</span><span class="cx"> {
</span><del>-    static const char* selectedSpanHTML = &quot;&lt;html&gt;&lt;body contentEditable=\&quot;true\&quot;&gt;&quot;
-        &quot;&lt;span id=\&quot;mainspan\&quot;&gt;All work and no play &lt;span id=\&quot;subspan\&quot;&gt;make Jack a dull&lt;/span&gt; boy.&lt;/span&gt;&quot;
-        &quot;&lt;script&gt;document.getSelection().collapse();\n&quot;
-        &quot;document.getSelection().selectAllChildren(document.getElementById('subspan'));\n&quot;
-        &quot;&lt;/script&gt;&lt;/body&gt;&lt;/html&gt;&quot;;
-
</del><span class="cx">     g_assert(test-&gt;canExecuteEditingCommand(WEBKIT_EDITING_COMMAND_SELECT_ALL));
</span><span class="cx"> 
</span><del>-    test-&gt;loadHtml(selectedSpanHTML, 0);
</del><ins>+    g_assert(!test-&gt;isEditable());
+    test-&gt;setEditable(true);
+    g_assert(test-&gt;isEditable());
+
+    GUniquePtr&lt;char&gt; selectedSpanHTML(g_strdup_printf(selectedSpanHTMLFormat, &quot;false&quot;));
+    test-&gt;loadHtml(selectedSpanHTML.get(), nullptr);
</ins><span class="cx">     test-&gt;waitUntilLoadFinished();
</span><span class="cx"> 
</span><span class="cx">     g_assert(test-&gt;canExecuteEditingCommand(WEBKIT_EDITING_COMMAND_SELECT_ALL));
</span><span class="lines">@@ -189,8 +199,65 @@
</span><span class="cx">     g_assert_cmpstr(clipboardText.get(), ==, &quot;All work and no play make Jack a dull boy.&quot;);
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+static void loadContentsAndTryToCutSelection(EditorTest* test, bool contentEditable)
+{
+    // View is not editable by default.
+    g_assert(!test-&gt;isEditable());
+
+    GUniquePtr&lt;char&gt; selectedSpanHTML(g_strdup_printf(selectedSpanHTMLFormat, contentEditable ? &quot;true&quot; : &quot;false&quot;));
+    test-&gt;loadHtml(selectedSpanHTML.get(), nullptr);
+    test-&gt;waitUntilLoadFinished();
+
+    g_assert(!test-&gt;isEditable());
+    test-&gt;setEditable(true);
+    g_assert(test-&gt;isEditable());
+
+    // Cut the selection to the clipboard to see if the view is indeed editable.
+    GUniquePtr&lt;char&gt; clipboardText(test-&gt;cutSelection());
+    g_assert_cmpstr(clipboardText.get(), ==, &quot;make Jack a dull&quot;);
+
+    // Reset the editable for next test.
+    test-&gt;setEditable(false);
+    g_assert(!test-&gt;isEditable());
+}
+
+static void testWebViewEditorNonEditable(EditorTest* test)
+{
+    GUniquePtr&lt;char&gt; selectedSpanHTML(g_strdup_printf(selectedSpanHTMLFormat, &quot;false&quot;));
+    test-&gt;loadHtml(selectedSpanHTML.get(), nullptr);
+    test-&gt;waitUntilLoadFinished();
+
+    g_assert(!test-&gt;isEditable());
+    test-&gt;setEditable(true);
+    g_assert(test-&gt;isEditable());
+    test-&gt;setEditable(false);
+    g_assert(!test-&gt;isEditable());
+
+    // Check if view is indeed non-editable.
+    g_assert(!test-&gt;canExecuteEditingCommand(WEBKIT_EDITING_COMMAND_CUT));
+    g_assert(!test-&gt;canExecuteEditingCommand(WEBKIT_EDITING_COMMAND_PASTE));
+}
+
+static void testWebViewEditorEditable(EditorTest* test, gconstpointer)
+{
+    testWebViewEditorNonEditable(test);
+
+    // Reset the editable for next test.
+    test-&gt;setEditable(false);
+    g_assert(!test-&gt;isEditable());
+
+    loadContentsAndTryToCutSelection(test, true);
+
+    // Reset the editable for next test.
+    test-&gt;setEditable(false);
+    g_assert(!test-&gt;isEditable());
+
+    loadContentsAndTryToCutSelection(test, false);
+}
+
</ins><span class="cx"> void beforeAll()
</span><span class="cx"> {
</span><ins>+    EditorTest::add(&quot;WebKitWebView&quot;, &quot;editable/editable&quot;, testWebViewEditorEditable);
</ins><span class="cx">     EditorTest::add(&quot;WebKitWebView&quot;, &quot;cut-copy-paste/non-editable&quot;, testWebViewEditorCutCopyPasteNonEditable);
</span><span class="cx">     EditorTest::add(&quot;WebKitWebView&quot;, &quot;cut-copy-paste/editable&quot;, testWebViewEditorCutCopyPasteEditable);
</span><span class="cx">     EditorTest::add(&quot;WebKitWebView&quot;, &quot;select-all/non-editable&quot;, testWebViewEditorSelectAllNonEditable);
</span></span></pre></div>
<a id="trunkToolsTestWebKitAPIgtkWebKit2GtkWebViewTestcpp"></a>
<div class="modfile"><h4>Modified: trunk/Tools/TestWebKitAPI/gtk/WebKit2Gtk/WebViewTest.cpp (178702 => 178703)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Tools/TestWebKitAPI/gtk/WebKit2Gtk/WebViewTest.cpp        2015-01-20 10:07:21 UTC (rev 178702)
+++ trunk/Tools/TestWebKitAPI/gtk/WebKit2Gtk/WebViewTest.cpp        2015-01-20 11:22:03 UTC (rev 178703)
</span><span class="lines">@@ -262,6 +262,16 @@
</span><span class="cx">     webkit_web_view_execute_editing_command(m_webView, &quot;SelectAll&quot;);
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+bool WebViewTest::isEditable()
+{
+    webkit_web_view_is_editable(m_webView);
+}
+
+void WebViewTest::setEditable(bool editable)
+{
+    webkit_web_view_set_editable(m_webView, editable);
+}
+
</ins><span class="cx"> static void resourceGetDataCallback(GObject* object, GAsyncResult* result, gpointer userData)
</span><span class="cx"> {
</span><span class="cx">     size_t dataSize;
</span></span></pre></div>
<a id="trunkToolsTestWebKitAPIgtkWebKit2GtkWebViewTesth"></a>
<div class="modfile"><h4>Modified: trunk/Tools/TestWebKitAPI/gtk/WebKit2Gtk/WebViewTest.h (178702 => 178703)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Tools/TestWebKitAPI/gtk/WebKit2Gtk/WebViewTest.h        2015-01-20 10:07:21 UTC (rev 178702)
+++ trunk/Tools/TestWebKitAPI/gtk/WebKit2Gtk/WebViewTest.h        2015-01-20 11:22:03 UTC (rev 178703)
</span><span class="lines">@@ -53,6 +53,9 @@
</span><span class="cx">     void selectAll();
</span><span class="cx">     const char* mainResourceData(size_t&amp; mainResourceDataSize);
</span><span class="cx"> 
</span><ins>+    bool isEditable();
+    void setEditable(bool);
+
</ins><span class="cx">     void mouseMoveTo(int x, int y, unsigned mouseModifiers = 0);
</span><span class="cx">     void clickMouseButton(int x, int y, unsigned button = 1, unsigned mouseModifiers = 0);
</span><span class="cx">     void keyStroke(unsigned keyVal, unsigned keyModifiers = 0);
</span></span></pre>
</div>
</div>

</body>
</html>