summaryrefslogtreecommitdiffstats
path: root/chrome/test
diff options
context:
space:
mode:
authormlamouri@chromium.org <mlamouri@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-12-12 17:40:09 +0000
committermlamouri@chromium.org <mlamouri@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-12-12 17:40:09 +0000
commite0dbe525fe1fb7f6d084e90aaeca7a6f7c8c1ede (patch)
treeb8fbe81a11247e943cc00bfc2a82d60f4e059698 /chrome/test
parentc7a75cc0735a51dbec1e19167a3cb03f21b155bf (diff)
downloadchromium_src-e0dbe525fe1fb7f6d084e90aaeca7a6f7c8c1ede.zip
chromium_src-e0dbe525fe1fb7f6d084e90aaeca7a6f7c8c1ede.tar.gz
chromium_src-e0dbe525fe1fb7f6d084e90aaeca7a6f7c8c1ede.tar.bz2
Add a focused property to the options parameter in chrome.app.window.create().
BUG=316410 Review URL: https://codereview.chromium.org/101323005 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@240356 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/test')
-rw-r--r--chrome/test/data/extensions/platform_apps/window_api_interactive/manifest.json9
-rw-r--r--chrome/test/data/extensions/platform_apps/window_api_interactive/test.html8
-rw-r--r--chrome/test/data/extensions/platform_apps/window_api_interactive/test.js138
3 files changed, 155 insertions, 0 deletions
diff --git a/chrome/test/data/extensions/platform_apps/window_api_interactive/manifest.json b/chrome/test/data/extensions/platform_apps/window_api_interactive/manifest.json
new file mode 100644
index 0000000..327c7dc
--- /dev/null
+++ b/chrome/test/data/extensions/platform_apps/window_api_interactive/manifest.json
@@ -0,0 +1,9 @@
+{
+ "name": "Platform App Test: Window API Interative",
+ "version": "1",
+ "app": {
+ "background": {
+ "scripts": ["test.js"]
+ }
+ }
+}
diff --git a/chrome/test/data/extensions/platform_apps/window_api_interactive/test.html b/chrome/test/data/extensions/platform_apps/window_api_interactive/test.html
new file mode 100644
index 0000000..42fa1f8
--- /dev/null
+++ b/chrome/test/data/extensions/platform_apps/window_api_interactive/test.html
@@ -0,0 +1,8 @@
+<!DOCTYPE html>
+<html>
+<head>
+ <title>Window API Interactive Tests</title>
+</head>
+<body>
+</body>
+</html>
diff --git a/chrome/test/data/extensions/platform_apps/window_api_interactive/test.js b/chrome/test/data/extensions/platform_apps/window_api_interactive/test.js
new file mode 100644
index 0000000..ecff515
--- /dev/null
+++ b/chrome/test/data/extensions/platform_apps/window_api_interactive/test.js
@@ -0,0 +1,138 @@
+// Copyright 2013 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.
+
+var callbackPass = chrome.test.callbackPass;
+
+function testWindowGetsFocus(win) {
+ // If the window is already focused, we are done.
+ if (win.contentWindow.document.hasFocus()) {
+ chrome.test.assertTrue(win.contentWindow.document.hasFocus(),
+ "window has been focused");
+ win.close();
+ return;
+ }
+
+ // Otherwise, we wait for the focus event.
+ win.contentWindow.onfocus = callbackPass(function() {
+ chrome.test.assertTrue(win.contentWindow.document.hasFocus(),
+ "window has been focused");
+ win.close();
+ });
+}
+
+function testWindowNeverGetsFocus(win) {
+ win.contentWindow.onfocus = function() {
+ chrome.test.assertFalse(win.contentWindow.document.hasFocus(),
+ "window should not be focused");
+ win.close();
+ };
+
+ if (win.contentWindow.document.hasFocus()) {
+ chrome.test.assertFalse(win.contentWindow.document.hasFocus(),
+ "window should not be focused");
+ win.close();
+ return;
+ };
+
+ if (win.contentWindow.document.readyState == 'complete') {
+ chrome.test.assertFalse(win.contentWindow.document.hasFocus(),
+ "window should not be focused");
+ win.close();
+ return;
+ }
+
+ win.contentWindow.onload = callbackPass(function() {
+ chrome.test.assertFalse(win.contentWindow.document.hasFocus(),
+ "window should not be focused");
+ win.close();
+ });
+}
+
+function testCreate() {
+ chrome.test.runTests([
+ function createUnfocusedWindow() {
+ chrome.app.window.create('test.html', {
+ bounds: { width: 200, height: 200 },
+ focused: false
+ }, callbackPass(testWindowNeverGetsFocus));
+ },
+ function createTwiceUnfocused() {
+ chrome.app.window.create('test.html', {
+ id: 'createTwiceUnfocused', focused: false,
+ bounds: { width: 200, height: 200 }
+ }, callbackPass(function(win) {
+ win.contentWindow.onload = callbackPass(function() {
+ chrome.app.window.create('test.html', {
+ id: 'createTwiceUnfocused', focused: false,
+ bounds: { width: 200, height: 200 }
+ }, callbackPass(testWindowNeverGetsFocus));
+ });
+ }));
+ },
+ function createFocusedWindow() {
+ chrome.app.window.create('test.html', {
+ bounds: { width: 200, height: 200 },
+ focused: true
+ }, callbackPass(testWindowGetsFocus));
+ },
+ function createDefaultFocusStateWindow() {
+ chrome.app.window.create('test.html', {
+ bounds: { width: 200, height: 200 },
+ }, callbackPass(testWindowGetsFocus));
+ },
+ function createTwiceFocusUnfocus() {
+ chrome.app.window.create('test.html', {
+ id: 'createTwiceFocusUnfocus', focused: true,
+ bounds: { width: 200, height: 200 }
+ }, callbackPass(function(win) {
+ win.contentWindow.onload = callbackPass(function() {
+ chrome.app.window.create('test.html', {
+ id: 'createTwiceFocusUnfocus', focused: false,
+ bounds: { width: 200, height: 200 }
+ }, callbackPass(testWindowGetsFocus));
+ });
+ }));
+ },
+ function createTwiceUnfocusFocus() {
+ chrome.app.window.create('test.html', {
+ id: 'createTwiceUnfocusFocus', focused: false,
+ bounds: { width: 200, height: 200 }
+ }, callbackPass(function(win) {
+ win.contentWindow.onload = callbackPass(function() {
+ chrome.app.window.create('test.html', {
+ id: 'createTwiceUnfocusFocus', focused: true,
+ bounds: { width: 200, height: 200 }
+ }, callbackPass(function() {
+ // This test fails on Linux GTK, see http://crbug.com/325219
+ // And none of those tests run on Linux Aura, see
+ // http://crbug.com/325142
+ if (navigator.platform.indexOf('Linux') != 0)
+ testWindowGetsFocus(win);
+ }));
+ });
+ }));
+ },
+ function createUnfocusThenShow() {
+ chrome.app.window.create('test.html', {
+ id: 'createUnfocusThenShow', focused: false,
+ bounds: { width: 200, height: 200 }
+ }, callbackPass(function(win) {
+ win.contentWindow.onload = callbackPass(function() {
+ win.show();
+ // This test fails on Linux GTK, see http://crbug.com/325219
+ // And none of those tests run on Linux Aura, see
+ // http://crbug.com/325142
+ if (navigator.platform.indexOf('Linux') != 0)
+ testWindowGetsFocus(win);
+ });
+ }));
+ },
+ ]);
+}
+
+chrome.app.runtime.onLaunched.addListener(function() {
+ chrome.test.sendMessage('Launched', function(reply) {
+ window[reply]();
+ });
+});