2010-05-03 Abhishek Arya <inferno@chromium.org>
authorabarth@webkit.org <abarth@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 3 May 2010 21:50:27 +0000 (21:50 +0000)
committerabarth@webkit.org <abarth@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 3 May 2010 21:50:27 +0000 (21:50 +0000)
        Reviewed by Adam Barth.

        Tests that javascript cannot access clipboard.
        https://bugs.webkit.org/show_bug.cgi?id=27751

        * editing/execCommand/clipboard-access-expected.txt: Added.
        * editing/execCommand/clipboard-access.html: Added.
        * editing/execCommand/script-tests/clipboard-access.js: Added.
        (enabled):
        (whenEnabled):
2010-05-03  Abhishek Arya  <inferno@chromium.org>

        Reviewed by Adam Barth.

        Add support for controlling clipboard access from javascript.
        Clipboard access from javascript is disabled by default.
        https://bugs.webkit.org/show_bug.cgi?id=27751

        Test: editing/execCommand/clipboard-access.html

        * WebCore.base.exp:
        * editing/EditorCommand.cpp:
        (WebCore::supportedCopyCut):
        (WebCore::supportedPaste):
        (WebCore::createCommandMap):
        * page/Settings.cpp:
        (WebCore::Settings::Settings):
        (WebCore::Settings::setJavaScriptCanAccessClipboard):
        * page/Settings.h:
        (WebCore::Settings::javaScriptCanAccessClipboard):
2010-05-03  Abhishek Arya  <inferno@chromium.org>

        Reviewed by Adam Barth.

        Add support for controlling clipboard access from javascript.
        Clipboard access from javascript is disabled by default.
        https://bugs.webkit.org/show_bug.cgi?id=27751

        * public/WebSettings.h:
        * src/WebSettingsImpl.cpp:
        (WebKit::WebSettingsImpl::setJavaScriptCanAccessClipboard):
        * src/WebSettingsImpl.h:
2010-05-03  Abhishek Arya  <inferno@chromium.org>

        Reviewed by Adam Barth.

        Add support for controlling clipboard access from javascript.
        Clipboard access from javascript is disabled by default.
        https://bugs.webkit.org/show_bug.cgi?id=27751

        * webkit/webkitwebsettings.cpp:
        (webkit_web_settings_class_init):
        (webkit_web_settings_set_property):
        (webkit_web_settings_get_property):
        (webkit_web_settings_copy):
        * webkit/webkitwebview.cpp:
        (webkit_web_view_update_settings):
        (webkit_web_view_settings_notify):
2010-05-03  Abhishek Arya  <inferno@chromium.org>

        Reviewed by Adam Barth.

        Add support for controlling clipboard access from javascript.
        Clipboard access from javascript is disabled by default.
        https://bugs.webkit.org/show_bug.cgi?id=27751

        * WebView/WebPreferenceKeysPrivate.h:
        * WebView/WebPreferences.mm:
        (+[WebPreferences initialize]):
        (-[WebPreferences javaScriptCanAccessClipboard]):
        (-[WebPreferences setJavaScriptCanAccessClipboard:]):
        * WebView/WebPreferencesPrivate.h:
        * WebView/WebView.mm:
        (-[WebView _preferencesChangedNotification:]):
2010-05-03  Abhishek Arya  <inferno@chromium.org>

        Reviewed by Adam Barth.

        Add support for controlling clipboard access from javascript.
        Clipboard access from javascript is disabled by default.
        https://bugs.webkit.org/show_bug.cgi?id=27751

        * Api/qwebsettings.cpp:
        (QWebSettingsPrivate::apply):
        * Api/qwebsettings.h:
2010-05-03  Abhishek Arya  <inferno@chromium.org>

        Reviewed by Adam Barth.

        Add support for controlling clipboard access from javascript.
        Clipboard access from javascript is disabled by default.
        https://bugs.webkit.org/show_bug.cgi?id=27751

        * Interfaces/IWebPreferencesPrivate.idl:
        * WebPreferenceKeysPrivate.h:
        * WebPreferences.cpp:
        (WebPreferences::initializeDefaultSettings):
        (WebPreferences::javaScriptCanAccessClipboard):
        (WebPreferences::setJavaScriptCanAccessClipboard):
        * WebPreferences.h:
        * WebView.cpp:
        (WebView::notifyPreferencesChanged):
2010-05-03  Abhishek Arya  <inferno@chromium.org>

        Reviewed by Adam Barth.

        Add support for controlling clipboard access from javascript.
        Clipboard access from javascript is enabled in test framework.
        https://bugs.webkit.org/show_bug.cgi?id=27751

        * DumpRenderTree/LayoutTestController.cpp:
        (setJavaScriptCanAccessClipboardCallback):
        (LayoutTestController::staticFunctions):
        * DumpRenderTree/LayoutTestController.h:
        * DumpRenderTree/chromium/LayoutTestController.cpp:
        (LayoutTestController::LayoutTestController):
        (LayoutTestController::setJavaScriptCanAccessClipboard):
        (LayoutTestController::overridePreference):
        * DumpRenderTree/chromium/LayoutTestController.h:
        * DumpRenderTree/chromium/TestShell.cpp:
        (TestShell::resetWebSettings):
        * DumpRenderTree/gtk/DumpRenderTree.cpp:
        (resetDefaultsToConsistentValues):
        * DumpRenderTree/gtk/LayoutTestControllerGtk.cpp:
        (LayoutTestController::setJavaScriptCanAccessClipboard):
        * DumpRenderTree/mac/DumpRenderTree.mm:
        (resetDefaultsToConsistentValues):
        * DumpRenderTree/mac/LayoutTestControllerMac.mm:
        (LayoutTestController::setJavaScriptCanAccessClipboard):
        * DumpRenderTree/qt/DumpRenderTreeQt.cpp:
        (WebCore::WebPage::WebPage):
        (WebCore::WebPage::resetSettings):
        * DumpRenderTree/qt/LayoutTestControllerQt.cpp:
        (LayoutTestController::setJavaScriptCanAccessClipboard):
        * DumpRenderTree/qt/LayoutTestControllerQt.h:
        * DumpRenderTree/win/DumpRenderTree.cpp:
        (resetDefaultsToConsistentValues):
        * DumpRenderTree/win/LayoutTestControllerWin.cpp:
        (LayoutTestController::setJavaScriptCanAccessClipboard):
        * DumpRenderTree/wx/LayoutTestControllerWx.cpp:
        (LayoutTestController::setJavaScriptCanAccessClipboard):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@58703 268f45cc-cd09-0410-ab3c-d52691b4dbfc

