Commit cfb653bb authored by Tricia Crichton's avatar Tricia Crichton Committed by Commit Bot

[ChromeDriver] Deprecate launchApp command

Prior to complete removal planned for m84, the LaunchApp command will be
rejected. As a temporary workaround, a new capability is added to give
access to LaunchApp when requested by users.

Bug: chromedriver:1778
Change-Id: I93f9aab5fca4593032b5876ddf2fbb52e50c7335
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2080782Reviewed-by: default avatarJohn Chen <johnchen@chromium.org>
Commit-Queue: Tricia Crichton <triciac@chromium.org>
Cr-Commit-Position: refs/heads/master@{#746139}
parent 36909610
......@@ -544,6 +544,9 @@ Status ParseChromeOptions(
// sent if not parsed correctly.
parser_map["w3c"] = base::Bind(&IgnoreCapability);
parser_map["useUnsupportedLaunchAppDeprecationWorkaround"] =
base::BindRepeating(&ParseBoolean, &capabilities->enable_launch_app);
if (is_android) {
parser_map["androidActivity"] =
base::Bind(&ParseString, &capabilities->android_activity);
......@@ -752,7 +755,8 @@ Capabilities::Capabilities()
detach(false),
extension_load_timeout(base::TimeDelta::FromSeconds(10)),
network_emulation_enabled(false),
use_automation_extension(true) {}
use_automation_extension(true),
enable_launch_app(false) {}
Capabilities::~Capabilities() {}
......
......@@ -186,6 +186,11 @@ struct Capabilities {
std::set<WebViewInfo::Type> window_types;
bool use_automation_extension;
// Temporary capability to enable LaunchApp command
// TODO remove with all LaunchApp code in m84.
// see https://crbug.com/chromedriver/1778
bool enable_launch_app;
};
bool GetChromeOptionsDictionary(const base::DictionaryValue& params,
......
......@@ -71,6 +71,7 @@ Session::Session(const std::string& id)
page_load_timeout(kDefaultPageLoadTimeout),
script_timeout(kDefaultScriptTimeout),
strict_file_interactability(false),
enable_launch_app(false),
click_count(0),
mouse_click_timestamp(base::TimeTicks::Now()) {}
......@@ -87,6 +88,7 @@ Session::Session(const std::string& id, std::unique_ptr<Chrome> chrome)
page_load_timeout(kDefaultPageLoadTimeout),
script_timeout(kDefaultScriptTimeout),
strict_file_interactability(false),
enable_launch_app(false),
click_count(0),
mouse_click_timestamp(base::TimeTicks::Now()) {}
......
......@@ -125,6 +125,12 @@ struct Session {
// |DevToolsEventListener|s owned by |chrome|.
std::vector<std::unique_ptr<CommandListener>> command_listeners;
bool strict_file_interactability;
// Temporary capability to enable LaunchApp command
// TODO remove with all LaunchApp code in m84.
// see https://crbug.com/chromedriver/1778
bool enable_launch_app;
std::string unhandled_prompt_behavior;
int click_count;
base::TimeTicks mouse_click_timestamp;
......
......@@ -358,6 +358,8 @@ Status ConfigureSession(Session* session,
session->w3c_compliant ? kDismissAndNotify : kIgnore;
}
session->enable_launch_app = capabilities->enable_launch_app;
session->implicit_wait = capabilities->implicit_wait_timeout;
session->page_load_timeout = capabilities->page_load_timeout;
session->script_timeout = capabilities->script_timeout;
......@@ -634,16 +636,21 @@ Status ExecuteGetCurrentWindowHandle(Session* session,
Status ExecuteLaunchApp(Session* session,
const base::DictionaryValue& params,
std::unique_ptr<base::Value>* value) {
if (!session->enable_launch_app) {
return Status(kUnsupportedOperation,
R"(LaunchApp command has been removed. See:
https://blog.chromium.org/2020/01/moving-forward-from-chrome-apps.html)");
}
std::string id;
if (!params.GetString("id", &id))
return Status(kInvalidArgument, "'id' must be a string");
ChromeDesktopImpl* desktop = NULL;
ChromeDesktopImpl* desktop = nullptr;
Status status = session->chrome->GetAsDesktop(&desktop);
if (status.IsError())
return status;
AutomationExtension* extension = NULL;
AutomationExtension* extension = nullptr;
status = desktop->GetAutomationExtension(&extension, session->w3c_compliant);
if (status.IsError())
return status;
......
......@@ -3538,7 +3538,9 @@ class ChromeExtensionsCapabilityTest(ChromeDriverBaseTestWithWebServer):
def testCanLaunchApp(self):
app_path = os.path.join(_TEST_DATA_DIR, 'test_app')
driver = self.CreateDriver(chrome_switches=['load-extension=%s' % app_path])
driver = self.CreateDriver(chrome_switches=['load-extension=%s' % app_path],
experimental_options=
{"useUnsupportedLaunchAppDeprecationWorkaround": True})
old_handles = driver.GetWindowHandles()
self.assertEqual(1, len(old_handles))
driver.LaunchApp('gegjcdcfeiojglhifpmibkadodekakpc')
......
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