IPC_STRUCT_TRAITS_BEGIN(WebPreferencesEfl)
IPC_STRUCT_TRAITS_MEMBER(shrinks_viewport_content_to_fit)
+ IPC_STRUCT_TRAITS_MEMBER(javascript_can_open_windows_automatically_ewk)
IPC_STRUCT_TRAITS_END()
IPC_STRUCT_TRAITS_BEGIN(ErrorParams)
#else
false;
#endif
+ bool javascript_can_open_windows_automatically_ewk = true;
};
#endif // WEB_PREFERENCES_EFL_H
Eina_Bool ewk_settings_scripts_can_open_windows_set(Ewk_Settings* settings, Eina_Bool enable)
{
EINA_SAFETY_ON_NULL_RETURN_VAL(settings, false);
- settings->getPreferences().javascript_can_open_windows_automatically = enable;
+ settings->getPreferencesEfl().javascript_can_open_windows_automatically_ewk = enable;
ewkUpdateWebkitPreferences(settings->getEvasObject());
return true;
}
Eina_Bool ewk_settings_scripts_can_open_windows_get(const Ewk_Settings* settings)
{
EINA_SAFETY_ON_NULL_RETURN_VAL(settings, false);
- return settings->getPreferences().javascript_can_open_windows_automatically;
+ return settings->getPreferencesEfl().javascript_can_open_windows_automatically_ewk;
}
Eina_Bool ewk_settings_encoding_detector_enabled_set(Ewk_Settings* settings, Eina_Bool enable)
};
ContentRendererClientEfl::ContentRendererClientEfl()
- : render_view_(nullptr) {
+ : javascript_can_open_windows_(true) {
}
ContentRendererClientEfl::~ContentRendererClientEfl() {
#if !defined(EWK_BRINGUP)
render_view->SetWrtUrlParser(wrt_url_parser_.get());
#endif
- render_view_ = render_view;
}
bool ContentRendererClientEfl::OverrideCreatePlugin(
return true;
}
-bool ContentRendererClientEfl::AllowPopup() {
- return render_view_
- ? render_view_->GetWebkitPreferences().javascript_can_open_windows_automatically
- : false;
-}
-
void ContentRendererClientEfl::WillReleaseScriptContext(blink::WebFrame* frame,
v8::Handle<v8::Context> context,
int world_id) {
v8::Handle<v8::Context>,
int world_id);
- bool AllowPopup() override;
+ bool AllowPopup() override { return javascript_can_open_windows_; }
+
+ // This setter is an EFL extension, where we cache the preference
+ // that controls whether JS content is allowed to open new windows.
+ // Note that strictly speaking this cached preference is incorrect:
+ // Every 'view' holds a preference instance. So it is possible that
+ // different views objects hold different preference set tha another
+ // at a given time.
+ void SetAllowPopup(bool value) { javascript_can_open_windows_ = value; }
bool WillSendRequest(blink::WebFrame* frame,
ui::PageTransition transition_type,
scoped_ptr<WrtUrlParseImpl> wrt_url_parser_;
scoped_ptr<RenderProcessObserverEfl> render_process_observer_;
scoped_ptr<visitedlink::VisitedLinkSlave> visited_link_slave_;
- content::RenderView* render_view_;
+ bool javascript_can_open_windows_;
};
#endif
view->settings()->setShrinksViewportContentToFit(web_preferences_efl.shrinks_viewport_content_to_fit);
// and more if they exist in web_preferences_efl.
}
+
+ DCHECK(renderer_client_);
+ static_cast<ContentRendererClientEfl*>(renderer_client_)->SetAllowPopup(
+ web_preferences_efl.javascript_can_open_windows_automatically_ewk);
}
void RenderViewObserverEfl::HandleTap(const blink::WebGestureEvent& event)
settings = ewk_view_settings_get(GetEwkWebView());
ASSERT_TRUE(settings);
// make sure default value is proper
- ASSERT_EQ(EINA_FALSE, ewk_settings_scripts_can_open_windows_get(settings));
+ ASSERT_EQ(EINA_TRUE, ewk_settings_scripts_can_open_windows_get(settings));
evas_object_smart_callback_add(GetEwkWebView(), "popup,blocked", ToSmartCallback(popup_blocked_cb), this);
evas_object_smart_callback_add(GetEwkWebView(), "create,window", ToSmartCallback(create_window_cb), this);
"</html>";
ASSERT_EQ(EINA_TRUE, ewk_view_html_string_load(GetEwkWebView(), htmlBuffer, NULL, NULL));
- ASSERT_EQ(Success, EventLoopStart());
+ ASSERT_EQ(Failure, EventLoopStart());
// now toggle option
- ASSERT_EQ(EINA_TRUE, ewk_settings_scripts_can_open_windows_set(settings, EINA_TRUE));
+ ASSERT_EQ(EINA_TRUE, ewk_settings_scripts_can_open_windows_set(settings, EINA_FALSE));
// check if option was toggled
- ASSERT_EQ(EINA_TRUE, ewk_settings_scripts_can_open_windows_get(settings));
+ ASSERT_EQ(EINA_FALSE, ewk_settings_scripts_can_open_windows_get(settings));
// reload page and expect create window smart callback
ASSERT_EQ(EINA_TRUE, ewk_view_html_string_load(GetEwkWebView(), htmlBuffer, NULL, NULL));
- ASSERT_EQ(Failure, EventLoopStart());
+ ASSERT_EQ(Success, EventLoopStart());
}
TEST_F(utc_blink_ewk_settings_scripts_can_open_windows_set, ToggleBeforeLoad)
{
- // Got feedback, that whem property is modified before loading anything to the view
+ // Got feedback, that when property is modified before loading anything to the view
// it may not work. This TC checks such case and tests provided solution
// toggle option