46 files changed:
LayoutTests/ChangeLog
LayoutTests/editing/execCommand/clipboard-access-expected.txt [new file with mode: 0644]
LayoutTests/editing/execCommand/clipboard-access.html [new file with mode: 0644]
LayoutTests/editing/execCommand/script-tests/clipboard-access.js [new file with mode: 0644]
WebCore/ChangeLog
WebCore/WebCore.base.exp
WebCore/editing/EditorCommand.cpp
WebCore/page/Settings.cpp
WebCore/page/Settings.h
WebKit/chromium/ChangeLog
WebKit/chromium/public/WebSettings.h
WebKit/chromium/src/WebSettingsImpl.cpp
WebKit/chromium/src/WebSettingsImpl.h
WebKit/gtk/ChangeLog
WebKit/gtk/webkit/webkitwebsettings.cpp
WebKit/gtk/webkit/webkitwebview.cpp
WebKit/mac/ChangeLog
WebKit/mac/WebView/WebPreferenceKeysPrivate.h
WebKit/mac/WebView/WebPreferences.mm
WebKit/mac/WebView/WebPreferencesPrivate.h
WebKit/mac/WebView/WebView.mm
WebKit/qt/Api/qwebsettings.cpp
WebKit/qt/Api/qwebsettings.h
WebKit/qt/ChangeLog
WebKit/win/ChangeLog
WebKit/win/Interfaces/IWebPreferencesPrivate.idl
WebKit/win/WebPreferenceKeysPrivate.h
WebKit/win/WebPreferences.cpp
WebKit/win/WebPreferences.h
WebKit/win/WebView.cpp
WebKitTools/ChangeLog
WebKitTools/DumpRenderTree/LayoutTestController.cpp
WebKitTools/DumpRenderTree/LayoutTestController.h
WebKitTools/DumpRenderTree/chromium/LayoutTestController.cpp
WebKitTools/DumpRenderTree/chromium/LayoutTestController.h
WebKitTools/DumpRenderTree/chromium/TestShell.cpp
WebKitTools/DumpRenderTree/gtk/DumpRenderTree.cpp
WebKitTools/DumpRenderTree/gtk/LayoutTestControllerGtk.cpp
WebKitTools/DumpRenderTree/mac/DumpRenderTree.mm
WebKitTools/DumpRenderTree/mac/LayoutTestControllerMac.mm
WebKitTools/DumpRenderTree/qt/DumpRenderTreeQt.cpp
WebKitTools/DumpRenderTree/qt/LayoutTestControllerQt.cpp
WebKitTools/DumpRenderTree/qt/LayoutTestControllerQt.h
WebKitTools/DumpRenderTree/win/DumpRenderTree.cpp
WebKitTools/DumpRenderTree/win/LayoutTestControllerWin.cpp
WebKitTools/DumpRenderTree/wx/LayoutTestControllerWx.cpp

index 8bf5c96..ae38700 100644 (file)
@@ -1,3 +1,16 @@
+2010-05-03  Abhishek Arya  <inferno@chromium.org>
+
+        Reviewed by Adam Barth.
+
+        Tests that javascript cannot access clipboard.
+        https://bugs.webkit.org/show_bug.cgi?id=27751
+
+        * editing/execCommand/clipboard-access-expected.txt: Added.
+        * editing/execCommand/clipboard-access.html: Added.
+        * editing/execCommand/script-tests/clipboard-access.js: Added.
+        (enabled):
+        (whenEnabled):
+
 2010-05-03  Dirk Pranke  <dpranke@chromium.org>
 
         Unreviewed, expectations change.
diff --git a/LayoutTests/editing/execCommand/clipboard-access-expected.txt b/LayoutTests/editing/execCommand/clipboard-access-expected.txt
new file mode 100644 (file)
index 0000000..580ad49
--- /dev/null
@@ -0,0 +1,13 @@
+This test checks whether javascript programs can access clipboard.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS whenEnabled('Copy') is 0
+PASS whenEnabled('Cut') is 0
+PASS whenEnabled('Paste') is 0
+PASS whenEnabled('PasteAndMatchStyle') is 0
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
diff --git a/LayoutTests/editing/execCommand/clipboard-access.html b/LayoutTests/editing/execCommand/clipboard-access.html
new file mode 100644 (file)
index 0000000..74dae55
--- /dev/null
@@ -0,0 +1,13 @@
+<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
+<html>
+<head>
+<link rel="stylesheet" href="../../fast/js/resources/js-test-style.css">
+<script src="../../fast/js/resources/js-test-pre.js"></script>
+</head>
+<body>
+<p id="description"></p>
+<div id="console"></div>
+<script src="script-tests/clipboard-access.js"></script>
+<script src="../../fast/js/resources/js-test-post.js"></script>
+</body>
+</html>
diff --git a/LayoutTests/editing/execCommand/script-tests/clipboard-access.js b/LayoutTests/editing/execCommand/script-tests/clipboard-access.js
new file mode 100644 (file)
index 0000000..4dc74e9
--- /dev/null
@@ -0,0 +1,90 @@
+description("This test checks whether javascript programs can access clipboard.");
+
+if (window.layoutTestController)
+{
+    window.layoutTestController.setJavaScriptCanAccessClipboard(false);
+}
+
+var nonEditableParagraph = document.createElement("p");
+nonEditableParagraph.appendChild(document.createTextNode("x"));
+document.body.appendChild(nonEditableParagraph);
+
+var editableParagraph = document.createElement("p");
+editableParagraph.appendChild(document.createTextNode("x"));
+editableParagraph.setAttribute("contentEditable", "true");
+document.body.appendChild(editableParagraph);
+
+var editablePlainTextParagraph = document.createElement("p");
+editablePlainTextParagraph.appendChild(document.createTextNode("x"));
+editablePlainTextParagraph.setAttribute("contentEditable", "plaintext-only");
+document.body.appendChild(editablePlainTextParagraph);
+
+function enabled(command, element, selectionStart, selectionEnd)
+{
+    var selection = document.getSelection();
+    selection.removeAllRanges();
+    if (element) {
+        var range = document.createRange();
+        range.setStart(element.firstChild, selectionStart);
+        range.setEnd(element.firstChild, selectionEnd);
+        selection.addRange(range);
+    }
+    var result = document.queryCommandEnabled(command)
+    selection.removeAllRanges();
+    return result;
+}
+
+function whenEnabled(command)
+{
+    var enabledWithNoSelection = enabled(command);
+    var enabledWithCaret = enabled(command, editableParagraph, 0, 0);
+    var enabledWithEditableRange = enabled(command, editableParagraph, 0, 1);
+    var enabledWithPlainTextCaret = enabled(command, editablePlainTextParagraph, 0, 0);
+    var enabledWithPlainTextEditableRange = enabled(command, editablePlainTextParagraph, 0, 1);
+    var enabledWithPoint = enabled(command, nonEditableParagraph, 0, 0);
+    var enabledWithNonEditableRange = enabled(command, nonEditableParagraph, 0, 1);
+
+    var summaryInteger = enabledWithNoSelection
+        | (enabledWithCaret << 1)
+        | (enabledWithEditableRange << 2)
+        | (enabledWithPlainTextCaret << 3)
+        | (enabledWithPlainTextEditableRange << 4)
+        | (enabledWithPoint << 5)
+        | (enabledWithNonEditableRange << 6);
+
+    if (summaryInteger === 0x7F)
+        return "always";
+
+    if (summaryInteger === 0x54)
+        return "range";
+
+    if (summaryInteger === 0x1E)
+        return "editable";
+    if (summaryInteger === 0x0A)
+        return "caret";
+    if (summaryInteger === 0x14)
+        return "editable range";
+
+    if (summaryInteger === 0x06)
+        return "richly editable";
+    if (summaryInteger === 0x02)
+        return "richly editable caret";
+    if (summaryInteger === 0x04)
+        return "richly editable range";
+
+    if (summaryInteger === 0x5E)
+        return "visible";
+
+    return summaryInteger;
+}
+
+shouldBe("whenEnabled('Copy')", "0");
+shouldBe("whenEnabled('Cut')", "0");
+shouldBe("whenEnabled('Paste')", "0");
+shouldBe("whenEnabled('PasteAndMatchStyle')", "0");
+
+document.body.removeChild(nonEditableParagraph);
+document.body.removeChild(editableParagraph);
+document.body.removeChild(editablePlainTextParagraph);
+
+var successfullyParsed = true;
index 79ed1fe..24e1137 100644 (file)
@@ -1,3 +1,24 @@
+2010-05-03  Abhishek Arya  <inferno@chromium.org>
+
+        Reviewed by Adam Barth.
+
+        Add support for controlling clipboard access from javascript.
+        Clipboard access from javascript is disabled by default.
+        https://bugs.webkit.org/show_bug.cgi?id=27751
+
+        Test: editing/execCommand/clipboard-access.html
+
+        * WebCore.base.exp:
+        * editing/EditorCommand.cpp:
+        (WebCore::supportedCopyCut):
+        (WebCore::supportedPaste):
+        (WebCore::createCommandMap):
+        * page/Settings.cpp:
+        (WebCore::Settings::Settings):
+        (WebCore::Settings::setJavaScriptCanAccessClipboard):
+        * page/Settings.h:
+        (WebCore::Settings::javaScriptCanAccessClipboard):
+
 2010-05-03  Alexey Proskuryakov  <ap@apple.com>
 
         Reviewed by Adam Barth.
