Commit d63e04cb authored by Stephane Zermatten's avatar Stephane Zermatten Committed by Commit Bot

[Autofill Assistant] Run a single autostart script, ignoring others

runnable scripts.

Before this patch, the controller only run an autostart script if it was
the single runnable script. This means that the presence of
non-autostart, but runnable script prevents autostart from triggering.

This was a misunderstanding. As long as there is exactly one autostart
script, it must be started, and other runnable scripts can be ignored.

After this patch, as long as there is exactly one autostart script, it
is run.

Bug: 806868
Change-Id: Id60223064bc3ed8fc364f7f9a8ae1a4ed4ef921b
Reviewed-on: https://chromium-review.googlesource.com/c/1264658Reviewed-by: default avatarGanggui Tang <gogerald@chromium.org>
Commit-Queue: Ganggui Tang <gogerald@chromium.org>
Cr-Commit-Position: refs/heads/master@{#597210}
parent 7895d362
...@@ -261,13 +261,22 @@ void Controller::OnRunnableScriptsChanged( ...@@ -261,13 +261,22 @@ void Controller::OnRunnableScriptsChanged(
return; return;
// Under specific conditions, we can directly run a script without first // Under specific conditions, we can directly run a script without first
// displaying it. This is meant to work only at the very beginning, when // displaying it. This is meant to work only at the very beginning, when no
// no scripts have run, there has been no interaction with the webpage and // scripts have run, there has been no interaction with the webpage and only
// only if there's exactly one runnable script, flagged for autostart. // if there's exactly one runnable autostartable script.
if (allow_autostart_ && runnable_scripts.size() == 1 && if (allow_autostart_) {
runnable_scripts[0].autostart) { int autostart_count = 0;
OnScriptSelected(runnable_scripts[0].path); std::string autostart_path;
return; for (const auto& script : runnable_scripts) {
if (script.autostart) {
autostart_count++;
autostart_path = script.path;
}
}
if (autostart_count == 1) {
OnScriptSelected(autostart_path);
return;
}
} }
GetUiController()->UpdateScripts(runnable_scripts); GetUiController()->UpdateScripts(runnable_scripts);
......
...@@ -275,12 +275,14 @@ TEST_F(ControllerTest, ForwardParameters) { ...@@ -275,12 +275,14 @@ TEST_F(ControllerTest, ForwardParameters) {
TEST_F(ControllerTest, Autostart) { TEST_F(ControllerTest, Autostart) {
SupportsScriptResponseProto script_response; SupportsScriptResponseProto script_response;
AddRunnableScript(&script_response, "runnable") AddRunnableScript(&script_response, "runnable");
AddRunnableScript(&script_response, "autostart")
->mutable_presentation() ->mutable_presentation()
->set_autostart(true); ->set_autostart(true);
AddRunnableScript(&script_response, "alsorunnable");
SetNextScriptResponse(script_response); SetNextScriptResponse(script_response);
EXPECT_CALL(*mock_service_, OnGetActions(StrEq("runnable"), _, _)) EXPECT_CALL(*mock_service_, OnGetActions(StrEq("autostart"), _, _))
.WillOnce(RunOnceCallback<2>(true, "")); .WillOnce(RunOnceCallback<2>(true, ""));
SimulateNavigateToUrl(GURL("http://a.example.com/path")); SimulateNavigateToUrl(GURL("http://a.example.com/path"));
......
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