Commit b1dcbc88 authored by Robert Sesek's avatar Robert Sesek Committed by Commit Bot

Remove flag for launched AppleScriptExecuteJavaScriptMenuItem feature.

Bug: 829021
Change-Id: I19b5f71e8c43541459f8429cbdfe36d9823d7b81
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1742568
Commit-Queue: Robert Sesek <rsesek@chromium.org>
Reviewed-by: default avatarElly Fong-Jones <ellyjones@chromium.org>
Cr-Commit-Position: refs/heads/master@{#685309}
parent 5318d265
...@@ -82,7 +82,6 @@ ...@@ -82,7 +82,6 @@
#include "chrome/browser/ui/user_manager.h" #include "chrome/browser/ui/user_manager.h"
#include "chrome/browser/web_applications/components/web_app_helpers.h" #include "chrome/browser/web_applications/components/web_app_helpers.h"
#include "chrome/browser/web_applications/components/web_app_shortcut_mac.h" #include "chrome/browser/web_applications/components/web_app_shortcut_mac.h"
#include "chrome/common/chrome_features.h"
#include "chrome/common/chrome_paths_internal.h" #include "chrome/common/chrome_paths_internal.h"
#include "chrome/common/chrome_switches.h" #include "chrome/common/chrome_switches.h"
#include "chrome/common/cloud_print/cloud_print_class_mac.h" #include "chrome/common/cloud_print/cloud_print_class_mac.h"
...@@ -427,18 +426,6 @@ static base::mac::ScopedObjCClassSwizzler* g_swizzle_imk_input_session; ...@@ -427,18 +426,6 @@ static base::mac::ScopedObjCClassSwizzler* g_swizzle_imk_input_session;
} }
[self initShareMenu]; [self initShareMenu];
// Remove "Enable Javascript in Apple Events" if the feature is disabled.
if (!base::FeatureList::IsEnabled(
features::kAppleScriptExecuteJavaScriptMenuItem)) {
NSMenu* mainMenu = [NSApp mainMenu];
NSMenu* viewMenu = [[mainMenu itemWithTag:IDC_VIEW_MENU] submenu];
NSMenu* devMenu = [[viewMenu itemWithTag:IDC_DEVELOPER_MENU] submenu];
NSMenuItem* javascriptAppleEventItem =
[devMenu itemWithTag:IDC_TOGGLE_JAVASCRIPT_APPLE_EVENTS];
if (javascriptAppleEventItem)
[devMenu removeItem:javascriptAppleEventItem];
}
} }
- (void)applicationWillHide:(NSNotification*)notification { - (void)applicationWillHide:(NSNotification*)notification {
......
...@@ -11,7 +11,6 @@ ...@@ -11,7 +11,6 @@
#include "base/strings/sys_string_conversions.h" #include "base/strings/sys_string_conversions.h"
#include "base/values.h" #include "base/values.h"
#include "chrome/browser/profiles/profile.h" #include "chrome/browser/profiles/profile.h"
#include "chrome/common/chrome_features.h"
#include "chrome/common/pref_names.h" #include "chrome/common/pref_names.h"
#include "components/prefs/pref_service.h" #include "components/prefs/pref_service.h"
...@@ -113,10 +112,6 @@ NSAppleEventDescriptor* ValueToAppleEventDescriptor(const base::Value* value) { ...@@ -113,10 +112,6 @@ NSAppleEventDescriptor* ValueToAppleEventDescriptor(const base::Value* value) {
bool IsJavaScriptEnabledForProfile(Profile* profile) { bool IsJavaScriptEnabledForProfile(Profile* profile) {
DCHECK(profile); DCHECK(profile);
if (!base::FeatureList::IsEnabled(
features::kAppleScriptExecuteJavaScriptMenuItem))
return YES;
PrefService* prefs = profile->GetPrefs(); PrefService* prefs = profile->GetPrefs();
return prefs->GetBoolean(prefs::kAllowJavascriptAppleEvents); return prefs->GetBoolean(prefs::kAllowJavascriptAppleEvents);
} }
......
...@@ -6,12 +6,10 @@ ...@@ -6,12 +6,10 @@
#include "base/mac/scoped_nsobject.h" #include "base/mac/scoped_nsobject.h"
#include "base/strings/sys_string_conversions.h" #include "base/strings/sys_string_conversions.h"
#include "base/test/scoped_feature_list.h"
#include "chrome/browser/profiles/profile.h" #include "chrome/browser/profiles/profile.h"
#import "chrome/browser/ui/cocoa/applescript/bookmark_applescript_utils_test.h" #import "chrome/browser/ui/cocoa/applescript/bookmark_applescript_utils_test.h"
#import "chrome/browser/ui/cocoa/applescript/bookmark_item_applescript.h" #import "chrome/browser/ui/cocoa/applescript/bookmark_item_applescript.h"
#import "chrome/browser/ui/cocoa/applescript/error_applescript.h" #import "chrome/browser/ui/cocoa/applescript/error_applescript.h"
#include "chrome/common/chrome_features.h"
#include "chrome/common/pref_names.h" #include "chrome/common/pref_names.h"
#include "components/prefs/pref_service.h" #include "components/prefs/pref_service.h"
#include "testing/gtest/include/gtest/gtest.h" #include "testing/gtest/include/gtest/gtest.h"
...@@ -47,17 +45,11 @@ IN_PROC_BROWSER_TEST_F(BookmarkItemAppleScriptTest, GetAndSetURL) { ...@@ -47,17 +45,11 @@ IN_PROC_BROWSER_TEST_F(BookmarkItemAppleScriptTest, GetAndSetURL) {
[fakeScriptCommand.get() scriptErrorNumber]); [fakeScriptCommand.get() scriptErrorNumber]);
} }
// Tests setting a Javascript URL when the "Allow Javascript in Apple // Creating bookmarks with javascript: URLs is controlled by a preference.
// Events" feature is enabled. An error should be returned if preference IN_PROC_BROWSER_TEST_F(BookmarkItemAppleScriptTest, GetAndSetJavascriptURL) {
// value is set to false.
IN_PROC_BROWSER_TEST_F(BookmarkItemAppleScriptTest,
GetAndSetJavascriptURLFeatureEnabled) {
base::test::ScopedFeatureList feature_list;
feature_list.InitAndEnableFeature(
features::kAppleScriptExecuteJavaScriptMenuItem);
PrefService* prefs = profile()->GetPrefs(); PrefService* prefs = profile()->GetPrefs();
prefs->SetBoolean(prefs::kAllowJavascriptAppleEvents, false); prefs->SetBoolean(prefs::kAllowJavascriptAppleEvents, false);
NSArray* bookmarkItems = [bookmarkBar_.get() bookmarkItems]; NSArray* bookmarkItems = [bookmarkBar_.get() bookmarkItems];
BookmarkItemAppleScript* item1 = [bookmarkItems objectAtIndex:0]; BookmarkItemAppleScript* item1 = [bookmarkItems objectAtIndex:0];
...@@ -73,30 +65,4 @@ IN_PROC_BROWSER_TEST_F(BookmarkItemAppleScriptTest, ...@@ -73,30 +65,4 @@ IN_PROC_BROWSER_TEST_F(BookmarkItemAppleScriptTest,
GURL(base::SysNSStringToUTF8([item1 URL]))); GURL(base::SysNSStringToUTF8([item1 URL])));
} }
// Tests setting a Javascript URL when the "Allow Javascript in Apple
// Events" feature is enabled. Doing this should should succeed regardless
// of the preference value.
IN_PROC_BROWSER_TEST_F(BookmarkItemAppleScriptTest,
GetAndSetJavascriptURLFeatureDisabled) {
base::test::ScopedFeatureList feature_list;
feature_list.InitAndDisableFeature(
features::kAppleScriptExecuteJavaScriptMenuItem);
PrefService* prefs = profile()->GetPrefs();
prefs->SetBoolean(prefs::kAllowJavascriptAppleEvents, false);
NSArray* bookmarkItems = [bookmarkBar_.get() bookmarkItems];
BookmarkItemAppleScript* item1 = [bookmarkItems objectAtIndex:0];
base::scoped_nsobject<FakeScriptCommand> fakeScriptCommand(
[[FakeScriptCommand alloc] init]);
[item1 setURL:@"javascript:alert('hi');"];
EXPECT_EQ(GURL("javascript:alert('hi');"),
GURL(base::SysNSStringToUTF8([item1 URL])));
prefs->SetBoolean(prefs::kAllowJavascriptAppleEvents, true);
[item1 setURL:@"javascript:alert('hi');"];
EXPECT_EQ(GURL("javascript:alert('hi');"),
GURL(base::SysNSStringToUTF8([item1 URL])));
}
} // namespace } // namespace
...@@ -6,14 +6,12 @@ ...@@ -6,14 +6,12 @@
#include "base/mac/scoped_nsobject.h" #include "base/mac/scoped_nsobject.h"
#include "base/strings/sys_string_conversions.h" #include "base/strings/sys_string_conversions.h"
#include "base/test/scoped_feature_list.h"
#include "chrome/browser/profiles/profile.h" #include "chrome/browser/profiles/profile.h"
#include "chrome/browser/ui/browser.h" #include "chrome/browser/ui/browser.h"
#import "chrome/browser/ui/cocoa/applescript/bookmark_applescript_utils_test.h" #import "chrome/browser/ui/cocoa/applescript/bookmark_applescript_utils_test.h"
#import "chrome/browser/ui/cocoa/applescript/error_applescript.h" #import "chrome/browser/ui/cocoa/applescript/error_applescript.h"
#import "chrome/browser/ui/cocoa/applescript/tab_applescript.h" #import "chrome/browser/ui/cocoa/applescript/tab_applescript.h"
#include "chrome/browser/ui/tabs/tab_strip_model.h" #include "chrome/browser/ui/tabs/tab_strip_model.h"
#include "chrome/common/chrome_features.h"
#include "chrome/common/pref_names.h" #include "chrome/common/pref_names.h"
#include "chrome/test/base/in_process_browser_test.h" #include "chrome/test/base/in_process_browser_test.h"
#include "components/prefs/pref_service.h" #include "components/prefs/pref_service.h"
...@@ -46,41 +44,13 @@ IN_PROC_BROWSER_TEST_F(TabAppleScriptTest, Creation) { ...@@ -46,41 +44,13 @@ IN_PROC_BROWSER_TEST_F(TabAppleScriptTest, Creation) {
EXPECT_TRUE(tab_applescript); EXPECT_TRUE(tab_applescript);
} }
// Tests the Execute Javascript command when the "Allow Javascript in Apple IN_PROC_BROWSER_TEST_F(TabAppleScriptTest, ExecuteJavascript) {
// Events" feature is disabled. The command should not return an error.
IN_PROC_BROWSER_TEST_F(TabAppleScriptTest, ExecuteJavascriptFeatureDisabled) {
Profile* profile = browser()->profile(); Profile* profile = browser()->profile();
content::WebContents* web_contents = content::WebContents* web_contents =
browser()->tab_strip_model()->GetActiveWebContents(); browser()->tab_strip_model()->GetActiveWebContents();
base::scoped_nsobject<TabAppleScript> tab_applescript( base::scoped_nsobject<TabAppleScript> tab_applescript(
[[TabAppleScript alloc] initWithWebContents:web_contents]); [[TabAppleScript alloc] initWithWebContents:web_contents]);
base::test::ScopedFeatureList feature_list;
feature_list.InitAndDisableFeature(
features::kAppleScriptExecuteJavaScriptMenuItem);
PrefService* prefs = profile->GetPrefs();
prefs->SetBoolean(prefs::kAllowJavascriptAppleEvents, false);
EXPECT_EQ(0, ExecuteJavascriptCommand(tab_applescript.get()));
prefs->SetBoolean(prefs::kAllowJavascriptAppleEvents, true);
EXPECT_EQ(0, ExecuteJavascriptCommand(tab_applescript.get()));
}
// Tests the Execute Javascript command when the "Allow Javascript in Apple
// Events" feature is disabled. The command should return an error if the menu
// item is turned off.
IN_PROC_BROWSER_TEST_F(TabAppleScriptTest, ExecuteJavascriptFeatureEnabled) {
Profile* profile = browser()->profile();
content::WebContents* web_contents =
browser()->tab_strip_model()->GetActiveWebContents();
base::scoped_nsobject<TabAppleScript> tab_applescript(
[[TabAppleScript alloc] initWithWebContents:web_contents]);
base::test::ScopedFeatureList feature_list;
feature_list.InitAndEnableFeature(
features::kAppleScriptExecuteJavaScriptMenuItem);
PrefService* prefs = profile->GetPrefs(); PrefService* prefs = profile->GetPrefs();
prefs->SetBoolean(prefs::kAllowJavascriptAppleEvents, false); prefs->SetBoolean(prefs::kAllowJavascriptAppleEvents, false);
EXPECT_EQ(AppleScript::ErrorCode::errJavaScriptUnsupported, EXPECT_EQ(AppleScript::ErrorCode::errJavaScriptUnsupported,
......
...@@ -35,10 +35,6 @@ const base::Feature kApkWebAppInstalls{"ApkWebAppInstalls", ...@@ -35,10 +35,6 @@ const base::Feature kApkWebAppInstalls{"ApkWebAppInstalls",
#endif // defined(OS_CHROMEOS) #endif // defined(OS_CHROMEOS)
#if defined(OS_MACOSX) #if defined(OS_MACOSX)
// Enables the menu item for Javascript execution via AppleScript.
const base::Feature kAppleScriptExecuteJavaScriptMenuItem{
"AppleScriptExecuteJavaScriptMenuItem", base::FEATURE_ENABLED_BY_DEFAULT};
// Enables the "this OS is obsolete" infobar on Mac 10.9. // Enables the "this OS is obsolete" infobar on Mac 10.9.
// TODO(ellyjones): Remove this after the last 10.9 release. // TODO(ellyjones): Remove this after the last 10.9 release.
const base::Feature kShow10_9ObsoleteInfobar{"Show109ObsoleteInfobar", const base::Feature kShow10_9ObsoleteInfobar{"Show109ObsoleteInfobar",
......
...@@ -36,8 +36,6 @@ extern const base::Feature kApkWebAppInstalls; ...@@ -36,8 +36,6 @@ extern const base::Feature kApkWebAppInstalls;
#if defined(OS_MACOSX) #if defined(OS_MACOSX)
COMPONENT_EXPORT(CHROME_FEATURES) COMPONENT_EXPORT(CHROME_FEATURES)
extern const base::Feature kAppleScriptExecuteJavaScriptMenuItem;
COMPONENT_EXPORT(CHROME_FEATURES)
extern const base::Feature kShow10_9ObsoleteInfobar; extern const base::Feature kShow10_9ObsoleteInfobar;
COMPONENT_EXPORT(CHROME_FEATURES) extern const base::Feature kViewsTaskManager; COMPONENT_EXPORT(CHROME_FEATURES) extern const base::Feature kViewsTaskManager;
#endif // defined(OS_MACOSX) #endif // defined(OS_MACOSX)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment