Pin Chrome's shortcut to the Win10 Start menu on install and OS upgrade.
[chromium-blink-merge.git] / chrome / test / data / extensions / api_test / content_scripts / extension_iframe / iframe.js
blobeb81f58131ebe54b0ae9fac9916d5ea037e805b1
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 // Simple success test: we want content-script APIs to be available (like
6 // sendRequest), but other APIs to be undefined or throw exceptions on access.
8 chrome.test.getConfig(function(config) {
9 'use strict';
11 let success = true;
12 let isSitePerProcess = config.sitePerProcess;
14 // chrome.storage should exist, since the extension has the permission, and
15 // the storage api is allowed in content scripts.
16 if (!chrome.storage) {
17 console.log("Error: chrome.storage doesn't exist; it should");
18 success = false;
21 let checkPrivilegedApi = function(api, name) {
22 if (api && !isSitePerProcess) {
23 console.log("Error: " + name +
24 " exists, but shouldn't without site-per-process.");
25 return false;
27 if (!api && isSitePerProcess) {
28 console.log("Error: " + name +
29 " doesn't exist, but should with site-per-process.");
30 return false;
32 return true;
35 // For other permissions, they should only be available if this is a trusted
36 // extension process - which is the case only with site-per-process.
37 // The whole of chrome.bookmarks (arbitrary unprivileged) is unavailable
38 // without site-per-process.
39 success = success && checkPrivilegedApi(chrome.bookmarks, 'chrome.bookmarks');
40 // We test chrome.tabs as a special case, because it's a dependency of the
41 // partially unprivileged chrome.extension.
42 success = success && checkPrivilegedApi(chrome.tabs, 'chrome.tabs');
43 // And parts of chrome.extension should be unavailable to unprivileged
44 // contexts.
45 success = success && checkPrivilegedApi(chrome.extension.getViews,
46 'chrome.extension.getViews');
48 chrome.extension.sendRequest({success: success});
49 });