// In M47, it isn't possible anymore to execute javascript in the generic
// case. We need to call ExecuteJavaScriptForTests to keep the behaviour
// unchanged @see https://codereview.chromium.org/1123783002
- render_frame_host->ExecuteJavaScriptForTests(js_script, base::Bind(&JavaScriptComplete, base::Owned(script_callback_data)));
+ render_frame_host->ExecuteJavaScriptWithUserGestureForTests(
+ js_script, base::Bind(&JavaScriptComplete, base::Owned(script_callback_data)));
} else {
// We use ExecuteJavaScriptWithUserGestureForTests instead of ExecuteJavaScript because
// ExecuteJavaScriptWithUserGestureForTests sets user_gesture to true. This was the
protected:
utc_blink_cb_popup_blocked()
: target_uri(NULL)
+ , old_can_open_windows_setting_(false)
{
}
void PostSetUp()
{
+ Ewk_Settings* settings = ewk_view_settings_get(GetEwkWebView());
+ old_can_open_windows_setting_ = ewk_settings_scripts_can_open_windows_get(settings);
+
evas_object_smart_callback_add(GetEwkWebView(), "popup,blocked", ToSmartCallback(popup_blocked_cb), this);
}
void PreTearDown()
{
evas_object_smart_callback_del(GetEwkWebView(), "popup,blocked", ToSmartCallback(popup_blocked_cb));
+
+ Ewk_Settings* settings = ewk_view_settings_get(GetEwkWebView());
+ ewk_settings_scripts_can_open_windows_set(settings, old_can_open_windows_setting_);
}
static void popup_blocked_cb(utc_blink_cb_popup_blocked* owner, Evas_Object*, Eina_Stringshare* uri)
protected:
Eina_Stringshare* target_uri;
+ bool old_can_open_windows_setting_;
};
/**
"<body onload=\"window.open('http://www.google.com/')\"></body>"
"</html>";
+ Ewk_Settings* settings = ewk_view_settings_get(GetEwkWebView());
+ ewk_settings_scripts_can_open_windows_set(settings, false);
+
ASSERT_EQ(EINA_TRUE, ewk_view_html_string_load(GetEwkWebView(), htmlBuffer, NULL, NULL));
ASSERT_EQ(Success, EventLoopStart());
ASSERT_STREQ("http://www.google.com/", target_uri);
+ ewk_settings_scripts_can_open_windows_set(settings, true);
+
// ewk_view_script_execute works like "user gesture" so window.open should not be blocked
ASSERT_EQ(EINA_TRUE, ewk_view_script_execute(GetEwkWebView(), "window.open('http://www.google.com/');", reinterpret_cast<Ewk_View_Script_Execute_Cb>(window_open_script_executed), this));
ASSERT_EQ(Failure, EventLoopStart());