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 assertEq = chrome.test.assertEq;
6 var assertTrue = chrome.test.assertTrue;
7 var fail = chrome.test.fail;
8 var succeed = chrome.test.succeed;
10 function checkIsDefined(prop) {
11 if (!chrome.runtime) {
12 fail('chrome.runtime is not defined');
15 if (!chrome.runtime[prop]) {
16 fail('chrome.runtime.' + prop + ' is not undefined');
22 chrome.test.runTests([
24 function testGetURL() {
25 if (!checkIsDefined('getURL'))
27 var url = chrome.runtime.getURL('_generated_background_page.html');
28 assertEq(url, window.location.href);
32 function testGetManifest() {
33 if (!checkIsDefined('getManifest'))
35 var manifest = chrome.runtime.getManifest();
36 if (!manifest || !manifest.background || !manifest.background.scripts) {
40 assertEq(manifest.name, 'chrome.runtime API Test');
41 assertEq(manifest.version, '1');
42 assertEq(manifest.manifest_version, 2);
43 assertEq(manifest.background.scripts, ['test.js']);
48 if (!checkIsDefined('id'))
50 // We *could* get the browser to tell the test what the extension ID is,
51 // and compare against that. It's a pain. Testing for a non-empty ID should
53 assertTrue(chrome.runtime.id != '', 'chrome.runtime.id is empty-string.');