- add sources.
[platform/framework/web/crosswalk.git] / src / chrome / test / data / extensions / api_test / runtime / content_script / content_script.js
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.
4
5 var assertFalse = chrome.test.assertFalse;
6 var assertTrue = chrome.test.assertTrue;
7 var succeed = chrome.test.succeed;
8
9 function isAvailable(api) {
10   if (!(api in chrome.runtime))
11     return false;
12
13   try {
14     var mightThrowException = chrome.runtime[api];
15   } catch (e) {
16     return false;
17   }
18
19   // Defined and doesn't throw an exception on access. It's available.
20   return true;
21 }
22
23 assertTrue(chrome.hasOwnProperty('runtime'), 'chrome.runtime not defined.');
24
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');
32
33 succeed();