Commit 5f188d95 authored by Mike Dougherty's avatar Mike Dougherty Committed by Commit Bot

Add kContextMenuElementPostMessage feature flag.

This feature flag will be used for adding Context Menu support to
iFrames by using the PostMessage WebKit API to return the found element.
(Instead of directly returning the element details from
__gCrWeb.getElementFromPoint)

Bug: 228355
Cq-Include-Trybots: master.tryserver.chromium.mac:ios-simulator-cronet;master.tryserver.chromium.mac:ios-simulator-full-configs
Change-Id: I17fec9afb74e7fe5f7b2818902f4b872ba8d445a
Reviewed-on: https://chromium-review.googlesource.com/896546
Commit-Queue: Mike Dougherty <michaeldo@chromium.org>
Reviewed-by: default avatarEugene But <eugenebut@chromium.org>
Cr-Commit-Position: refs/heads/master@{#533983}
parent c6e766e9
...@@ -235,7 +235,11 @@ const flags_ui::FeatureEntry kFeatureEntries[] = { ...@@ -235,7 +235,11 @@ const flags_ui::FeatureEntry kFeatureEntries[] = {
{"ui-refresh-phase-1", flag_descriptions::kUIRefreshPhase1Name, {"ui-refresh-phase-1", flag_descriptions::kUIRefreshPhase1Name,
flag_descriptions::kUIRefreshPhase1Description, flags_ui::kOsIos, flag_descriptions::kUIRefreshPhase1Description, flags_ui::kOsIos,
FEATURE_VALUE_TYPE(kUIRefreshPhase1)}, FEATURE_VALUE_TYPE(kUIRefreshPhase1)},
{"context-menu-element-post-message",
flag_descriptions::kContextMenuElementPostMessageName,
flag_descriptions::kContextMenuElementPostMessageDescription,
flags_ui::kOsIos,
FEATURE_VALUE_TYPE(web::features::kContextMenuElementPostMessage)},
}; };
// Add all switches from experimental flags to |command_line|. // Add all switches from experimental flags to |command_line|.
......
...@@ -18,6 +18,7 @@ source_set("eg_tests") { ...@@ -18,6 +18,7 @@ source_set("eg_tests") {
"//ios/testing/earl_grey:earl_grey_support", "//ios/testing/earl_grey:earl_grey_support",
"//ios/third_party/earl_grey:earl_grey+link", "//ios/third_party/earl_grey:earl_grey+link",
"//ios/web:earl_grey_test_support", "//ios/web:earl_grey_test_support",
"//ios/web/public",
"//ios/web/public/test/http_server", "//ios/web/public/test/http_server",
"//url", "//url",
] ]
......
...@@ -7,6 +7,7 @@ ...@@ -7,6 +7,7 @@
#import <XCTest/XCTest.h> #import <XCTest/XCTest.h>
#include "base/ios/ios_util.h" #include "base/ios/ios_util.h"
#include "base/test/scoped_feature_list.h"
#include "ios/chrome/browser/ui/ui_util.h" #include "ios/chrome/browser/ui/ui_util.h"
#include "ios/chrome/grit/ios_strings.h" #include "ios/chrome/grit/ios_strings.h"
#import "ios/chrome/test/app/chrome_test_util.h" #import "ios/chrome/test/app/chrome_test_util.h"
...@@ -20,6 +21,7 @@ ...@@ -20,6 +21,7 @@
#import "ios/chrome/test/earl_grey/chrome_test_case.h" #import "ios/chrome/test/earl_grey/chrome_test_case.h"
#import "ios/testing/earl_grey/disabled_test_macros.h" #import "ios/testing/earl_grey/disabled_test_macros.h"
#import "ios/testing/wait_util.h" #import "ios/testing/wait_util.h"
#import "ios/web/public/features.h"
#import "ios/web/public/test/earl_grey/web_view_matchers.h" #import "ios/web/public/test/earl_grey/web_view_matchers.h"
#import "ios/web/public/test/http_server/http_server.h" #import "ios/web/public/test/http_server/http_server.h"
#import "ios/web/public/test/http_server/http_server_util.h" #import "ios/web/public/test/http_server/http_server_util.h"
...@@ -124,8 +126,13 @@ void SelectTabAtIndexInCurrentMode(NSUInteger index) { ...@@ -124,8 +126,13 @@ void SelectTabAtIndexInCurrentMode(NSUInteger index) {
} }
// Tests that selecting "Open Image" from the context menu properly opens the // Tests that selecting "Open Image" from the context menu properly opens the
// image in the current tab. // image in the current tab. (With the kContextMenuElementPostMessage feature
// disabled.)
- (void)testOpenImageInCurrentTabFromContextMenu { - (void)testOpenImageInCurrentTabFromContextMenu {
base::test::ScopedFeatureList scopedFeatureList;
scopedFeatureList.InitAndDisableFeature(
web::features::kContextMenuElementPostMessage);
GURL pageURL = web::test::HttpServer::MakeUrl(kUrlChromiumLogoPage); GURL pageURL = web::test::HttpServer::MakeUrl(kUrlChromiumLogoPage);
GURL imageURL = web::test::HttpServer::MakeUrl(kUrlChromiumLogoImg); GURL imageURL = web::test::HttpServer::MakeUrl(kUrlChromiumLogoImg);
web::test::SetUpFileBasedHttpServer(); web::test::SetUpFileBasedHttpServer();
...@@ -143,8 +150,13 @@ void SelectTabAtIndexInCurrentMode(NSUInteger index) { ...@@ -143,8 +150,13 @@ void SelectTabAtIndexInCurrentMode(NSUInteger index) {
} }
// Tests that selecting "Open Image in New Tab" from the context menu properly // Tests that selecting "Open Image in New Tab" from the context menu properly
// opens the image in a new background tab. // opens the image in a new background tab. (With the
// kContextMenuElementPostMessage feature disabled.)
- (void)testOpenImageInNewTabFromContextMenu { - (void)testOpenImageInNewTabFromContextMenu {
base::test::ScopedFeatureList scopedFeatureList;
scopedFeatureList.InitAndDisableFeature(
web::features::kContextMenuElementPostMessage);
GURL pageURL = web::test::HttpServer::MakeUrl(kUrlChromiumLogoPage); GURL pageURL = web::test::HttpServer::MakeUrl(kUrlChromiumLogoPage);
GURL imageURL = web::test::HttpServer::MakeUrl(kUrlChromiumLogoImg); GURL imageURL = web::test::HttpServer::MakeUrl(kUrlChromiumLogoImg);
web::test::SetUpFileBasedHttpServer(); web::test::SetUpFileBasedHttpServer();
...@@ -163,8 +175,13 @@ void SelectTabAtIndexInCurrentMode(NSUInteger index) { ...@@ -163,8 +175,13 @@ void SelectTabAtIndexInCurrentMode(NSUInteger index) {
[ChromeEarlGrey waitForMainTabCount:2]; [ChromeEarlGrey waitForMainTabCount:2];
} }
// Tests "Open in New Tab" on context menu. // Tests "Open in New Tab" on context menu. (With the
// kContextMenuElementPostMessage feature disabled.)
- (void)testContextMenuOpenInNewTab { - (void)testContextMenuOpenInNewTab {
base::test::ScopedFeatureList scopedFeatureList;
scopedFeatureList.InitAndDisableFeature(
web::features::kContextMenuElementPostMessage);
// Set up test simple http server. // Set up test simple http server.
std::map<GURL, std::string> responses; std::map<GURL, std::string> responses;
GURL initialURL = web::test::HttpServer::MakeUrl(kUrlInitialPage); GURL initialURL = web::test::HttpServer::MakeUrl(kUrlInitialPage);
...@@ -191,8 +208,13 @@ void SelectTabAtIndexInCurrentMode(NSUInteger index) { ...@@ -191,8 +208,13 @@ void SelectTabAtIndexInCurrentMode(NSUInteger index) {
[ChromeEarlGrey waitForMainTabCount:2]; [ChromeEarlGrey waitForMainTabCount:2];
} }
// Tests that the context menu is displayed for an image url. // Tests that the context menu is displayed for an image url. (With the
// kContextMenuElementPostMessage feature disabled.)
- (void)testContextMenuDisplayedOnImage { - (void)testContextMenuDisplayedOnImage {
base::test::ScopedFeatureList scopedFeatureList;
scopedFeatureList.InitAndDisableFeature(
web::features::kContextMenuElementPostMessage);
GURL imageURL = web::test::HttpServer::MakeUrl(kUrlChromiumLogoImg); GURL imageURL = web::test::HttpServer::MakeUrl(kUrlChromiumLogoImg);
web::test::SetUpFileBasedHttpServer(); web::test::SetUpFileBasedHttpServer();
[ChromeEarlGrey loadURL:imageURL]; [ChromeEarlGrey loadURL:imageURL];
......
...@@ -34,6 +34,13 @@ const char kContextualSearch[] = "Contextual Search"; ...@@ -34,6 +34,13 @@ const char kContextualSearch[] = "Contextual Search";
const char kContextualSearchDescription[] = const char kContextualSearchDescription[] =
"Whether or not Contextual Search is enabled."; "Whether or not Contextual Search is enabled.";
const char kContextMenuElementPostMessageName[] =
"Context Menu Element Post Message";
const char kContextMenuElementPostMessageDescription[] =
"When enabled, the DOM element for the Context Menu is returned using a "
"webkit postMessage call instead of directly returned from the JavaScript "
"function.";
const char kDragAndDropName[] = "Drag and Drop"; const char kDragAndDropName[] = "Drag and Drop";
const char kDragAndDropDescription[] = "Enable support for drag and drop."; const char kDragAndDropDescription[] = "Enable support for drag and drop.";
......
...@@ -28,6 +28,11 @@ extern const char kClippingTextfieldDescription[]; ...@@ -28,6 +28,11 @@ extern const char kClippingTextfieldDescription[];
extern const char kContextualSearch[]; extern const char kContextualSearch[];
extern const char kContextualSearchDescription[]; extern const char kContextualSearchDescription[];
// Title and description for the flag to enable returning the DOM element for
// context menu using webkit postMessage API.
extern const char kContextMenuElementPostMessageName[];
extern const char kContextMenuElementPostMessageDescription[];
// Title and description for the flag to enable drag and drop. // Title and description for the flag to enable drag and drop.
extern const char kDragAndDropName[]; extern const char kDragAndDropName[];
extern const char kDragAndDropDescription[]; extern const char kDragAndDropDescription[];
......
...@@ -7,6 +7,9 @@ ...@@ -7,6 +7,9 @@
namespace web { namespace web {
namespace features { namespace features {
const base::Feature kContextMenuElementPostMessage{
"ContextMenuElementPostMessage", base::FEATURE_DISABLED_BY_DEFAULT};
const base::Feature kSlimNavigationManager{"SlimNavigationManager", const base::Feature kSlimNavigationManager{"SlimNavigationManager",
base::FEATURE_DISABLED_BY_DEFAULT}; base::FEATURE_DISABLED_BY_DEFAULT};
......
...@@ -10,6 +10,9 @@ ...@@ -10,6 +10,9 @@
namespace web { namespace web {
namespace features { namespace features {
// Used to enable asynchronous DOM element fetching for context menu.
extern const base::Feature kContextMenuElementPostMessage;
// Used to enable the WKBackForwardList based navigation manager. // Used to enable the WKBackForwardList based navigation manager.
extern const base::Feature kSlimNavigationManager; extern const base::Feature kSlimNavigationManager;
......
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