Commit 0e3bba80 authored by jackhou's avatar jackhou Committed by Commit bot

Fix hiding behavior when creating app windows.

This ensures that re-creating a window with the same id shows that
window if it already exists. This was broken in:
https://codereview.chromium.org/417433002

BUG=461081

Review URL: https://codereview.chromium.org/958923004

Cr-Commit-Position: refs/heads/master@{#319013}
parent 8c522ea0
......@@ -461,6 +461,42 @@ IN_PROC_BROWSER_TEST_F(AppWindowInteractiveTest, TestDrawAttention) {
ASSERT_TRUE(RunAppWindowInteractiveTest("testDrawAttention")) << message_;
}
IN_PROC_BROWSER_TEST_F(AppWindowInteractiveTest, TestCreateHidden) {
// Created hidden both times.
{
ExtensionTestMessageListener launched_listener("Launched", true);
LoadAndLaunchPlatformApp("hidden_with_id", &launched_listener);
EXPECT_TRUE(launched_listener.WaitUntilSatisfied());
ExtensionTestMessageListener create_listener_1("Launched", true);
launched_listener.Reply("createHidden");
EXPECT_TRUE(create_listener_1.WaitUntilSatisfied());
AppWindow* app_window = GetFirstAppWindow();
EXPECT_TRUE(app_window->is_hidden());
ExtensionTestMessageListener create_listener_2("Launched", false);
create_listener_1.Reply("createHidden");
EXPECT_TRUE(create_listener_2.WaitUntilSatisfied());
EXPECT_TRUE(app_window->is_hidden());
app_window->GetBaseWindow()->Close();
}
// Created hidden, then visible. The second create should show the window.
{
ExtensionTestMessageListener launched_listener("Launched", true);
LoadAndLaunchPlatformApp("hidden_with_id", &launched_listener);
EXPECT_TRUE(launched_listener.WaitUntilSatisfied());
ExtensionTestMessageListener create_listener_1("Launched", true);
launched_listener.Reply("createHidden");
EXPECT_TRUE(create_listener_1.WaitUntilSatisfied());
AppWindow* app_window = GetFirstAppWindow();
EXPECT_TRUE(app_window->is_hidden());
ExtensionTestMessageListener create_listener_2("Launched", false);
create_listener_1.Reply("createVisible");
EXPECT_TRUE(create_listener_2.WaitUntilSatisfied());
EXPECT_FALSE(app_window->is_hidden());
app_window->GetBaseWindow()->Close();
}
}
// Only Linux and Windows use keep-alive to determine when to shut down.
#if defined(OS_LINUX) || defined(OS_WIN)
......
{
"name": "Platform App Hidden With ID",
"version": "1",
"manifest_version": 2,
"app": {
"background": {
"scripts": ["test.js"]
}
}
}
// Copyright 2015 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
function sendLaunchedAndRunReply() {
chrome.test.sendMessage('Launched', function (reply) {
if (reply)
window[reply]();
});
}
function createHidden() {
chrome.app.window.create('empty.html', {
id: 'hidden_with_id',
hidden: true,
}, function () {
sendLaunchedAndRunReply();
});
}
function createVisible() {
chrome.app.window.create('empty.html', {
id: 'hidden_with_id',
}, function () {
sendLaunchedAndRunReply();
});
}
chrome.app.runtime.onLaunched.addListener(function() {
sendLaunchedAndRunReply();
});
......@@ -182,7 +182,7 @@ bool AppWindowCreateFunction::RunAsync() {
view_id = created_view->GetRoutingID();
}
if (options->hidden.get() && !*options->hidden.get()) {
if (!options->hidden.get() || !*options->hidden.get()) {
if (options->focused.get() && !*options->focused.get())
window->Show(AppWindow::SHOW_INACTIVE);
else
......
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