This patch implements below internal EWK APIs for clipboard.
* ewk_settings_javascript_can_access_clipboard_{get,set}
- These APIs get/set the permission to access clipboard from javascript.
* ewk_settings_dom_paste_allowed_{get,set}
- These APIs get/set the permission for DOM paste.
Added also a unit tests for these APIs.
References:
https://review.tizen.org/gerrit/c/platform/framework/web/chromium-efl/+/220050
Change-Id: I60349ef902f15bb39cda0a3fb5608b4e477dd62b
Signed-off-by: yh106.jung <yh106.jung@samsung.com>
return EINA_FALSE;
}
-Eina_Bool ewk_settings_allow_file_access_from_external_url_set(Ewk_Settings* settings, Eina_Bool allow) {
+Eina_Bool ewk_settings_allow_file_access_from_external_url_set(Ewk_Settings* settings, Eina_Bool allow)
+{
LOG_EWK_API_MOCKUP();
return false;
}
LOG_EWK_API_MOCKUP();
return EINA_FALSE;
}
+
+Eina_Bool ewk_settings_javascript_can_access_clipboard_set(Ewk_Settings* settings, Eina_Bool enable)
+{
+ EINA_SAFETY_ON_NULL_RETURN_VAL(settings, EINA_FALSE);
+ settings->getPreferences().javascript_can_access_clipboard = enable;
+ ewkUpdateWebkitPreferences(settings->getEvasObject());
+ return EINA_TRUE;
+}
+
+Eina_Bool ewk_settings_javascript_can_access_clipboard_get(const Ewk_Settings* settings)
+{
+ EINA_SAFETY_ON_NULL_RETURN_VAL(settings, EINA_FALSE);
+ return settings->getPreferences().javascript_can_access_clipboard;
+}
+
+Eina_Bool ewk_settings_dom_paste_allowed_set(Ewk_Settings* settings, Eina_Bool enable)
+{
+ EINA_SAFETY_ON_NULL_RETURN_VAL(settings, EINA_FALSE);
+ settings->getPreferences().dom_paste_enabled = enable;
+ ewkUpdateWebkitPreferences(settings->getEvasObject());
+ return EINA_TRUE;
+}
+
+Eina_Bool ewk_settings_dom_paste_allowed_get(const Ewk_Settings* settings)
+{
+ EINA_SAFETY_ON_NULL_RETURN_VAL(settings, EINA_FALSE);
+ return settings->getPreferences().dom_paste_enabled;
+}
"utc_blink_ewk_settings_default_encoding_set_func.cpp",
"utc_blink_ewk_settings_default_keypad_enabled_set_func.cpp",
"utc_blink_ewk_settings_detect_contents_automatically_set_func.cpp",
+ "utc_blink_ewk_settings_dom_paste_allowed_get_func.cpp",
+ "utc_blink_ewk_settings_dom_paste_allowed_set_func.cpp",
"utc_blink_ewk_settings_edge_effect_enabled_set_func.cpp",
"utc_blink_ewk_settings_editable_link_behavior_set_func.cpp",
"utc_blink_ewk_settings_extra_feature_set_func.cpp",
"utc_blink_ewk_settings_initial_list_style_position_get_func.cpp",
"utc_blink_ewk_settings_initial_list_style_position_set_func.cpp",
"utc_blink_ewk_settings_is_encoding_valid_func.cpp",
+ "utc_blink_ewk_settings_javascript_can_access_clipboard_get_func.cpp",
+ "utc_blink_ewk_settings_javascript_can_access_clipboard_set_func.cpp",
"utc_blink_ewk_settings_javascript_enabled_get_func.cpp",
"utc_blink_ewk_settings_javascript_enabled_set_func.cpp",
"utc_blink_ewk_settings_link_effect_enabled_set_func.cpp",
--- /dev/null
+// Copyright 2016 Samsung Electronics. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "utc_blink_ewk_base.h"
+
+class utc_blink_ewk_settings_dom_paste_allowed_get_func
+ : public utc_blink_ewk_base {
+ protected:
+ utc_blink_ewk_settings_dom_paste_allowed_get_func()
+ : settings_(nullptr) {
+ }
+
+ void PostSetUp() override {
+ settings_ = ewk_view_settings_get(GetEwkWebView());
+ ASSERT_TRUE(settings_ != nullptr);
+ }
+
+ Ewk_Settings* settings_;
+};
+
+/**
+ * @brief Tests whether the function works properly for case 2nd param is TRUE.
+ */
+TEST_F(utc_blink_ewk_settings_dom_paste_allowed_get_func, POS_ENABLE_TRUE) {
+ ASSERT_TRUE(ewk_settings_dom_paste_allowed_set(settings_, EINA_TRUE));
+ EXPECT_TRUE(ewk_settings_dom_paste_allowed_get(settings_));
+}
+
+/**
+ * @brief Tests whether the function works properly for case 2nd param is FALSE.
+ */
+TEST_F(utc_blink_ewk_settings_dom_paste_allowed_get_func, POS_ENABLE_FALSE) {
+ ASSERT_TRUE(ewk_settings_dom_paste_allowed_set(settings_, EINA_FALSE));
+ EXPECT_FALSE(ewk_settings_dom_paste_allowed_get(settings_));
+}
+
+/**
+ * @brief Tests whether the function works properly
+ * for case Ewk_Settings object is NULL.
+ */
+TEST_F(utc_blink_ewk_settings_dom_paste_allowed_get_func,
+ NEG_INVALID_SETTINGS_PARAM) {
+ EXPECT_FALSE(ewk_settings_dom_paste_allowed_get(nullptr));
+}
--- /dev/null
+// Copyright 2016 Samsung Electronics. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "utc_blink_ewk_base.h"
+
+class utc_blink_ewk_settings_dom_paste_allowed_set_func
+ : public utc_blink_ewk_base {
+ protected:
+ utc_blink_ewk_settings_dom_paste_allowed_set_func()
+ : settings_(nullptr) {
+ }
+
+ void PostSetUp() override {
+ settings_ = ewk_view_settings_get(GetEwkWebView());
+ ASSERT_TRUE(settings_ != nullptr);
+ }
+
+ Ewk_Settings* settings_;
+};
+
+/**
+ * @brief Tests whether the function works properly for case 2nd param is TRUE.
+ */
+TEST_F(utc_blink_ewk_settings_dom_paste_allowed_set_func, POS_ENABLE_TRUE) {
+ EXPECT_TRUE(ewk_settings_dom_paste_allowed_set(settings_, EINA_TRUE));
+}
+
+/**
+ * @brief Tests whether the function works properly for case 2nd param is FALSE.
+ */
+TEST_F(utc_blink_ewk_settings_dom_paste_allowed_set_func, POS_ENABLE_FALSE) {
+ EXPECT_TRUE(ewk_settings_dom_paste_allowed_set(settings_, EINA_FALSE));
+}
+
+/**
+ * @brief Tests whether the function works properly
+ * for case Ewk_Settings object is NULL.
+ */
+TEST_F(utc_blink_ewk_settings_dom_paste_allowed_set_func,
+ NEG_INVALID_SETTINGS_PARAM) {
+ EXPECT_FALSE(ewk_settings_dom_paste_allowed_set(nullptr, EINA_TRUE));
+}
--- /dev/null
+// Copyright 2016 Samsung Electronics. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "utc_blink_ewk_base.h"
+
+class utc_blink_ewk_settings_javascript_can_access_clipboard_get_func
+ : public utc_blink_ewk_base {
+ protected:
+ utc_blink_ewk_settings_javascript_can_access_clipboard_get_func()
+ : settings_(nullptr) {
+ }
+
+ void PostSetUp() override {
+ settings_ = ewk_view_settings_get(GetEwkWebView());
+ ASSERT_TRUE(settings_ != nullptr);
+ }
+
+ Ewk_Settings* settings_;
+};
+
+/**
+ * @brief Tests whether the function works properly for case 2nd param is TRUE.
+ */
+TEST_F(utc_blink_ewk_settings_javascript_can_access_clipboard_get_func,
+ POS_ENABLE_TRUE) {
+ ASSERT_TRUE(ewk_settings_javascript_can_access_clipboard_set(
+ settings_, EINA_TRUE));
+ EXPECT_TRUE(ewk_settings_javascript_can_access_clipboard_get(settings_));
+}
+
+/**
+ * @brief Tests whether the function works properly for case 2nd param is FALSE.
+ */
+TEST_F(utc_blink_ewk_settings_javascript_can_access_clipboard_get_func,
+ POS_ENABLE_FALSE) {
+ ASSERT_TRUE(ewk_settings_javascript_can_access_clipboard_set(
+ settings_, EINA_FALSE));
+ EXPECT_FALSE(ewk_settings_javascript_can_access_clipboard_get(settings_));
+}
+
+/**
+ * @brief Tests whether the function works properly
+ * for case Ewk_Settings object is NULL.
+ */
+TEST_F(utc_blink_ewk_settings_javascript_can_access_clipboard_get_func,
+ NEG_INVALID_SETTINGS_PARAM) {
+ EXPECT_FALSE(ewk_settings_javascript_can_access_clipboard_get(nullptr));
+}
--- /dev/null
+// Copyright 2016 Samsung Electronics. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "utc_blink_ewk_base.h"
+
+class utc_blink_ewk_settings_javascript_can_access_clipboard_set_func
+ : public utc_blink_ewk_base {
+ protected:
+ utc_blink_ewk_settings_javascript_can_access_clipboard_set_func()
+ : settings_(nullptr) {
+ }
+
+ void PostSetUp() override {
+ settings_ = ewk_view_settings_get(GetEwkWebView());
+ ASSERT_TRUE(settings_ != nullptr);
+ }
+
+ Ewk_Settings* settings_;
+};
+
+/**
+ * @brief Tests whether the function works properly for case 2nd param is TRUE.
+ */
+TEST_F(utc_blink_ewk_settings_javascript_can_access_clipboard_set_func,
+ POS_ENABLE_TRUE) {
+ EXPECT_TRUE(ewk_settings_javascript_can_access_clipboard_set(
+ settings_, EINA_TRUE));
+}
+
+/**
+ * @brief Tests whether the function works properly for case 2nd param is FALSE.
+ */
+TEST_F(utc_blink_ewk_settings_javascript_can_access_clipboard_set_func,
+ POS_ENABLE_FALSE) {
+ EXPECT_TRUE(ewk_settings_javascript_can_access_clipboard_set(
+ settings_, EINA_FALSE));
+}
+
+/**
+ * @brief Tests whether the function works properly
+ * for case Ewk_Settings object is NULL.
+ */
+TEST_F(utc_blink_ewk_settings_javascript_can_access_clipboard_set_func,
+ NEG_INVALID_SETTINGS_PARAM) {
+ EXPECT_FALSE(ewk_settings_javascript_can_access_clipboard_set(
+ nullptr, EINA_TRUE));
+}