1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 var assertFalse = chrome.test.assertFalse;
6 var assertTrue = chrome.test.assertTrue;
7 var succeed = chrome.test.succeed;
9 function isAvailable(api) {
10 if (!(api in chrome.runtime))
14 var mightThrowException = chrome.runtime[api];
19 // Defined and doesn't throw an exception on access. It's available.
23 assertTrue(chrome.hasOwnProperty('runtime'), 'chrome.runtime not defined.');
25 // Would test lastError but it's only defined when there's been an error.
26 assertTrue(isAvailable('id'), 'id not available.');
27 assertTrue(isAvailable('getManifest'), 'getManifest not available');
28 assertTrue(isAvailable('getURL'), 'getManifest not available');
29 assertFalse(isAvailable('getBackgroundPage'), 'getBackgroundPage available');
30 assertFalse(isAvailable('onInstalled'), 'onInstalled available');
31 assertFalse(isAvailable('onSuspend'), 'onSuspend available');