index e10099b..d66ee1b 100644 (file)
@@ -678,6 +678,7 @@ __ZN7WebCore8Settings28setForceFTPDirectoryListingsEb
 __ZN7WebCore8Settings29setAuthorAndUserStylesEnabledEb
 __ZN7WebCore8Settings29setWebArchiveDebugModeEnabledEb
 __ZN7WebCore8Settings30setAllowFileAccessFromFileURLsEb
+__ZN7WebCore8Settings31setJavaScriptCanAccessClipboardEb
 __ZN7WebCore8Settings31setShrinksStandaloneImagesToFitEb
 __ZN7WebCore8Settings32setAcceleratedCompositingEnabledEb
 __ZN7WebCore8Settings32setNeedsAdobeFrameReloadingQuirkEb
index 34fa46d..4cb34ac 100644 (file)
@@ -1069,6 +1069,21 @@ static bool supportedFromMenuOrKeyBinding(Frame*, EditorCommandSource source)
     return source == CommandFromMenuOrKeyBinding;
 }
 
+static bool supportedCopyCut(Frame* frame, EditorCommandSource source)
+{
+    switch (source) {
+        case CommandFromMenuOrKeyBinding:
+            return true;
+        case CommandFromDOM:
+        case CommandFromDOMWithUserInterface: {
+            Settings* settings = frame ? frame->settings() : 0;
+            return settings && settings->javaScriptCanAccessClipboard();
+        }
+    }
+    ASSERT_NOT_REACHED();
+    return false;
+}
+
 static bool supportedPaste(Frame* frame, EditorCommandSource source)
 {
     switch (source) {
@@ -1077,7 +1092,7 @@ static bool supportedPaste(Frame* frame, EditorCommandSource source)
         case CommandFromDOM:
         case CommandFromDOMWithUserInterface: {
             Settings* settings = frame ? frame->settings() : 0;
-            return settings && settings->isDOMPasteAllowed();
+            return settings && (settings->javaScriptCanAccessClipboard() ? settings->isDOMPasteAllowed() : 0);
         }
     }
     ASSERT_NOT_REACHED();
@@ -1304,9 +1319,9 @@ static const CommandMap& createCommandMap()
         { "BackColor", { executeBackColor, supported, enabledInRichlyEditableText, stateNone, valueBackColor, notTextInsertion, doNotAllowExecutionWhenDisabled } },
         { "BackwardDelete", { executeDeleteBackward, supportedFromMenuOrKeyBinding, enabledInEditableText, stateNone, valueNull, notTextInsertion, doNotAllowExecutionWhenDisabled } }, // FIXME: remove BackwardDelete when Safari for Windows stops using it.
         { "Bold", { executeToggleBold, supported, enabledInRichlyEditableText, stateBold, valueNull, notTextInsertion, doNotAllowExecutionWhenDisabled } },
-        { "Copy", { executeCopy, supported, enabledCopy, stateNone, valueNull, notTextInsertion, allowExecutionWhenDisabled } },
+        { "Copy", { executeCopy, supportedCopyCut, enabledCopy, stateNone, valueNull, notTextInsertion, allowExecutionWhenDisabled } },
         { "CreateLink", { executeCreateLink, supported, enabledInRichlyEditableText, stateNone, valueNull, notTextInsertion, doNotAllowExecutionWhenDisabled } },
-        { "Cut", { executeCut, supported, enabledCut, stateNone, valueNull, notTextInsertion, allowExecutionWhenDisabled } },
+        { "Cut", { executeCut, supportedCopyCut, enabledCut, stateNone, valueNull, notTextInsertion, allowExecutionWhenDisabled } },
         { "Delete", { executeDelete, supported, enabledDelete, stateNone, valueNull, notTextInsertion, doNotAllowExecutionWhenDisabled } },
         { "DeleteBackward", { executeDeleteBackward, supportedFromMenuOrKeyBinding, enabledInEditableText, stateNone, valueNull, notTextInsertion, doNotAllowExecutionWhenDisabled } },
         { "DeleteBackwardByDecomposingPreviousCharacter", { executeDeleteBackwardByDecomposingPreviousCharacter, supportedFromMenuOrKeyBinding, enabledInEditableText, stateNone, valueNull, notTextInsertion, doNotAllowExecutionWhenDisabled } },
index fd9f9e3..714888b 100644 (file)
@@ -84,6 +84,7 @@ Settings::Settings(Page* page)
     , m_allowUniversalAccessFromFileURLs(true)
     , m_allowFileAccessFromFileURLs(true)
     , m_javaScriptCanOpenWindowsAutomatically(false)
+    , m_javaScriptCanAccessClipboard(false)
     , m_shouldPrintBackgrounds(false)
     , m_textAreasAreResizable(false)
 #if ENABLE(DASHBOARD_SUPPORT)
@@ -308,6 +309,11 @@ void Settings::setJavaScriptCanOpenWindowsAutomatically(bool javaScriptCanOpenWi
     m_javaScriptCanOpenWindowsAutomatically = javaScriptCanOpenWindowsAutomatically;
 }
 
+void Settings::setJavaScriptCanAccessClipboard(bool javaScriptCanAccessClipboard)
+{
+    m_javaScriptCanAccessClipboard = javaScriptCanAccessClipboard;
+}
+
 void Settings::setDefaultTextEncodingName(const String& defaultTextEncodingName)
 {
     m_defaultTextEncodingName = defaultTextEncodingName;
index 104decc..327dd04 100644 (file)
@@ -122,6 +122,9 @@ namespace WebCore {
         void setJavaScriptCanOpenWindowsAutomatically(bool);
         bool javaScriptCanOpenWindowsAutomatically() const { return m_javaScriptCanOpenWindowsAutomatically; }
 
+        void setJavaScriptCanAccessClipboard(bool);
+        bool javaScriptCanAccessClipboard() const { return m_javaScriptCanAccessClipboard; }
+
         void setSpatialNavigationEnabled(bool);
         bool isSpatialNavigationEnabled() const { return m_isSpatialNavigationEnabled; }
 
@@ -345,6 +348,7 @@ namespace WebCore {
         bool m_allowUniversalAccessFromFileURLs: 1;
         bool m_allowFileAccessFromFileURLs: 1;
         bool m_javaScriptCanOpenWindowsAutomatically : 1;
+        bool m_javaScriptCanAccessClipboard : 1;
         bool m_shouldPrintBackgrounds : 1;
         bool m_textAreasAreResizable : 1;
 #if ENABLE(DASHBOARD_SUPPORT)
index 9c9d093..6997345 100644 (file)
@@ -1,3 +1,16 @@
+2010-05-03  Abhishek Arya  <inferno@chromium.org>
+
+        Reviewed by Adam Barth.
+
+        Add support for controlling clipboard access from javascript.
+        Clipboard access from javascript is disabled by default.
+        https://bugs.webkit.org/show_bug.cgi?id=27751
+
+        * public/WebSettings.h:
+        * src/WebSettingsImpl.cpp:
+        (WebKit::WebSettingsImpl::setJavaScriptCanAccessClipboard):
+        * src/WebSettingsImpl.h:
+
 2010-05-03  Jens Alfke  <snej@chromium.org>
 
         Reviewed by Darin Fisher.
index 6339ded..356d9fa 100644 (file)
@@ -72,6 +72,7 @@ public:
     virtual void setAuthorAndUserStylesEnabled(bool) = 0;
     virtual void setUsesPageCache(bool) = 0;
     virtual void setDownloadableBinaryFontsEnabled(bool) = 0;
+    virtual void setJavaScriptCanAccessClipboard(bool) = 0;
     virtual void setXSSAuditorEnabled(bool) = 0;
     virtual void setLocalStorageEnabled(bool) = 0;
     virtual void setEditableLinkBehaviorNeverLive() = 0;
index 9e0fa91..3adf3ac 100644 (file)
@@ -200,6 +200,11 @@ void WebSettingsImpl::setDownloadableBinaryFontsEnabled(bool enabled)
     m_settings->setDownloadableBinaryFontsEnabled(enabled);
 }
 
+void WebSettingsImpl::setJavaScriptCanAccessClipboard(bool enabled)
+{
+    m_settings->setJavaScriptCanAccessClipboard(enabled);
+}
+
 void WebSettingsImpl::setXSSAuditorEnabled(bool enabled)
 {
     m_settings->setXSSAuditorEnabled(enabled);
index 7a809c7..54c660b 100644 (file)
@@ -74,6 +74,7 @@ public:
     virtual void setAuthorAndUserStylesEnabled(bool);
     virtual void setUsesPageCache(bool);
     virtual void setDownloadableBinaryFontsEnabled(bool);
+    virtual void setJavaScriptCanAccessClipboard(bool);
     virtual void setXSSAuditorEnabled(bool);
     virtual void setLocalStorageEnabled(bool);
     virtual void setEditableLinkBehaviorNeverLive();
index 980f906..a4170d2 100644 (file)
@@ -1,3 +1,20 @@
+2010-05-03  Abhishek Arya  <inferno@chromium.org>
+
+        Reviewed by Adam Barth.
+
+        Add support for controlling clipboard access from javascript.
+        Clipboard access from javascript is disabled by default.
+        https://bugs.webkit.org/show_bug.cgi?id=27751
+
+        * webkit/webkitwebsettings.cpp:
+        (webkit_web_settings_class_init):
+        (webkit_web_settings_set_property):
+        (webkit_web_settings_get_property):
+        (webkit_web_settings_copy):
+        * webkit/webkitwebview.cpp:
+        (webkit_web_view_update_settings):
+        (webkit_web_view_settings_notify):
+
 2010-05-03  Jens Alfke  <snej@chromium.org>
 
         Reviewed by Darin Fisher.
index 5d2d658..d61f3ff 100644 (file)
@@ -96,6 +96,7 @@ struct _WebKitWebSettingsPrivate {
     gboolean enable_spatial_navigation;
     gchar* user_agent;
     gboolean javascript_can_open_windows_automatically;
+    gboolean javascript_can_access_clipboard;
     gboolean enable_offline_web_application_cache;
     WebKitEditingBehavior editing_behavior;
     gboolean enable_universal_access_from_file_uris;
@@ -145,6 +146,7 @@ enum {
     PROP_ENABLE_SPATIAL_NAVIGATION,
     PROP_USER_AGENT,
     PROP_JAVASCRIPT_CAN_OPEN_WINDOWS_AUTOMATICALLY,
+    PROP_JAVASCRIPT_CAN_ACCESS_CLIPBOARD,
     PROP_ENABLE_OFFLINE_WEB_APPLICATION_CACHE,
     PROP_EDITING_BEHAVIOR,
     PROP_ENABLE_UNIVERSAL_ACCESS_FROM_FILE_URIS,
@@ -623,6 +625,22 @@ static void webkit_web_settings_class_init(WebKitWebSettingsClass* klass)
                                                          _("Whether JavaScript can open windows automatically"),
                                                          FALSE,
                                                          flags));
+
+    /**
+    * WebKitWebSettings:javascript-can-access-clipboard
+    *
+    * Whether JavaScript can access Clipboard.
+    *
+    * Since: 1.3.0
+    */
+    g_object_class_install_property(gobject_class,
+                                    PROP_JAVASCRIPT_CAN_ACCESS_CLIPBOARD,
+                                    g_param_spec_boolean("javascript-can-access-clipboard",
+                                                         _("JavaScript can access Clipboard"),
+                                                         _("Whether JavaScript can access Clipboard"),
+                                                         FALSE,
+                                                         flags));
+
     /**
     * WebKitWebSettings:enable-offline-web-application-cache
     *
@@ -1023,6 +1041,9 @@ static void webkit_web_settings_set_property(GObject* object, guint prop_id, con
     case PROP_JAVASCRIPT_CAN_OPEN_WINDOWS_AUTOMATICALLY:
         priv->javascript_can_open_windows_automatically = g_value_get_boolean(value);
         break;
+    case PROP_JAVASCRIPT_CAN_ACCESS_CLIPBOARD:
+        priv->javascript_can_access_clipboard = g_value_get_boolean(value);
+        break;
     case PROP_ENABLE_OFFLINE_WEB_APPLICATION_CACHE:
         priv->enable_offline_web_application_cache = g_value_get_boolean(value);
         break;
@@ -1161,6 +1182,9 @@ static void webkit_web_settings_get_property(GObject* object, guint prop_id, GVa
     case PROP_JAVASCRIPT_CAN_OPEN_WINDOWS_AUTOMATICALLY:
         g_value_set_boolean(value, priv->javascript_can_open_windows_automatically);
         break;
+    case PROP_JAVASCRIPT_CAN_ACCESS_CLIPBOARD:
+        g_value_set_boolean(value, priv->javascript_can_access_clipboard);
+        break;
     case PROP_ENABLE_OFFLINE_WEB_APPLICATION_CACHE:
         g_value_set_boolean(value, priv->enable_offline_web_application_cache);
         break;
@@ -1255,6 +1279,7 @@ WebKitWebSettings* webkit_web_settings_copy(WebKitWebSettings* web_settings)
                  "enable-spatial-navigation", priv->enable_spatial_navigation,
                  "user-agent", webkit_web_settings_get_user_agent(web_settings),
                  "javascript-can-open-windows-automatically", priv->javascript_can_open_windows_automatically,
+                 "javascript-can-access-clipboard", priv->javascript_can_access_clipboard,
                  "enable-offline-web-application-cache", priv->enable_offline_web_application_cache,
                  "editing-behavior", priv->editing_behavior,
                  "enable-universal-access-from-file-uris", priv->enable_universal_access_from_file_uris,
index b3e7f6e..6536961 100644 (file)
@@ -2696,7 +2696,8 @@ static void webkit_web_view_update_settings(WebKitWebView* webView)
     gboolean autoLoadImages, autoShrinkImages, printBackgrounds,
         enableScripts, enablePlugins, enableDeveloperExtras, resizableTextAreas,
         enablePrivateBrowsing, enableCaretBrowsing, enableHTML5Database, enableHTML5LocalStorage,
-        enableXSSAuditor, enableSpatialNavigation, javascriptCanOpenWindows, enableOfflineWebAppCache,
+        enableXSSAuditor, enableSpatialNavigation, javascriptCanOpenWindows,
+        javaScriptCanAccessClipboard, enableOfflineWebAppCache,
         enableUniversalAccessFromFileURI, enableFileAccessFromFileURI,
         enableDOMPaste, tabKeyCyclesThroughElements,
         enableSiteSpecificQuirks, usePageCache, enableJavaApplet;
@@ -2726,6 +2727,7 @@ static void webkit_web_view_update_settings(WebKitWebView* webView)
                  "enable-xss-auditor", &enableXSSAuditor,
                  "enable-spatial-navigation", &enableSpatialNavigation,
                  "javascript-can-open-windows-automatically", &javascriptCanOpenWindows,
+                 "javascript-can-access-clipboard", &javaScriptCanAccessClipboard,
                  "enable-offline-web-application-cache", &enableOfflineWebAppCache,
                  "editing-behavior", &editingBehavior,
                  "enable-universal-access-from-file-uris", &enableUniversalAccessFromFileURI,
@@ -2761,6 +2763,7 @@ static void webkit_web_view_update_settings(WebKitWebView* webView)
     settings->setXSSAuditorEnabled(enableXSSAuditor);
     settings->setSpatialNavigationEnabled(enableSpatialNavigation);
     settings->setJavaScriptCanOpenWindowsAutomatically(javascriptCanOpenWindows);
+    settings->setJavaScriptCanAccessClipboard(javaScriptCanAccessClipboard);
     settings->setOfflineWebApplicationCacheEnabled(enableOfflineWebAppCache);
     settings->setEditingBehavior(core(editingBehavior));
     settings->setAllowUniversalAccessFromFileURLs(enableUniversalAccessFromFileURI);
@@ -2858,6 +2861,8 @@ static void webkit_web_view_settings_notify(WebKitWebSettings* webSettings, GPar
         settings->setSpatialNavigationEnabled(g_value_get_boolean(&value));
     else if (name == g_intern_string("javascript-can-open-windows-automatically"))
         settings->setJavaScriptCanOpenWindowsAutomatically(g_value_get_boolean(&value));
+    else if (name == g_intern_string("javascript-can-access-clipboard"))
+        settings->setJavaScriptCanAccessClipboard(g_value_get_boolean(&value));
     else if (name == g_intern_string("enable-offline-web-application-cache"))
         settings->setOfflineWebApplicationCacheEnabled(g_value_get_boolean(&value));
     else if (name == g_intern_string("editing-behavior"))
index 917bd48..750dc6d 100644 (file)
@@ -1,3 +1,20 @@
+2010-05-03  Abhishek Arya  <inferno@chromium.org>
+
+        Reviewed by Adam Barth.
+
+        Add support for controlling clipboard access from javascript.
+        Clipboard access from javascript is disabled by default.
+        https://bugs.webkit.org/show_bug.cgi?id=27751
+
+        * WebView/WebPreferenceKeysPrivate.h:
+        * WebView/WebPreferences.mm:
+        (+[WebPreferences initialize]):
+        (-[WebPreferences javaScriptCanAccessClipboard]):
+        (-[WebPreferences setJavaScriptCanAccessClipboard:]):
+        * WebView/WebPreferencesPrivate.h:
+        * WebView/WebView.mm:
+        (-[WebView _preferencesChangedNotification:]):
+
 2010-05-03  Jens Alfke  <snej@chromium.org>
 
         Reviewed by Darin Fisher.
index e74d0e5..f4ae333 100644 (file)
@@ -84,6 +84,7 @@
 #define WebKitEnableFullDocumentTeardownPreferenceKey @"WebKitEnableFullDocumentTeardown"
 #define WebKitOfflineWebApplicationCacheEnabledPreferenceKey @"WebKitOfflineWebApplicationCacheEnabled"
 #define WebKitZoomsTextOnlyPreferenceKey @"WebKitZoomsTextOnly"
+#define WebKitJavaScriptCanAccessClipboardPreferenceKey @"WebKitJavaScriptCanAccessClipboard"
 #define WebKitXSSAuditorEnabledPreferenceKey @"WebKitXSSAuditorEnabled"
 #define WebKitAcceleratedCompositingEnabledPreferenceKey @"WebKitAcceleratedCompositingEnabled"
 #define WebKitShowDebugBordersPreferenceKey @"WebKitShowDebugBorders"
index 06897e3..9de8495 100644 (file)
@@ -350,6 +350,7 @@ static WebCacheModel cacheModelForMainBundle(void)
         [NSNumber numberWithBool:NO],   WebKitLocalFileContentSniffingEnabledPreferenceKey,
         [NSNumber numberWithBool:NO],   WebKitOfflineWebApplicationCacheEnabledPreferenceKey,
         [NSNumber numberWithBool:YES],  WebKitZoomsTextOnlyPreferenceKey,
+        [NSNumber numberWithBool:NO],   WebKitJavaScriptCanAccessClipboardPreferenceKey,
         [NSNumber numberWithBool:YES],  WebKitXSSAuditorEnabledPreferenceKey,
         [NSNumber numberWithBool:YES],  WebKitAcceleratedCompositingEnabledPreferenceKey,
         [NSNumber numberWithBool:NO],   WebKitShowDebugBordersPreferenceKey,
@@ -831,6 +832,16 @@ static WebCacheModel cacheModelForMainBundle(void)
     [self _setBoolValue:flag forKey:WebKitZoomsTextOnlyPreferenceKey];
 }
 
+- (BOOL)javaScriptCanAccessClipboard
+{
+    return [self _boolValueForKey:WebKitJavaScriptCanAccessClipboardPreferenceKey];
+}
+
+- (void)setJavaScriptCanAccessClipboard:(BOOL)flag
+{
+    [self _setBoolValue:flag forKey:WebKitJavaScriptCanAccessClipboardPreferenceKey];
+}
+
 - (BOOL)isXSSAuditorEnabled
 {
     return [self _boolValueForKey:WebKitXSSAuditorEnabledPreferenceKey];
index 0b5f969..ee785e9 100644 (file)
@@ -107,6 +107,9 @@ extern NSString *WebPreferencesRemovedNotification;
 - (BOOL)zoomsTextOnly;
 - (void)setZoomsTextOnly:(BOOL)zoomsTextOnly;
 
+- (BOOL)javaScriptCanAccessClipboard;
+- (void)setJavaScriptCanAccessClipboard:(BOOL)flag;
+
 - (BOOL)isXSSAuditorEnabled;
 - (void)setXSSAuditorEnabled:(BOOL)flag;
 
index 89ab55f..98de0b5 100644 (file)
@@ -1345,6 +1345,7 @@ static bool fastDocumentTeardownEnabled()
     settings->setLocalFileContentSniffingEnabled([preferences localFileContentSniffingEnabled]);
     settings->setOfflineWebApplicationCacheEnabled([preferences offlineWebApplicationCacheEnabled]);
     settings->setZoomMode([preferences zoomsTextOnly] ? ZoomTextOnly : ZoomPage);
+    settings->setJavaScriptCanAccessClipboard([preferences javaScriptCanAccessClipboard]);
     settings->setXSSAuditorEnabled([preferences isXSSAuditorEnabled]);
     settings->setEnforceCSSMIMETypeInStrictMode(!WKAppVersionCheckLessThan(@"com.apple.iWeb", -1, 2.1));
     
index a8819de..5d33efd 100644 (file)
@@ -185,8 +185,8 @@ void QWebSettingsPrivate::apply()
                                       global->attributes.value(QWebSettings::SpatialNavigationEnabled));
         settings->setSpatialNavigationEnabled(value);
 
-        value = attributes.value(QWebSettings::JavascriptCanAccessClipboard,
-                                      global->attributes.value(QWebSettings::JavascriptCanAccessClipboard));
+        value = attributes.value(QWebSettings::DOMPasteAllowed,
+                                      global->attributes.value(QWebSettings::DOMPasteAllowed));
         settings->setDOMPasteAllowed(value);
 
         value = attributes.value(QWebSettings::DeveloperExtrasEnabled,
@@ -236,6 +236,10 @@ void QWebSettingsPrivate::apply()
                                       global->attributes.value(QWebSettings::LocalContentCanAccessFileUrls));
         settings->setAllowFileAccessFromFileURLs(value);
 
+        value = attributes.value(QWebSettings::JavaScriptCanAccessClipboard,
+                                      global->attributes.value(QWebSettings::JavaScriptCanAccessClipboard));
+        settings->setJavaScriptCanAccessClipboard(value);
+
         value = attributes.value(QWebSettings::XSSAuditingEnabled,
                                       global->attributes.value(QWebSettings::XSSAuditingEnabled));
         settings->setXSSAuditorEnabled(value);
@@ -373,8 +377,8 @@ QWebSettings* QWebSettings::globalSettings()
         recording visited pages in the history and storing web page icons.
     \value JavascriptCanOpenWindows Specifies whether JavaScript programs
         can open new windows.
-    \value JavascriptCanAccessClipboard Specifies whether JavaScript programs
-        can read or write to the clipboard.
+    \value DOMPasteAllowed Specifies whether JavaScript programs can
+        read clipboard contents.
     \value DeveloperExtrasEnabled Enables extra tools for Web developers.
         Currently this enables the "Inspect" element in the context menu as
         well as the use of QWebInspector which controls the WebKit WebInspector
@@ -402,6 +406,7 @@ QWebSettings* QWebSettings::globalSettings()
         QWebSettings::LocalStorageEnabled instead.
     \value LocalContentCanAccessRemoteUrls Specifies whether locally loaded documents are allowed to access remote urls.
     \value LocalContentCanAccessFileUrls Specifies whether locally loaded documents are allowed to access other local urls.
+    \value JavaScriptCanAccessClipboard Specifies whether JavaScript can access the clipboard.
     \value XSSAuditingEnabled Specifies whether load requests should be monitored for cross-site scripting attempts.
     \value AcceleratedCompositingEnabled This feature, when used in conjunction with
         QGraphicsWebView, accelerates animations of web content. CSS animations of the transform and
index bd728d8..41376e4 100644 (file)
@@ -55,7 +55,7 @@ public:
         PluginsEnabled,
         PrivateBrowsingEnabled,
         JavascriptCanOpenWindows,
-        JavascriptCanAccessClipboard,
+        DOMPasteAllowed,
         DeveloperExtrasEnabled,
         LinksIncludedInFocusChain,
         ZoomTextOnly,
@@ -68,6 +68,7 @@ public:
 #endif
         LocalContentCanAccessRemoteUrls,
         DnsPrefetchEnabled,
+        JavaScriptCanAccessClipboard,
         XSSAuditingEnabled,
         AcceleratedCompositingEnabled,
         WebGLEnabled,
index 5740e01..6f49e41 100644 (file)
@@ -1,3 +1,15 @@
+2010-05-03  Abhishek Arya  <inferno@chromium.org>
+
+        Reviewed by Adam Barth.
+
+        Add support for controlling clipboard access from javascript.
+        Clipboard access from javascript is disabled by default.
+        https://bugs.webkit.org/show_bug.cgi?id=27751
+
+        * Api/qwebsettings.cpp:
+        (QWebSettingsPrivate::apply):
+        * Api/qwebsettings.h:
+
 2010-05-03  Jens Alfke  <snej@chromium.org>
 
         Reviewed by Darin Fisher.
index 24cb93d..34d9eaf 100644 (file)
@@ -1,3 +1,21 @@
+2010-05-03  Abhishek Arya  <inferno@chromium.org>
+
+        Reviewed by Adam Barth.
+
+        Add support for controlling clipboard access from javascript.
+        Clipboard access from javascript is disabled by default.
+        https://bugs.webkit.org/show_bug.cgi?id=27751
+
+        * Interfaces/IWebPreferencesPrivate.idl:
+        * WebPreferenceKeysPrivate.h:
+        * WebPreferences.cpp:
+        (WebPreferences::initializeDefaultSettings):
+        (WebPreferences::javaScriptCanAccessClipboard):
+        (WebPreferences::setJavaScriptCanAccessClipboard):
+        * WebPreferences.h:
+        * WebView.cpp:
+        (WebView::notifyPreferencesChanged):
+
 2010-05-03  Jens Alfke  <snej@chromium.org>
 
         Reviewed by Darin Fisher.
index 76ee3fa..2cb4037 100644 (file)
@@ -109,4 +109,7 @@ interface IWebPreferencesPrivate : IUnknown
 
     HRESULT setShowRepaintCounter([in] BOOL);
     HRESULT showRepaintCounter([out, retval] BOOL*);
+
+    HRESULT javaScriptCanAccessClipboard([out, retval] BOOL *enabled);
+    HRESULT setJavaScriptCanAccessClipboard([in] BOOL enabled);
 }
index c57934c..c49a96d 100644 (file)
 
 #define WebKitZoomsTextOnlyPreferenceKey "WebKitZoomsTextOnly"
 
+#define WebKitJavaScriptCanAccessClipboardPreferenceKey "WebKitJavaScriptCanAccessClipboard"
+
 #define WebKitXSSAuditorEnabledPreferenceKey "WebKitXSSAuditorEnabled"
 
 #define WebKitUseHighResolutionTimersPreferenceKey "WebKitUseHighResolutionTimers"
index b5937cb..33e904d 100644 (file)
@@ -206,6 +206,7 @@ void WebPreferences::initializeDefaultSettings()
     CFDictionaryAddValue(defaults, CFSTR(WebKitWebSecurityEnabledPreferenceKey), kCFBooleanTrue);
     CFDictionaryAddValue(defaults, CFSTR(WebKitAllowUniversalAccessFromFileURLsPreferenceKey), kCFBooleanFalse);
     CFDictionaryAddValue(defaults, CFSTR(WebKitAllowFileAccessFromFileURLsPreferenceKey), kCFBooleanTrue);
+    CFDictionaryAddValue(defaults, CFSTR(WebKitJavaScriptCanAccessClipboardPreferenceKey), kCFBooleanFalse);
     CFDictionaryAddValue(defaults, CFSTR(WebKitXSSAuditorEnabledPreferenceKey), kCFBooleanTrue);
     CFDictionaryAddValue(defaults, CFSTR(WebKitFrameFlatteningEnabledPreferenceKey), kCFBooleanFalse);
     CFDictionaryAddValue(defaults, CFSTR(WebKitJavaScriptCanOpenWindowsAutomaticallyPreferenceKey), kCFBooleanTrue);
@@ -809,6 +810,20 @@ HRESULT STDMETHODCALLTYPE WebPreferences::setAllowFileAccessFromFileURLs(
     return S_OK;
 }
 
+HRESULT STDMETHODCALLTYPE WebPreferences::javaScriptCanAccessClipboard(
+    /* [retval][out] */ BOOL* enabled)
+{
+    *enabled = boolValueForKey(CFSTR(WebKitJavaScriptCanAccessClipboardPreferenceKey));
+    return S_OK;
+}
+
+HRESULT STDMETHODCALLTYPE WebPreferences::setJavaScriptCanAccessClipboard(
+    /* [in] */ BOOL enabled)
+{
+    setBoolValue(CFSTR(WebKitJavaScriptCanAccessClipboardPreferenceKey), enabled);
+    return S_OK;
+}
+
 HRESULT STDMETHODCALLTYPE WebPreferences::isXSSAuditorEnabled(
     /* [retval][out] */ BOOL* enabled)
 {
index 241178d..cfdefa8 100644 (file)
@@ -368,6 +368,12 @@ public:
     virtual HRESULT STDMETHODCALLTYPE setAllowFileAccessFromFileURLs(
     /* [in] */ BOOL allowAccess);
 
+    virtual HRESULT STDMETHODCALLTYPE javaScriptCanAccessClipboard(
+    /* [retval][out] */ BOOL* enabled);
+
+    virtual HRESULT STDMETHODCALLTYPE setJavaScriptCanAccessClipboard(
+    /* [in] */ BOOL enabled);
+
     virtual HRESULT STDMETHODCALLTYPE isXSSAuditorEnabled(
     /* [retval][out] */ BOOL* enabled);
 
index f8ffb72..248e3cd 100644 (file)
@@ -4667,6 +4667,11 @@ HRESULT WebView::notifyPreferencesChanged(IWebNotification* notification)
         return hr;
     settings->setAllowFileAccessFromFileURLs(!!enabled);
 
+    hr = prefsPrivate->javaScriptCanAccessClipboard(&enabled);
+    if (FAILED(hr))
+        return hr;
+    settings->setJavaScriptCanAccessClipboard(!!enabled);
+
     hr = prefsPrivate->isXSSAuditorEnabled(&enabled);
     if (FAILED(hr))
         return hr;
index 9af9895..f11d1a1 100644 (file)
@@ -1,3 +1,43 @@
+2010-05-03  Abhishek Arya  <inferno@chromium.org>
+
+        Reviewed by Adam Barth.
+
+        Add support for controlling clipboard access from javascript.
+        Clipboard access from javascript is enabled in test framework.
+        https://bugs.webkit.org/show_bug.cgi?id=27751
+
+        * DumpRenderTree/LayoutTestController.cpp:
+        (setJavaScriptCanAccessClipboardCallback):
+        (LayoutTestController::staticFunctions):
+        * DumpRenderTree/LayoutTestController.h:
+        * DumpRenderTree/chromium/LayoutTestController.cpp:
+        (LayoutTestController::LayoutTestController):
+        (LayoutTestController::setJavaScriptCanAccessClipboard):
+        (LayoutTestController::overridePreference):
+        * DumpRenderTree/chromium/LayoutTestController.h:
+        * DumpRenderTree/chromium/TestShell.cpp:
+        (TestShell::resetWebSettings):
+        * DumpRenderTree/gtk/DumpRenderTree.cpp:
+        (resetDefaultsToConsistentValues):
+        * DumpRenderTree/gtk/LayoutTestControllerGtk.cpp:
+        (LayoutTestController::setJavaScriptCanAccessClipboard):
+        * DumpRenderTree/mac/DumpRenderTree.mm:
+        (resetDefaultsToConsistentValues):
+        * DumpRenderTree/mac/LayoutTestControllerMac.mm:
+        (LayoutTestController::setJavaScriptCanAccessClipboard):
+        * DumpRenderTree/qt/DumpRenderTreeQt.cpp:
+        (WebCore::WebPage::WebPage):
+        (WebCore::WebPage::resetSettings):
+        * DumpRenderTree/qt/LayoutTestControllerQt.cpp:
+        (LayoutTestController::setJavaScriptCanAccessClipboard):
+        * DumpRenderTree/qt/LayoutTestControllerQt.h:
+        * DumpRenderTree/win/DumpRenderTree.cpp:
+        (resetDefaultsToConsistentValues):
+        * DumpRenderTree/win/LayoutTestControllerWin.cpp:
+        (LayoutTestController::setJavaScriptCanAccessClipboard):
+        * DumpRenderTree/wx/LayoutTestControllerWx.cpp:
+        (LayoutTestController::setJavaScriptCanAccessClipboard):
+
 2010-05-03  Anders Carlsson  <andersca@apple.com>
 
         Reviewed by Adam Roben.
index 0f13be9..b4b5bf2 100644 (file)
@@ -937,6 +937,18 @@ static JSValueRef setPrivateBrowsingEnabledCallback(JSContextRef context, JSObje
     return JSValueMakeUndefined(context);
 }
 
+static JSValueRef setJavaScriptCanAccessClipboardCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
+{
+    // Has mac & windows implementation
+    if (argumentCount < 1)
+        return JSValueMakeUndefined(context);
+
+    LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
+    controller->setJavaScriptCanAccessClipboard(JSValueToBoolean(context, arguments[0]));
+
+    return JSValueMakeUndefined(context);
+}
+
 static JSValueRef setXSSAuditorEnabledCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
 {
     // Has mac & windows implementation
@@ -1606,6 +1618,7 @@ JSStaticFunction* LayoutTestController::staticFunctions()
         { "setWillSendRequestReturnsNull", setWillSendRequestReturnsNullCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
         { "setWillSendRequestReturnsNullOnRedirect", setWillSendRequestReturnsNullOnRedirectCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
         { "setWindowIsKey", setWindowIsKeyCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
+        { "setJavaScriptCanAccessClipboard", setJavaScriptCanAccessClipboardCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
         { "setXSSAuditorEnabled", setXSSAuditorEnabledCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
         { "showWebInspector", showWebInspectorCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
         { "testOnscreen", testOnscreenCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
index da29d38..08f9692 100644 (file)
@@ -81,6 +81,7 @@ public:
     void setDomainRelaxationForbiddenForURLScheme(bool forbidden, JSStringRef scheme);
     void setIconDatabaseEnabled(bool iconDatabaseEnabled);
     void setJavaScriptProfilingEnabled(bool profilingEnabled);
+    void setJavaScriptCanAccessClipboard(bool flag);
     void setMainFrameIsFirstResponder(bool flag);
     void setMockGeolocationError(int code, JSStringRef message);
     void setMockGeolocationPosition(double latitude, double longitude, double accuracy);
index d0dca69..21b168c 100644 (file)
@@ -139,6 +139,7 @@ LayoutTestController::LayoutTestController(TestShell* shell)
     bindMethod("setPrivateBrowsingEnabled", &LayoutTestController::setPrivateBrowsingEnabled);
     bindMethod("setUseDashboardCompatibilityMode", &LayoutTestController::setUseDashboardCompatibilityMode);
 
+    bindMethod("setJavaScriptCanAccessClipboard", &LayoutTestController::setJavaScriptCanAccessClipboard);
     bindMethod("setXSSAuditorEnabled", &LayoutTestController::setXSSAuditorEnabled);
     bindMethod("evaluateScriptInIsolatedWorld", &LayoutTestController::evaluateScriptInIsolatedWorld);
     bindMethod("overridePreference", &LayoutTestController::overridePreference);
@@ -881,6 +882,13 @@ void LayoutTestController::setPrivateBrowsingEnabled(const CppArgumentList& argu
     result->setNull();
 }
 
+void LayoutTestController::setJavaScriptCanAccessClipboard(const CppArgumentList& arguments, CppVariant* result)
+{
+    if (arguments.size() > 0 && arguments[0].isBool())
+        m_shell->webView()->settings()->setJavaScriptCanAccessClipboard(arguments[0].value.boolValue);
+    result->setNull();
+}
+
 void LayoutTestController::setXSSAuditorEnabled(const CppArgumentList& arguments, CppVariant* result)
 {
     if (arguments.size() > 0 && arguments[0].isBool())
@@ -1007,6 +1015,8 @@ void LayoutTestController::overridePreference(const CppArgumentList& arguments,
         settings->setJavaEnabled(cppVariantToBool(value));
     else if (key == "WebKitUsesPageCachePreferenceKey")
         settings->setUsesPageCache(cppVariantToBool(value));
+    else if (key == "WebKitJavaScriptCanAccessClipboard")
+        settings->setJavaScriptCanAccessClipboard(cppVariantToBool(value));
     else if (key == "WebKitXSSAuditorEnabled")
         settings->setXSSAuditorEnabled(cppVariantToBool(value));
     else if (key == "WebKitLocalStorageEnabledPreferenceKey")
index a8639da..ca8b014 100644 (file)
@@ -213,6 +213,7 @@ public:
     void setCallCloseOnWebViews(const CppArgumentList&, CppVariant*);
     void setPrivateBrowsingEnabled(const CppArgumentList&, CppVariant*);
 
+    void setJavaScriptCanAccessClipboard(const CppArgumentList&, CppVariant*);
     void setXSSAuditorEnabled(const CppArgumentList&, CppVariant*);
     void evaluateScriptInIsolatedWorld(const CppArgumentList&, CppVariant*);
     void overridePreference(const CppArgumentList&, CppVariant*);
index 9d72737..e4229fe 100644 (file)
@@ -138,6 +138,7 @@ void TestShell::resetWebSettings(WebView& webView)
     settings->setMinimumFontSize(1);
     settings->setMinimumLogicalFontSize(9);
     settings->setJavaScriptCanOpenWindowsAutomatically(true);
+    settings->setJavaScriptCanAccessClipboard(true);
     settings->setDOMPasteAllowed(true);
     settings->setDeveloperExtrasEnabled(false);
     settings->setNeedsSiteSpecificQuirks(true);
index e37613d..0f3ca38 100644 (file)
@@ -325,6 +325,7 @@ static void resetDefaultsToConsistentValues()
                  "enable-html5-local-storage", TRUE,
                  "enable-xss-auditor", FALSE,
                  "enable-spatial-navigation", FALSE,
+                 "javascript-can-access-clipboard", TRUE,
                  "javascript-can-open-windows-automatically", TRUE,
                  "enable-offline-web-application-cache", TRUE,
                  "enable-universal-access-from-file-uris", TRUE,
index 58d2631..cbba7ce 100644 (file)
@@ -362,6 +362,15 @@ void LayoutTestController::setPrivateBrowsingEnabled(bool flag)
     g_object_set(G_OBJECT(settings), "enable-private-browsing", flag, NULL);
 }
 
+void LayoutTestController::setJavaScriptCanAccessClipboard(bool flag)
+{
+    WebKitWebView* view = webkit_web_frame_get_web_view(mainFrame);
+    ASSERT(view);
+
+    WebKitWebSettings* settings = webkit_web_view_get_settings(view);
+    g_object_set(G_OBJECT(settings), "javascript-can-access-clipboard", flag, NULL);
+}
+
 void LayoutTestController::setXSSAuditorEnabled(bool flag)
 {
     WebKitWebView* view = webkit_web_frame_get_web_view(mainFrame);
index b766c28..bd25310 100644 (file)
@@ -431,6 +431,7 @@ static void resetDefaultsToConsistentValues()
     [preferences setPrivateBrowsingEnabled:NO];
     [preferences setAuthorAndUserStylesEnabled:YES];
     [preferences setJavaScriptCanOpenWindowsAutomatically:YES];
+    [preferences setJavaScriptCanAccessClipboard:YES];
     [preferences setOfflineWebApplicationCacheEnabled:YES];
     [preferences setDeveloperExtrasEnabled:NO];
     [preferences setLoadsImagesAutomatically:YES];
index e62e411..3b03aec 100644 (file)
@@ -371,6 +371,11 @@ void LayoutTestController::setPopupBlockingEnabled(bool popupBlockingEnabled)
     [[[mainFrame webView] preferences] setJavaScriptCanOpenWindowsAutomatically:!popupBlockingEnabled];
 }
 
+void LayoutTestController::setJavaScriptCanAccessClipboard(bool enabled)
+{
+    [[[mainFrame webView] preferences] setJavaScriptCanAccessClipboard:enabled];
+}
+
 void LayoutTestController::setTabKeyCyclesThroughElements(bool cycles)
 {
     [[mainFrame webView] setTabKeyCyclesThroughElements:cycles];
index 2c2db92..9d2a065 100644 (file)
@@ -148,13 +148,14 @@ WebPage::WebPage(QObject* parent, DumpRenderTree* drt)
     globalSettings->setFontSize(QWebSettings::DefaultFixedFontSize, 13);
 
     globalSettings->setAttribute(QWebSettings::JavascriptCanOpenWindows, true);
-    globalSettings->setAttribute(QWebSettings::JavascriptCanAccessClipboard, true);
+    globalSettings->setAttribute(QWebSettings::DOMPasteAllowed, true);
     globalSettings->setAttribute(QWebSettings::LinksIncludedInFocusChain, false);
     globalSettings->setAttribute(QWebSettings::PluginsEnabled, true);
     globalSettings->setAttribute(QWebSettings::LocalContentCanAccessRemoteUrls, true);
     globalSettings->setAttribute(QWebSettings::JavascriptEnabled, true);
     globalSettings->setAttribute(QWebSettings::PrivateBrowsingEnabled, false);
     globalSettings->setAttribute(QWebSettings::SpatialNavigationEnabled, false);
+    globalSettings->setAttribute(QWebSettings::JavaScriptCanAccessClipboard, true);
 
     connect(this, SIGNAL(geometryChangeRequested(const QRect &)),
             this, SLOT(setViewGeometry(const QRect & )));
@@ -190,6 +191,7 @@ void WebPage::resetSettings()
     settings()->resetAttribute(QWebSettings::OfflineWebApplicationCacheEnabled);
     settings()->resetAttribute(QWebSettings::LocalContentCanAccessRemoteUrls);
     settings()->resetAttribute(QWebSettings::PluginsEnabled);
+    settings()->resetAttribute(QWebSettings::JavaScriptCanAccessClipboard);
 
     m_drt->layoutTestController()->setCaretBrowsingEnabled(false);
     m_drt->layoutTestController()->setFrameFlatteningEnabled(false);
index aff108d..93c583e 100644 (file)
@@ -409,6 +409,11 @@ void LayoutTestController::setMainFrameIsFirstResponder(bool isFirst)
     //FIXME: only need this for the moment: https://bugs.webkit.org/show_bug.cgi?id=32990
 }
 
+void LayoutTestController::setJavaScriptCanAccessClipboard(bool enable)
+{
+    m_drt->webPage()->settings()->setAttribute(QWebSettings::JavaScriptCanAccessClipboard, enable);
+}
+
 void LayoutTestController::setXSSAuditorEnabled(bool enable)
 {
     // Set XSSAuditingEnabled globally so that windows created by the test inherit it too.
index df645e1..b13f2ad 100644 (file)
@@ -144,6 +144,7 @@ public slots:
     void resetLoadFinished() { m_loadFinished = false; }
     void setWindowIsKey(bool isKey);
     void setMainFrameIsFirstResponder(bool isFirst);
+    void setJavaScriptCanAccessClipboard(bool enable);
     void setXSSAuditorEnabled(bool enable);
     void setCaretBrowsingEnabled(bool enable);
     void setViewModeMediaFeature(const QString& mode);
index bd12f2c..e96adae 100644 (file)
@@ -795,6 +795,7 @@ static void resetDefaultsToConsistentValues(IWebPreferences* preferences)
         prefsPrivate->setDeveloperExtrasEnabled(FALSE);
         prefsPrivate->setExperimentalNotificationsEnabled(TRUE);
         prefsPrivate->setShouldPaintNativeControls(FALSE); // FIXME - need to make DRT pass with Windows native controls <http://bugs.webkit.org/show_bug.cgi?id=25592>
+        prefsPrivate->setJavaScriptCanAccessClipboard(TRUE);
         prefsPrivate->setXSSAuditorEnabled(FALSE);
         prefsPrivate->setFrameFlatteningEnabled(FALSE);
         prefsPrivate->setOfflineWebApplicationCacheEnabled(TRUE);
index 24ddc3b..d889cfc 100644 (file)
@@ -483,6 +483,23 @@ void LayoutTestController::setPopupBlockingEnabled(bool enabled)
     preferences->setJavaScriptCanOpenWindowsAutomatically(!enabled);
 }
 
+void LayoutTestController::setJavaScriptCanAccessClipboard(bool enabled)
+{
+    COMPtr<IWebView> webView;
+    if (FAILED(frame->webView(&webView)))
+        return;
+
+    COMPtr<IWebPreferences> preferences;
+    if (FAILED(webView->preferences(&preferences)))
+        return;
+
+    COMPtr<IWebPreferencesPrivate> prefsPrivate(Query, preferences);
+    if (!prefsPrivate)
+        return;
+
+    prefsPrivate->setJavaScriptCanAccessClipboard(enabled);
+}
+
 void LayoutTestController::setTabKeyCyclesThroughElements(bool shouldCycle)
 {
     COMPtr<IWebView> webView;
index a99b2a5..4614aca 100644 (file)
@@ -167,6 +167,11 @@ void LayoutTestController::setPrivateBrowsingEnabled(bool privateBrowsingEnabled
     // FIXME: implement
 }
 
+void LayoutTestController::setJavaScriptCanAccessClipboard(bool enabled)
+{
+    // FIXME: implement
+}
+
 void LayoutTestController::setXSSAuditorEnabled(bool enabled)
 {
     // FIXME: implement