diff --git a/atom/browser/native_window.cc b/atom/browser/native_window.cc index 3b959263876..f99f783f160 100644 --- a/atom/browser/native_window.cc +++ b/atom/browser/native_window.cc @@ -79,9 +79,7 @@ NativeWindow::NativeWindow(content::WebContents* web_contents, options.Get(switches::kNodeIntegration, &node_integration_); // Read the web preferences. - scoped_ptr web_preferences(new mate::Dictionary); - if (options.Get(switches::kWebPreferences, web_preferences.get())) - web_preferences_.reset(web_preferences.release()); + options.Get(switches::kWebPreferences, &web_preferences_); // Read the zoom factor before any navigation. options.Get(switches::kZoomFactor, &zoom_factor_); @@ -329,29 +327,32 @@ void NativeWindow::AppendExtraCommandLineSwitches( } void NativeWindow::OverrideWebkitPrefs(const GURL& url, WebPreferences* prefs) { + if (web_preferences_.IsEmpty()) + return; + bool b; std::vector list; - if (!web_preferences_) - return; - if (web_preferences_->Get("javascript", &b)) + mate::Dictionary web_preferences(web_preferences_.isolate(), + web_preferences_.NewHandle()); + if (web_preferences.Get("javascript", &b)) prefs->javascript_enabled = b; - if (web_preferences_->Get("web-security", &b)) + if (web_preferences.Get("web-security", &b)) prefs->web_security_enabled = b; - if (web_preferences_->Get("images", &b)) + if (web_preferences.Get("images", &b)) prefs->images_enabled = b; - if (web_preferences_->Get("java", &b)) + if (web_preferences.Get("java", &b)) prefs->java_enabled = b; - if (web_preferences_->Get("text-areas-are-resizable", &b)) + if (web_preferences.Get("text-areas-are-resizable", &b)) prefs->text_areas_are_resizable = b; - if (web_preferences_->Get("webgl", &b)) + if (web_preferences.Get("webgl", &b)) prefs->experimental_webgl_enabled = b; - if (web_preferences_->Get("webaudio", &b)) + if (web_preferences.Get("webaudio", &b)) prefs->webaudio_enabled = b; - if (web_preferences_->Get("accelerated-compositing", &b)) + if (web_preferences.Get("accelerated-compositing", &b)) prefs->accelerated_compositing_enabled = b; - if (web_preferences_->Get("plugins", &b)) + if (web_preferences.Get("plugins", &b)) prefs->plugins_enabled = b; - if (web_preferences_->Get("extra-plugin-dirs", &list)) + if (web_preferences.Get("extra-plugin-dirs", &list)) for (size_t i = 0; i < list.size(); ++i) content::PluginService::GetInstance()->AddExtraPluginDir(list[i]); } diff --git a/atom/browser/native_window.h b/atom/browser/native_window.h index d77e761a0a8..fdb7fa676f8 100644 --- a/atom/browser/native_window.h +++ b/atom/browser/native_window.h @@ -19,6 +19,7 @@ #include "atom/browser/ui/accelerator_util.h" #include "content/public/browser/notification_registrar.h" #include "content/public/browser/notification_observer.h" +#include "native_mate/scoped_persistent.h" #include "vendor/brightray/browser/default_web_contents_delegate.h" #include "vendor/brightray/browser/inspectable_web_contents_delegate.h" #include "vendor/brightray/browser/inspectable_web_contents_impl.h" @@ -290,7 +291,7 @@ class NativeWindow : public brightray::DefaultWebContentsDelegate, base::CancelableClosure window_unresposive_closure_; // Web preferences. - scoped_ptr web_preferences_; + mate::ScopedPersistent web_preferences_; // Page's default zoom factor. double zoom_factor_; diff --git a/spec/static/main.js b/spec/static/main.js index 5b0817cca2f..af9c0fdd0d9 100644 --- a/spec/static/main.js +++ b/spec/static/main.js @@ -139,7 +139,10 @@ app.on('ready', function() { title: 'atom-shell tests', show: false, width: 800, - height: 600 + height: 600, + 'web-preferences': { + javascript: true // Test whether web-preferences crashes. + }, }); window.loadUrl('file://' + __dirname + '/index.html'); window.on('unresponsive', function() { diff --git a/vendor/native_mate b/vendor/native_mate index 14c851e9f88..3d713baa4c3 160000 --- a/vendor/native_mate +++ b/vendor/native_mate @@ -1 +1 @@ -Subproject commit 14c851e9f887a09ac3e055aacb930b0b3c690df4 +Subproject commit 3d713baa4c33baebfac82b242e8897504592c590