Commit dfeb70e5 authored by abarth@webkit.org's avatar abarth@webkit.org

2010-04-22 Abhishek Arya <inferno@chromium.org>

        Reviewed by Adam Barth.

        Manual test to verify 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):
        (runTest):
2010-04-22  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-04-22  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-04-22  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-04-22  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-04-22  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-04-22  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-04-22  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/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: http://svn.webkit.org/repository/webkit/trunk@58069 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent 70e8a012
2010-04-22 Abhishek Arya <inferno@chromium.org>
Reviewed by Adam Barth.
Manual test to verify 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):
(runTest):
2010-04-21 Adam Barth <abarth@webkit.org>
Reviewed by Eric Seidel.
......
Run this test manually to check whether javascript programs can access clipboard.
On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
PASS successfullyParsed is true
TEST COMPLETE
<!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>
description("Run this test manually to check whether javascript programs can access clipboard.");
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);
// Cannot run this test inside layoutTestController
// since clipboard access is required for other layout tests.
if (!window.layoutTestController)
{
runTest();
}
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;
}
function runTest()
{
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;
2010-04-22 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-04-22 Stephan Aßmus <superstippi@gmx.de>
Reviewed by David Levin.
......@@ -677,6 +677,7 @@ __ZN7WebCore8Settings28setForceFTPDirectoryListingsEb
__ZN7WebCore8Settings29setAuthorAndUserStylesEnabledEb
__ZN7WebCore8Settings29setWebArchiveDebugModeEnabledEb
__ZN7WebCore8Settings30setAllowFileAccessFromFileURLsEb
__ZN7WebCore8Settings31setJavaScriptCanAccessClipboardEb
__ZN7WebCore8Settings31setShrinksStandaloneImagesToFitEb
__ZN7WebCore8Settings32setAcceleratedCompositingEnabledEb
__ZN7WebCore8Settings32setNeedsAdobeFrameReloadingQuirkEb
......
......@@ -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());
}
}
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 } },
......
......@@ -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;
......
......@@ -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)
......
2010-04-22 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-04-21 Tony Chang <tony@chromium.org>
Reviewed by Shinichiro Hamaji.
......
......@@ -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;
......
......@@ -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);
......
......@@ -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();
......
2010-04-22 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-04-21 Jakub Wieczorek <jwieczorek@webkit.org>
Reviewed by Darin Adler.
......
......@@ -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,
......
......@@ -2695,7 +2695,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;
......@@ -2725,6 +2726,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,
......@@ -2760,6 +2762,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);
......@@ -2857,6 +2860,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"))
......
2010-04-22 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-04-21 Alexey Proskuryakov <ap@apple.com>
Reviewed by Shinichiro Hamaji.
......
......@@ -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"
......
......@@ -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];
......
......@@ -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;
......
......@@ -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));
......
......@@ -187,8 +187,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,
......@@ -238,6 +238,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);
......@@ -372,8 +376,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
......@@ -401,6 +405,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
......
......@@ -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,
......
2010-04-22 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-04-21 Jesus Sanchez-Palencia <jesus@webkit.org>
Reviewed by Kenneth Rohde Christiansen.
......
2010-04-22 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-04-21 Andy Estes <aestes@apple.com>
Reviewed by Maciej Stachowiak.
......
......@@ -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);
}
......@@ -125,6 +125,8 @@
#define WebKitZoomsTextOnlyPreferenceKey "WebKitZoomsTextOnly"
#define WebKitJavaScriptCanAccessClipboard "WebKitJavaScriptCanAccessClipboard"
#define WebKitXSSAuditorEnabledPreferenceKey "WebKitXSSAuditorEnabled"
#define WebKitUseHighResolutionTimersPreferenceKey "WebKitUseHighResolutionTimers"
......
......@@ -206,6 +206,7 @@ void WebPreferences::initializeDefaultSettings()