Custom protocol handler test page added.
authorFilip Piechocki <f.piechocki@samsung.com>
Tue, 16 Dec 2014 10:01:23 +0000 (11:01 +0100)
committerYoungsoo Choi <kenshin.choi@samsung.com>
Tue, 10 Jul 2018 06:57:09 +0000 (06:57 +0000)
Custom protocol handlers' origin must have 'http' or 'https'
protocol and the site registering the custom handler must be
of the same origin as this handler. This implies, that the
test page's origin must have 'http' or 'https' protocol, so
we hosted this test page on GitHub:
  http://jmajnert.github.io/tests/customProtocols/
and modified tests to use it.

Bug: http://107.108.218.239/bugzilla/show_bug.cgi?id=9522
Reviewed by: Antonio Gomes, Min-Soo Koo, Piotr Tworek, commitbot

Change-Id: I5bfc9ff681f1bdfde1131af6d25f88c42bc92235
Signed-off-by: Filip Piechocki <f.piechocki@samsung.com>
tizen_src/ewk/unittest/resources/protocol_handler/register_burger_handler.html [new file with mode: 0644]
tizen_src/ewk/unittest/utc_blink_ewk_custom_handlers_data_target_get_func.cpp
tizen_src/ewk/unittest/utc_blink_ewk_custom_handlers_data_title_get_func.cpp
tizen_src/ewk/unittest/utc_blink_ewk_custom_handlers_data_url_get_func.cpp

diff --git a/tizen_src/ewk/unittest/resources/protocol_handler/register_burger_handler.html b/tizen_src/ewk/unittest/resources/protocol_handler/register_burger_handler.html
new file mode 100644 (file)
index 0000000..3c9cf76
--- /dev/null
@@ -0,0 +1,24 @@
+<html>
+<body onload="test();">
+</body>
+<script>
+function test() {
+  if (navigator.registerProtocolHandler) {
+    var str = "navigator.registerProtocolHandler is supported!";
+    console.log(str);
+    document.title = str;
+    // registerProtocolHandler example from Mozilla Developer Network
+    navigator.registerProtocolHandler("web+burger",
+                                      "http://jmajnert.github.io/tests/customProtocols/?uri=%s",
+                                      "Burger handler");
+    str = "burger protocol handler registered!";
+    console.log(str);
+    document.title = str;
+  } else {
+    var str = "navigator.registerProtocolHandler is not supported!";
+    console.log(str);
+    document.title = str;
+  }
+}
+</script>
+</html>
index 1a03911..834ad0b 100644 (file)
@@ -6,6 +6,9 @@
 
 class utc_blink_ewk_custom_handlers_data_target_get: public utc_blink_ewk_base {
 protected:
+  utc_blink_ewk_custom_handlers_data_target_get() : target_(NULL) {}
+  ~utc_blink_ewk_custom_handlers_data_target_get() { free(target_); }
+
   void PostSetUp()
   {
     evas_object_smart_callback_add(GetEwkWebView(),"protocolhandler,registration,requested", (void(*)(void*, Evas_Object*, void*))custom_handler, this);
@@ -28,18 +31,26 @@ protected:
     ASSERT_TRUE(NULL != owner);
     ASSERT_TRUE(NULL != custom_handler_data);
 
-    ASSERT_STREQ("tel", ewk_custom_handlers_data_target_get(custom_handler_data));
+    const char* target = ewk_custom_handlers_data_target_get(custom_handler_data);
+    owner->target_ = (target ? strdup(target) : NULL);
     owner->EventLoopStop(Success);
   }
+
+protected:
+  char* target_;
+  static const char* const expected_target_;
 };
 
