Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / chrome / test / data / extensions / api_test / runtime / privileged / test.js
blob7aeb6fb49e3c81c00dabe965fd3b4dd7d9f29781
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');
13 return false;
15 if (!chrome.runtime[prop]) {
16 fail('chrome.runtime.' + prop + ' is not undefined');
17 return false;
19 return true;
22 chrome.test.runTests([
24 function testGetURL() {
25 if (!checkIsDefined('getURL'))
26 return;
27 var url = chrome.runtime.getURL('_generated_background_page.html');
28 assertEq(url, window.location.href);
29 succeed();
32 function testGetManifest() {
33 if (!checkIsDefined('getManifest'))
34 return;
35 var manifest = chrome.runtime.getManifest();
36 if (!manifest || !manifest.background || !manifest.background.scripts) {
37 fail();
38 return;
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']);
44 succeed();
47 function testID() {
48 if (!checkIsDefined('id'))
49 return;
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
52 // be good enough.
53 assertTrue(chrome.runtime.id != '', 'chrome.runtime.id is empty-string.');
54 succeed();
57 ]);