summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJack Hou <jackhou@chromium.org>2015-03-05 14:24:03 +1100
committerJack Hou <jackhou@chromium.org>2015-03-05 03:26:00 +0000
commit25321827e66b726b7adb66d9fe2b64723550e5c9 (patch)
treeb14fbc103cf1b5dd4304d4c60cf6fcdd65edb756
parente5a14ee5c748b247dc0f055850d692eaaa7ff10a (diff)
downloadchromium_src-25321827e66b726b7adb66d9fe2b64723550e5c9.zip
chromium_src-25321827e66b726b7adb66d9fe2b64723550e5c9.tar.gz
chromium_src-25321827e66b726b7adb66d9fe2b64723550e5c9.tar.bz2
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} (cherry picked from commit 0e3bba803a97b1a649fd9359c19fc0356e2da684) TBR=benwells@chromium.org Review URL: https://codereview.chromium.org/980773002 Cr-Commit-Position: refs/branch-heads/2311@{#146} Cr-Branched-From: 09b7de5dd7254947cd4306de907274fa63373d48-refs/heads/master@{#317474}
-rw-r--r--chrome/browser/apps/app_window_interactive_uitest.cc36
-rw-r--r--chrome/test/data/extensions/platform_apps/hidden_with_id/empty.html1
-rw-r--r--chrome/test/data/extensions/platform_apps/hidden_with_id/manifest.json10
-rw-r--r--chrome/test/data/extensions/platform_apps/hidden_with_id/test.js31
-rw-r--r--extensions/browser/api/app_window/app_window_api.cc2
5 files changed, 79 insertions, 1 deletions
diff --git a/chrome/browser/apps/app_window_interactive_uitest.cc b/chrome/browser/apps/app_window_interactive_uitest.cc
index 30247d7..7319903 100644
--- a/chrome/browser/apps/app_window_interactive_uitest.cc
+++ b/chrome/browser/apps/app_window_interactive_uitest.cc
@@ -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)
diff --git a/chrome/test/data/extensions/platform_apps/hidden_with_id/empty.html b/chrome/test/data/extensions/platform_apps/hidden_with_id/empty.html
new file mode 100644
index 0000000..aabcd1b
--- /dev/null
+++ b/chrome/test/data/extensions/platform_apps/hidden_with_id/empty.html
@@ -0,0 +1 @@
+<!-- This file intentionally left blank. -->
diff --git a/chrome/test/data/extensions/platform_apps/hidden_with_id/manifest.json b/chrome/test/data/extensions/platform_apps/hidden_with_id/manifest.json
new file mode 100644
index 0000000..098c347
--- /dev/null
+++ b/chrome/test/data/extensions/platform_apps/hidden_with_id/manifest.json
@@ -0,0 +1,10 @@
+{
+ "name": "Platform App Hidden With ID",
+ "version": "1",
+ "manifest_version": 2,
+ "app": {
+ "background": {
+ "scripts": ["test.js"]
+ }
+ }
+}
diff --git a/chrome/test/data/extensions/platform_apps/hidden_with_id/test.js b/chrome/test/data/extensions/platform_apps/hidden_with_id/test.js
new file mode 100644
index 0000000..91ccea0
--- /dev/null
+++ b/chrome/test/data/extensions/platform_apps/hidden_with_id/test.js
@@ -0,0 +1,31 @@
+// 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();
+});
diff --git a/extensions/browser/api/app_window/app_window_api.cc b/extensions/browser/api/app_window/app_window_api.cc
index f8cd74a..3f5123f 100644
--- a/extensions/browser/api/app_window/app_window_api.cc
+++ b/extensions/browser/api/app_window/app_window_api.cc
@@ -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