[M85 Migration][API] Implement EWK APIs for clipboard 13/245313/2
authoryh106.jung <yh106.jung@samsung.com>
Tue, 1 Aug 2017 04:52:46 +0000 (13:52 +0900)
committerBot Blink <blinkbot@samsung.com>
Mon, 12 Oct 2020 05:46:32 +0000 (05:46 +0000)
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>
tizen_src/ewk/efl_integration/public/ewk_settings.cc
tizen_src/ewk/unittest/BUILD.gn
tizen_src/ewk/unittest/utc_blink_ewk_settings_dom_paste_allowed_get_func.cpp [new file with mode: 0644]
tizen_src/ewk/unittest/utc_blink_ewk_settings_dom_paste_allowed_set_func.cpp [new file with mode: 0644]
tizen_src/ewk/unittest/utc_blink_ewk_settings_javascript_can_access_clipboard_get_func.cpp [new file with mode: 0644]
tizen_src/ewk/unittest/utc_blink_ewk_settings_javascript_can_access_clipboard_set_func.cpp [new file with mode: 0644]

index 84b815c..8ce40cd 100644 (file)
@@ -919,7 +919,8 @@ Eina_Bool ewk_settings_ime_panel_enabled_get(const Ewk_Settings *settings)
   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;
 }
@@ -957,3 +958,31 @@ Eina_Bool ewk_settings_clipboard_enabled_get(const Ewk_Settings* settings)
   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;
+}
index 5882210..0cd7971 100644 (file)
@@ -245,6 +245,8 @@ test("ewk_unittests") {
     "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",
@@ -257,6 +259,8 @@ test("ewk_unittests") {
     "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",
diff --git a/tizen_src/ewk/unittest/utc_blink_ewk_settings_dom_paste_allowed_get_func.cpp b/tizen_src/ewk/unittest/utc_blink_ewk_settings_dom_paste_allowed_get_func.cpp
new file mode 100644 (file)
index 0000000..1819699
--- /dev/null
@@ -0,0 +1,45 @@
+// 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));
+}
diff --git a/tizen_src/ewk/unittest/utc_blink_ewk_settings_dom_paste_allowed_set_func.cpp b/tizen_src/ewk/unittest/utc_blink_ewk_settings_dom_paste_allowed_set_func.cpp
new file mode 100644 (file)
index 0000000..8ac3395
--- /dev/null
@@ -0,0 +1,43 @@
+// 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));
+}
diff --git a/tizen_src/ewk/unittest/utc_blink_ewk_settings_javascript_can_access_clipboard_get_func.cpp b/tizen_src/ewk/unittest/utc_blink_ewk_settings_javascript_can_access_clipboard_get_func.cpp
new file mode 100644 (file)
index 0000000..95da4e2
--- /dev/null
@@ -0,0 +1,49 @@
+// 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));
+}
diff --git a/tizen_src/ewk/unittest/utc_blink_ewk_settings_javascript_can_access_clipboard_set_func.cpp b/tizen_src/ewk/unittest/utc_blink_ewk_settings_javascript_can_access_clipboard_set_func.cpp
new file mode 100644 (file)
index 0000000..3f906ed
--- /dev/null
@@ -0,0 +1,48 @@
+// 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));
+}