+const char* const utc_blink_ewk_custom_handlers_data_target_get::expected_target_ = "web+burger";
+
 /**
  * @brief Checking if base_url is returned properly.
 */
 TEST_F(utc_blink_ewk_custom_handlers_data_target_get, POS_TEST)
 {
-  ASSERT_EQ(EINA_TRUE, ewk_view_url_set(GetEwkWebView(), "http://codebits.glennjones.net/registerprotocol/register.html"));
+  ASSERT_EQ(EINA_TRUE, ewk_view_url_set(GetEwkWebView(), "http://jmajnert.github.io/tests/customProtocols/"));
   ASSERT_EQ(Success, EventLoopStart());
+  ASSERT_STREQ(expected_target_, target_);
 }
 
 /**
index adcc9c7..49dcddc 100644 (file)
@@ -6,6 +6,11 @@
 
 class utc_blink_ewk_custom_handlers_data_title_get: public utc_blink_ewk_base {
 protected:
+  utc_blink_ewk_custom_handlers_data_title_get() : title_(NULL) {}
+  ~utc_blink_ewk_custom_handlers_data_title_get() {
+    free(title_);
+  }
+
   void PostSetUp()
   {
     evas_object_smart_callback_add(GetEwkWebView(),"protocolhandler,registration,requested", (void(*)(void*, Evas_Object*, void*))custom_handler, this);
@@ -28,18 +33,26 @@ protected:
     ASSERT_TRUE(NULL != owner);
     ASSERT_TRUE(NULL != custom_handler_data);
 
-    ASSERT_STREQ("Telephony App", ewk_custom_handlers_data_title_get(custom_handler_data));
+    const char *title = ewk_custom_handlers_data_title_get(custom_handler_data);
+    owner->title_ = (title ? strdup(title) : NULL);
     owner->EventLoopStop(Success);
   }
+
+protected:
+  char* title_;
+  static const char* const expected_title_;
 };
 
+const char* const utc_blink_ewk_custom_handlers_data_title_get::expected_title_ = "Burger handler";
+
 /**
  * @brief Checking if base_url is returned properly.
 */
 TEST_F(utc_blink_ewk_custom_handlers_data_title_get, POS_TEST)
 {
-  ASSERT_EQ(EINA_TRUE, ewk_view_url_set(GetEwkWebView(), "http://codebits.glennjones.net/registerprotocol/register.html"));
-  ASSERT_EQ(Success, EventLoopStart());
+  ASSERT_EQ(EINA_TRUE, ewk_view_url_set(GetEwkWebView(), "http://jmajnert.github.io/tests/customProtocols/"));
+  ASSERT_EQ(Success, EventLoopStart()) << "\"protocolhandler,registration,requested\" was not fired.";
+  ASSERT_STREQ(expected_title_, title_);
 }
 
 /**
index 07042b5..c955db7 100644 (file)
@@ -6,6 +6,9 @@
 
 class utc_blink_ewk_custom_handlers_data_url_get: public utc_blink_ewk_base {
 protected:
+  utc_blink_ewk_custom_handlers_data_url_get() : url_(NULL) {}
+  ~utc_blink_ewk_custom_handlers_data_url_get() { free(url_); }
+
   void PostSetUp()
   {
     evas_object_smart_callback_add(GetEwkWebView(),"protocolhandler,registration,requested", (void(*)(void*, Evas_Object*, void*))custom_handler, this);
@@ -28,18 +31,26 @@ protected:
     ASSERT_TRUE(NULL != owner);
     ASSERT_TRUE(NULL != custom_handler_data);
 
-    ASSERT_STREQ("http://codebits.glennjones.net/registerprotocol/register.html?%s", ewk_custom_handlers_data_url_get(custom_handler_data));
+    const char* url = ewk_custom_handlers_data_url_get(custom_handler_data);
+    owner->url_ = (url ? strdup(url) : NULL);
     owner->EventLoopStop(Success);
   }
+
+protected:
+  char* url_;
+  static const char* const expected_url_;
 };
 
+const char* const utc_blink_ewk_custom_handlers_data_url_get::expected_url_ = "http://jmajnert.github.io/tests/customProtocols/?uri=%s";
+
 /**
  * @brief Checking if base_url is returned properly.
 */
 TEST_F(utc_blink_ewk_custom_handlers_data_url_get, POS_TEST)
 {
-  ASSERT_EQ(EINA_TRUE, ewk_view_url_set(GetEwkWebView(), "http://codebits.glennjones.net/registerprotocol/register.html"));
+  ASSERT_EQ(EINA_TRUE, ewk_view_url_set(GetEwkWebView(), "http://jmajnert.github.io/tests/customProtocols/"));
   ASSERT_EQ(Success, EventLoopStart());
+  ASSERT_STREQ(expected_url_, url_);
 }
 
 /**