summaryrefslogtreecommitdiffstats
path: root/chrome/test/data/extensions
diff options
context:
space:
mode:
authormek@chromium.org <mek@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-11-13 03:40:31 +0000
committermek@chromium.org <mek@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-11-13 03:40:31 +0000
commitc1e5fb151ec29af7c95f2a5d8712c6f8d879ef3a (patch)
treee2c0ceabd09bc415734825ba16d473cc689ab952 /chrome/test/data/extensions
parent1e2420662fae0f8046ecbc7dd1aa458cd7b56e2d (diff)
downloadchromium_src-c1e5fb151ec29af7c95f2a5d8712c6f8d879ef3a.zip
chromium_src-c1e5fb151ec29af7c95f2a5d8712c6f8d879ef3a.tar.gz
chromium_src-c1e5fb151ec29af7c95f2a5d8712c6f8d879ef3a.tar.bz2
Implement app.window.get() and app.window.getAll().
Also fixes the idl parser and schema compiler to support arrays as return types. BUG=179737 Review URL: https://codereview.chromium.org/57913004 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@234730 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/test/data/extensions')
-rw-r--r--chrome/test/data/extensions/platform_apps/windows_api_get/background.js75
-rw-r--r--chrome/test/data/extensions/platform_apps/windows_api_get/index.html1
-rw-r--r--chrome/test/data/extensions/platform_apps/windows_api_get/manifest.json10
3 files changed, 86 insertions, 0 deletions
diff --git a/chrome/test/data/extensions/platform_apps/windows_api_get/background.js b/chrome/test/data/extensions/platform_apps/windows_api_get/background.js
new file mode 100644
index 0000000..6f584a5
--- /dev/null
+++ b/chrome/test/data/extensions/platform_apps/windows_api_get/background.js
@@ -0,0 +1,75 @@
+// 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.
+
+function compareId(a, b) {
+ return a.id > b.id;
+}
+
+chrome.app.runtime.onLaunched.addListener(function() {
+ chrome.test.runTests([
+
+ function testGetAllNoWindows() {
+ chrome.test.assertEq({}, chrome.app.window.getAll());
+ chrome.test.succeed();
+ },
+
+ function testGetAllOneWindow() {
+ chrome.app.window.create('index.html', {id: 'win1'}, function(win) {
+ win.contentWindow.addEventListener('load', function() {
+ chrome.test.assertEq([win], chrome.app.window.getAll());
+ win.onClosed.addListener(function() {
+ chrome.test.succeed();
+ });
+ win.close();
+ });
+ });
+ },
+
+ function testGetAllMultipleWindows() {
+ chrome.app.window.create('index.html', {id: 'win1'}, function(win1) {
+ win1.contentWindow.addEventListener('load', function() {
+ chrome.app.window.create('index.html', {id: 'win2'}, function(win2) {
+ win2.contentWindow.addEventListener('load', function() {
+ var windows = chrome.app.window.getAll().sort(compareId);
+ chrome.test.assertEq([win1, win2], windows);
+ win2.onClosed.addListener(function() {
+ chrome.test.succeed();
+ });
+ win1.onClosed.addListener(function() {
+ win2.close();
+ });
+ win1.close();
+ });
+ });
+ });
+ });
+ },
+
+ function testGetNoWindows() {
+ chrome.test.assertEq(null, chrome.app.window.get(''));
+ chrome.test.succeed();
+ },
+
+ function testGet() {
+ chrome.app.window.create('index.html', {id: 'win1'}, function(win1) {
+ win1.contentWindow.addEventListener('load', function() {
+ chrome.app.window.create('index.html', {id: 'win2'}, function(win2) {
+ win2.contentWindow.addEventListener('load', function() {
+ chrome.test.assertEq(win1, chrome.app.window.get('win1'));
+ chrome.test.assertEq(win2, chrome.app.window.get('win2'));
+ chrome.test.assertEq(null, chrome.app.window.get('win3'));
+ win2.onClosed.addListener(function() {
+ chrome.test.succeed();
+ });
+ win1.onClosed.addListener(function() {
+ win2.close();
+ });
+ win1.close();
+ });
+ });
+ });
+ });
+ }
+ ]);
+});
diff --git a/chrome/test/data/extensions/platform_apps/windows_api_get/index.html b/chrome/test/data/extensions/platform_apps/windows_api_get/index.html
new file mode 100644
index 0000000..c341a40
--- /dev/null
+++ b/chrome/test/data/extensions/platform_apps/windows_api_get/index.html
@@ -0,0 +1 @@
+<!-- empty -->
diff --git a/chrome/test/data/extensions/platform_apps/windows_api_get/manifest.json b/chrome/test/data/extensions/platform_apps/windows_api_get/manifest.json
new file mode 100644
index 0000000..bbd3a80
--- /dev/null
+++ b/chrome/test/data/extensions/platform_apps/windows_api_get/manifest.json
@@ -0,0 +1,10 @@
+{
+ "name": "Windows API - get/getAll",
+ "version": "1",
+ "manifest_version": 2,
+ "app": {
+ "background": {
+ "scripts": ["background.js"]
+ }
+ }
+}